From 5d970cf5bdfd1ce09dfa349e77fd225cbbebe069 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 3 Mar 2022 19:19:59 +0000 Subject: [PATCH] Fire: do not overwrite blocks during burning unless they were unchanged by onIncinerate() onIncinerate() by custom blocks might produce custom results which aren't supposed to be burned away (e.g. wood could turn into charred wood, or something of that nature). closes #4764 --- src/block/Fire.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/block/Fire.php b/src/block/Fire.php index 1b73882b0..cd8447c2a 100644 --- a/src/block/Fire.php +++ b/src/block/Fire.php @@ -180,14 +180,16 @@ class Fire extends Flowable{ if(!$ev->isCancelled()){ $block->onIncinerate(); - $spreadedFire = false; - if(mt_rand(0, $this->age + 9) < 5){ //TODO: check rain - $fire = clone $this; - $fire->age = min(15, $fire->age + (mt_rand(0, 4) >> 2)); - $spreadedFire = $this->spreadBlock($block, $fire); - } - if(!$spreadedFire){ - $this->position->getWorld()->setBlock($block->position, VanillaBlocks::AIR()); + if($this->position->getWorld()->getBlock($block->getPosition())->isSameState($block)){ + $spreadedFire = false; + if(mt_rand(0, $this->age + 9) < 5){ //TODO: check rain + $fire = clone $this; + $fire->age = min(15, $fire->age + (mt_rand(0, 4) >> 2)); + $spreadedFire = $this->spreadBlock($block, $fire); + } + if(!$spreadedFire){ + $this->position->getWorld()->setBlock($block->position, VanillaBlocks::AIR()); + } } } }