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.
This commit is contained in:
Dylan K. Taylor 2021-04-19 23:01:57 +01:00
parent 4e0bc6c98e
commit fc01735b6f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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;