mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
All BlockInventory descendents now have a Position as holder
this allows multiple problems to be solved: 1) Cycle between tile and inventory is now removed. 2) BlockInventory now provides a consistent API for plugins to get the block holding an inventory.
This commit is contained in:
@ -53,11 +53,11 @@ class BrewingStand extends Spawnable implements Container, Nameable{
|
||||
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
$this->inventory = new BrewingStandInventory($this);
|
||||
$this->inventory->addChangeListeners(CallbackInventoryChangeListener::onAnyChange(function(Inventory $unused){
|
||||
$this->world->scheduleDelayedBlockUpdate($this->getBlock()->getPos(), 1);
|
||||
}));
|
||||
parent::__construct($world, $pos);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -54,8 +54,8 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
private $pairZ;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->inventory = new ChestInventory($this);
|
||||
parent::__construct($world, $pos);
|
||||
$this->inventory = new ChestInventory($this);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
@ -152,9 +152,9 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$this->doubleInventory = $pair->doubleInventory;
|
||||
}else{
|
||||
if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($pair, $this);
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($pair->inventory, $this->inventory);
|
||||
}else{
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($this, $pair);
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($this->inventory, $pair->inventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,14 +56,13 @@ class Furnace extends Spawnable implements Container, Nameable{
|
||||
private $maxFuelTime = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
parent::__construct($world, $pos);
|
||||
$this->inventory = new FurnaceInventory($this);
|
||||
$this->inventory->addChangeListeners(CallbackInventoryChangeListener::onAnyChange(
|
||||
function(Inventory $unused) : void{
|
||||
$this->world->scheduleDelayedBlockUpdate($this->asVector3(), 1);
|
||||
})
|
||||
);
|
||||
|
||||
parent::__construct($world, $pos);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -42,8 +42,8 @@ class Hopper extends Spawnable implements Container, Nameable{
|
||||
private $transferCooldown = 0;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->inventory = new HopperInventory($this);
|
||||
parent::__construct($world, $pos);
|
||||
$this->inventory = new HopperInventory($this);
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -50,8 +50,8 @@ abstract class Tile extends Position{
|
||||
protected $timings;
|
||||
|
||||
public function __construct(World $world, Vector3 $pos){
|
||||
$this->timings = Timings::getTileEntityTimings($this);
|
||||
parent::__construct($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ(), $world);
|
||||
$this->timings = Timings::getTileEntityTimings($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user