mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Chest block now has responsibility for configuring double chest inventories
it already needs to locate the correct pair anyway to know the left/right for DoubleChestInventoryWindow, so we might as well use this logic for initializing the DoubleChestInventory itself too. The old logic in tile/Chest didn't work correctly.
This commit is contained in:
@ -115,15 +115,14 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
$this->containerTraitBlockDestroyedHook();
|
||||
}
|
||||
|
||||
public function getInventory() : Inventory|DoubleChestInventory{
|
||||
if($this->isPaired() && $this->doubleInventory === null){
|
||||
$this->checkPairing();
|
||||
}
|
||||
return $this->doubleInventory instanceof DoubleChestInventory ? $this->doubleInventory : $this->inventory;
|
||||
public function getInventory() : Inventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
public function getRealInventory() : Inventory{
|
||||
return $this->inventory;
|
||||
public function getDoubleInventory() : ?DoubleChestInventory{ return $this->doubleInventory; }
|
||||
|
||||
public function setDoubleInventory(?DoubleChestInventory $doubleChestInventory) : void{
|
||||
$this->doubleInventory = $doubleChestInventory;
|
||||
}
|
||||
|
||||
protected function checkPairing() : void{
|
||||
@ -134,18 +133,7 @@ class Chest extends Spawnable implements Container, Nameable{
|
||||
}elseif(($pair = $this->getPair()) instanceof Chest){
|
||||
if(!$pair->isPaired()){
|
||||
$pair->createPair($this);
|
||||
$pair->checkPairing();
|
||||
}
|
||||
if($this->doubleInventory === null){
|
||||
if($pair->doubleInventory !== null){
|
||||
$this->doubleInventory = $pair->doubleInventory;
|
||||
}else{
|
||||
if(($pair->position->x + ($pair->position->z << 15)) > ($this->position->x + ($this->position->z << 15))){ //Order them correctly
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($pair->inventory, $this->inventory);
|
||||
}else{
|
||||
$this->doubleInventory = $pair->doubleInventory = new DoubleChestInventory($this->inventory, $pair->inventory);
|
||||
}
|
||||
}
|
||||
$this->doubleInventory = $pair->doubleInventory = null;
|
||||
}
|
||||
}else{
|
||||
$this->doubleInventory = null;
|
||||
|
Reference in New Issue
Block a user