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:
Dylan K. Taylor
2019-08-05 18:50:29 +01:00
parent 358fea9645
commit 9353f616a2
14 changed files with 36 additions and 95 deletions

View File

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