Tiles now encapsulate positions instead of extending them

This commit is contained in:
Dylan K. Taylor
2019-08-05 19:33:34 +01:00
parent d355d5b5b5
commit 4e5b296c8c
10 changed files with 58 additions and 45 deletions

View File

@ -57,10 +57,10 @@ class Furnace extends Spawnable implements Container, Nameable{
public function __construct(World $world, Vector3 $pos){
parent::__construct($world, $pos);
$this->inventory = new FurnaceInventory($this);
$this->inventory = new FurnaceInventory($this->pos);
$this->inventory->addChangeListeners(CallbackInventoryChangeListener::onAnyChange(
function(Inventory $unused) : void{
$this->world->scheduleDelayedBlockUpdate($this->asVector3(), 1);
$this->pos->getWorld()->scheduleDelayedBlockUpdate($this->pos, 1);
})
);
}
@ -132,7 +132,7 @@ class Furnace extends Spawnable implements Container, Nameable{
$block = $this->getBlock();
if($block instanceof BlockFurnace and !$block->isLit()){
$block->setLit(true);
$this->getWorld()->setBlock($block->getPos(), $block);
$this->pos->getWorld()->setBlock($block->getPos(), $block);
}
if($this->remainingFuelTime > 0 and $ev->isBurning()){
@ -158,7 +158,7 @@ class Furnace extends Spawnable implements Container, Nameable{
$fuel = $this->inventory->getFuel();
$raw = $this->inventory->getSmelting();
$product = $this->inventory->getResult();
$smelt = $this->world->getServer()->getCraftingManager()->matchFurnaceRecipe($raw);
$smelt = $this->pos->getWorld()->getServer()->getCraftingManager()->matchFurnaceRecipe($raw);
$canSmelt = ($smelt instanceof FurnaceRecipe and $raw->getCount() > 0 and (($smelt->getResult()->equals($product) and $product->getCount() < $product->getMaxStackSize()) or $product->isNull()));
if($this->remainingFuelTime <= 0 and $canSmelt and $fuel->getFuelTime() > 0 and $fuel->getCount() > 0){
@ -195,7 +195,7 @@ class Furnace extends Spawnable implements Container, Nameable{
$block = $this->getBlock();
if($block instanceof BlockFurnace and $block->isLit()){
$block->setLit(false);
$this->getWorld()->setBlock($block->getPos(), $block);
$this->pos->getWorld()->setBlock($block->getPos(), $block);
}
$this->remainingFuelTime = $this->cookTime = $this->maxFuelTime = 0;
}