From fc01735b6fbd71112412c127ef75537803b600ac Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Mon, 19 Apr 2021 23:01:57 +0100 Subject: [PATCH] Fixed infinite loop when placing two coral plants next to each other the dead flag is not persisted in their metadata, so they forget their state when next read from the world. --- src/block/Coral.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/block/Coral.php b/src/block/Coral.php index ad535ec7b..fd74e69cc 100644 --- a/src/block/Coral.php +++ b/src/block/Coral.php @@ -30,6 +30,18 @@ use pocketmine\world\BlockTransaction; final class Coral extends BaseCoral{ + public function readStateFromWorld() : void{ + //TODO: this hack ensures correct state of coral plants, because they don't retain their dead flag in metadata + $world = $this->pos->getWorld(); + $this->dead = true; + foreach($this->pos->sides() as $vector3){ + if($world->getBlock($vector3) instanceof Water){ + $this->dead = false; + break; + } + } + } + public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ if(!$tx->fetchBlock($blockReplace->getPos()->down())->isSolid()){ return false;