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
This commit is contained in:
Dylan K. Taylor
2022-03-03 19:19:59 +00:00
parent 58e186440b
commit 5d970cf5bd

View File

@ -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());
}
}
}
}