diff --git a/src/pocketmine/block/Bedrock.php b/src/pocketmine/block/Bedrock.php index 91fb7fe4c..c2ef58093 100644 --- a/src/pocketmine/block/Bedrock.php +++ b/src/pocketmine/block/Bedrock.php @@ -27,6 +27,21 @@ use pocketmine\item\Item; class Bedrock extends Solid{ + /** @var bool */ + private $burnsForever = false; + + public function readStateFromData(int $id, int $stateMeta) : void{ + $this->burnsForever = $stateMeta !== 0; + } + + protected function writeStateToMeta() : int{ + return $this->burnsForever ? 1 : 0; + } + + public function getStateBitmask() : int{ + return 0b1; + } + public function getHardness() : float{ return -1; } @@ -38,4 +53,8 @@ class Bedrock extends Solid{ public function isBreakable(Item $item) : bool{ return false; } + + public function burnsForever() : bool{ + return $this->burnsForever; + } } diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index d56d7b74b..3b74bee1c 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -40,10 +40,33 @@ use const M_PI; class TNT extends Solid{ + /** @var bool */ + protected $unstable = false; //TODO: Usage unclear, seems to be a weird hack in vanilla + + public function readStateFromData(int $id, int $stateMeta) : void{ + $this->unstable = $stateMeta !== 0; + } + + protected function writeStateToMeta() : int{ + return $this->unstable ? 1 : 0; + } + + public function getStateBitmask() : int{ + return 0b1; + } + public function getHardness() : float{ return 0; } + public function onBreak(Item $item, ?Player $player = null) : bool{ + if($this->unstable){ + $this->ignite(); + return true; + } + return parent::onBreak($item, $player); + } + public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if($item instanceof FlintSteel or $item->hasEnchantment(Enchantment::FIRE_ASPECT())){ if($item instanceof Durable){