diff --git a/src/block/tile/BrewingStand.php b/src/block/tile/BrewingStand.php index 0046916be..21663d69c 100644 --- a/src/block/tile/BrewingStand.php +++ b/src/block/tile/BrewingStand.php @@ -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{ diff --git a/src/block/tile/Chest.php b/src/block/tile/Chest.php index edcde8fe9..6479c4628 100644 --- a/src/block/tile/Chest.php +++ b/src/block/tile/Chest.php @@ -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); } } } diff --git a/src/block/tile/Furnace.php b/src/block/tile/Furnace.php index 9db38e306..0cd82cfaa 100644 --- a/src/block/tile/Furnace.php +++ b/src/block/tile/Furnace.php @@ -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{ diff --git a/src/block/tile/Hopper.php b/src/block/tile/Hopper.php index 1d3f369bc..ee620b5c4 100644 --- a/src/block/tile/Hopper.php +++ b/src/block/tile/Hopper.php @@ -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{ diff --git a/src/block/tile/Tile.php b/src/block/tile/Tile.php index 3530cabc5..3eaeaaed4 100644 --- a/src/block/tile/Tile.php +++ b/src/block/tile/Tile.php @@ -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); } /** diff --git a/src/inventory/AnvilInventory.php b/src/inventory/AnvilInventory.php index c069816d0..e07ff965e 100644 --- a/src/inventory/AnvilInventory.php +++ b/src/inventory/AnvilInventory.php @@ -28,19 +28,8 @@ use pocketmine\world\Position; class AnvilInventory extends BlockInventory{ - /** @var Position */ - protected $holder; - - public function __construct(Position $pos){ - parent::__construct($pos->asPosition(), 2); - } - - /** - * This override is here for documentation and code completion purposes only. - * @return Position - */ - public function getHolder(){ - return $this->holder; + public function __construct(Position $holder){ + parent::__construct($holder, 2); } public function onClose(Player $who) : void{ diff --git a/src/inventory/BlockInventory.php b/src/inventory/BlockInventory.php index 46d0193e0..5e4267b61 100644 --- a/src/inventory/BlockInventory.php +++ b/src/inventory/BlockInventory.php @@ -23,19 +23,19 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\math\Vector3; +use pocketmine\world\Position; class BlockInventory extends BaseInventory{ - /** @var Vector3 */ + /** @var Position */ protected $holder; - public function __construct(Vector3 $holder, int $size){ - $this->holder = $holder; + public function __construct(Position $holder, int $size){ + $this->holder = $holder->asPosition(); parent::__construct($size); } /** - * @return Vector3 + * @return Position */ public function getHolder(){ return $this->holder; diff --git a/src/inventory/BrewingStandInventory.php b/src/inventory/BrewingStandInventory.php index 238cf99d7..48aaaa6b3 100644 --- a/src/inventory/BrewingStandInventory.php +++ b/src/inventory/BrewingStandInventory.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\math\Vector3; +use pocketmine\world\Position; class BrewingStandInventory extends BlockInventory{ - public function __construct(Vector3 $holder, int $size = 5){ + public function __construct(Position $holder, int $size = 5){ parent::__construct($holder, $size); } } diff --git a/src/inventory/ChestInventory.php b/src/inventory/ChestInventory.php index db7a788cf..49235d444 100644 --- a/src/inventory/ChestInventory.php +++ b/src/inventory/ChestInventory.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\block\tile\Chest; use pocketmine\network\mcpe\protocol\BlockEventPacket; use pocketmine\player\Player; +use pocketmine\world\Position; use pocketmine\world\sound\ChestCloseSound; use pocketmine\world\sound\ChestOpenSound; use pocketmine\world\sound\Sound; @@ -33,22 +33,11 @@ use function count; class ChestInventory extends BlockInventory{ - /** @var Chest */ - protected $holder; - /** - * @param Chest $tile + * @param Position $holder */ - public function __construct(Chest $tile){ - parent::__construct($tile, 27); - } - - /** - * This override is here for documentation and code completion purposes only. - * @return Chest - */ - public function getHolder(){ - return $this->holder; + public function __construct(Position $holder){ + parent::__construct($holder, 27); } protected function getOpenSound() : Sound{ diff --git a/src/inventory/DoubleChestInventory.php b/src/inventory/DoubleChestInventory.php index f600cf0b4..451ddc7a7 100644 --- a/src/inventory/DoubleChestInventory.php +++ b/src/inventory/DoubleChestInventory.php @@ -23,9 +23,9 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\block\tile\Chest; use pocketmine\item\Item; use pocketmine\player\Player; +use pocketmine\world\Position; use function count; class DoubleChestInventory extends ChestInventory implements InventoryHolder{ @@ -34,9 +34,9 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ /** @var ChestInventory */ private $right; - public function __construct(Chest $left, Chest $right){ - $this->left = $left->getRealInventory(); - $this->right = $right->getRealInventory(); + public function __construct(ChestInventory $left, ChestInventory $right){ + $this->left = $left; + $this->right = $right; BaseInventory::__construct($this->left->getSize() + $this->right->getSize()); } @@ -45,7 +45,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ } /** - * @return Chest + * @return Position */ public function getHolder(){ return $this->left->getHolder(); diff --git a/src/inventory/EnchantInventory.php b/src/inventory/EnchantInventory.php index 74d40d687..06d7f651c 100644 --- a/src/inventory/EnchantInventory.php +++ b/src/inventory/EnchantInventory.php @@ -28,19 +28,8 @@ use pocketmine\world\Position; class EnchantInventory extends BlockInventory{ - /** @var Position */ - protected $holder; - - public function __construct(Position $pos){ - parent::__construct($pos->asPosition(), 2); - } - - /** - * This override is here for documentation and code completion purposes only. - * @return Position - */ - public function getHolder(){ - return $this->holder; + public function __construct(Position $holder){ + parent::__construct($holder, 2); } public function onClose(Player $who) : void{ diff --git a/src/inventory/EnderChestInventory.php b/src/inventory/EnderChestInventory.php index 1986ac7d0..935ee7fe7 100644 --- a/src/inventory/EnderChestInventory.php +++ b/src/inventory/EnderChestInventory.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\block\tile\EnderChest; use pocketmine\world\Position; use pocketmine\world\sound\EnderChestCloseSound; use pocketmine\world\sound\EnderChestOpenSound; @@ -31,21 +30,15 @@ use pocketmine\world\sound\Sound; class EnderChestInventory extends ChestInventory{ - /** @var Position */ - protected $holder; - public function __construct(){ - BlockInventory::__construct(new Position(), 27); + parent::__construct(new Position(0, 0, 0, null)); } /** - * Set the holder's position to that of a tile - * - * @param EnderChest $enderChest + * @param Position $pos */ - public function setHolderPosition(EnderChest $enderChest) : void{ - $this->holder->setComponents($enderChest->getFloorX(), $enderChest->getFloorY(), $enderChest->getFloorZ()); - $this->holder->setWorld($enderChest->getWorld()); + public function setHolderPosition(Position $pos) : void{ + $this->holder = $pos->asPosition(); } protected function getOpenSound() : Sound{ @@ -55,12 +48,4 @@ class EnderChestInventory extends ChestInventory{ protected function getCloseSound() : Sound{ return new EnderChestCloseSound(); } - - /** - * This override is here for documentation and code completion purposes only. - * @return Position - */ - public function getHolder(){ - return $this->holder; - } } diff --git a/src/inventory/FurnaceInventory.php b/src/inventory/FurnaceInventory.php index 6a95c49aa..b04620dd9 100644 --- a/src/inventory/FurnaceInventory.php +++ b/src/inventory/FurnaceInventory.php @@ -23,23 +23,13 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\block\tile\Furnace; use pocketmine\item\Item; +use pocketmine\world\Position; class FurnaceInventory extends BlockInventory{ - /** @var Furnace */ - protected $holder; - public function __construct(Furnace $tile){ - parent::__construct($tile, 3); - } - - /** - * This override is here for documentation and code completion purposes only. - * @return Furnace - */ - public function getHolder(){ - return $this->holder; + public function __construct(Position $holder){ + parent::__construct($holder, 3); } /** diff --git a/src/inventory/HopperInventory.php b/src/inventory/HopperInventory.php index af77a7a45..8378458ce 100644 --- a/src/inventory/HopperInventory.php +++ b/src/inventory/HopperInventory.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace pocketmine\inventory; -use pocketmine\math\Vector3; +use pocketmine\world\Position; class HopperInventory extends BlockInventory{ - public function __construct(Vector3 $holder, int $size = 5){ + public function __construct(Position $holder, int $size = 5){ parent::__construct($holder, $size); } }