mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-01 07:39:57 +00:00
Furnace: Separate light/extinguish code into onStartSmelting() and onStopSmelting() hooks
this is a preparation for other kinds of furnaces which might not be plain old Furnaces.
This commit is contained in:
parent
9abdcd8ee5
commit
d5e1b4bd39
@ -124,15 +124,26 @@ class Furnace extends Spawnable implements Container, Nameable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->maxFuelTime = $this->remainingFuelTime = $ev->getBurnTime();
|
$this->maxFuelTime = $this->remainingFuelTime = $ev->getBurnTime();
|
||||||
|
$this->onStartSmelting();
|
||||||
|
|
||||||
|
if($this->remainingFuelTime > 0 and $ev->isBurning()){
|
||||||
|
$this->inventory->setFuel($fuel->getFuelResidue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function onStartSmelting() : void{
|
||||||
$block = $this->getBlock();
|
$block = $this->getBlock();
|
||||||
if($block instanceof BlockFurnace and !$block->isLit()){
|
if($block instanceof BlockFurnace and !$block->isLit()){
|
||||||
$block->setLit(true);
|
$block->setLit(true);
|
||||||
$this->pos->getWorld()->setBlock($block->getPos(), $block);
|
$this->pos->getWorld()->setBlock($block->getPos(), $block);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($this->remainingFuelTime > 0 and $ev->isBurning()){
|
protected function onStopSmelting() : void{
|
||||||
$this->inventory->setFuel($fuel->getFuelResidue());
|
$block = $this->getBlock();
|
||||||
|
if($block instanceof BlockFurnace and $block->isLit()){
|
||||||
|
$block->setLit(false);
|
||||||
|
$this->pos->getWorld()->setBlock($block->getPos(), $block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,11 +198,7 @@ class Furnace extends Spawnable implements Container, Nameable{
|
|||||||
}
|
}
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}else{
|
}else{
|
||||||
$block = $this->getBlock();
|
$this->onStopSmelting();
|
||||||
if($block instanceof BlockFurnace and $block->isLit()){
|
|
||||||
$block->setLit(false);
|
|
||||||
$this->pos->getWorld()->setBlock($block->getPos(), $block);
|
|
||||||
}
|
|
||||||
$this->remainingFuelTime = $this->cookTime = $this->maxFuelTime = 0;
|
$this->remainingFuelTime = $this->cookTime = $this->maxFuelTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user