From ce55183d7138eafa39d6353f104090194b21c737 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 30 Apr 2025 19:52:49 +0100 Subject: [PATCH] ... --- src/block/Anvil.php | 2 +- src/block/Barrel.php | 2 +- src/block/BrewingStand.php | 2 +- src/block/CartographyTable.php | 2 +- src/block/Chest.php | 4 ++-- src/block/CraftingTable.php | 2 +- src/block/EnchantingTable.php | 2 +- src/block/EnderChest.php | 2 +- src/block/Furnace.php | 2 +- src/block/Hopper.php | 2 +- src/block/Loom.php | 2 +- src/block/ShulkerBox.php | 2 +- src/block/SmithingTable.php | 2 +- src/block/Stonecutter.php | 2 +- src/block/inventory/window/AnvilInventoryWindow.php | 4 ++-- src/block/inventory/window/BlockInventoryWindow.php | 1 - .../window/CartographyTableInventoryWindow.php | 4 ++-- .../inventory/window/CraftingTableInventoryWindow.php | 4 ++-- .../inventory/window/DoubleChestInventoryWindow.php | 10 +++++----- .../window/EnchantingTableInventoryWindow.php | 6 +++--- src/block/inventory/window/FurnaceInventoryWindow.php | 4 ++-- src/block/inventory/window/LoomInventoryWindow.php | 4 ++-- .../inventory/window/SmithingTableInventoryWindow.php | 4 ++-- .../inventory/window/StonecutterInventoryWindow.php | 4 ++-- 24 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/block/Anvil.php b/src/block/Anvil.php index f23a0156c0..c98f20b5eb 100644 --- a/src/block/Anvil.php +++ b/src/block/Anvil.php @@ -80,7 +80,7 @@ class Anvil extends Transparent implements Fallable{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player instanceof Player){ - $player->setCurrentWindow(new AnvilInventoryWindow($player, $this)); + $player->setCurrentWindow(new AnvilInventoryWindow($player, $this->position)); } return true; diff --git a/src/block/Barrel.php b/src/block/Barrel.php index 999f82db47..1b64e814c5 100644 --- a/src/block/Barrel.php +++ b/src/block/Barrel.php @@ -89,7 +89,7 @@ class Barrel extends Opaque implements AnimatedContainer{ return true; } - $player->setCurrentWindow(new BlockInventoryWindow($player, $barrel->getInventory(), $this)); + $player->setCurrentWindow(new BlockInventoryWindow($player, $barrel->getInventory(), $this->position)); } } diff --git a/src/block/BrewingStand.php b/src/block/BrewingStand.php index ca143e6b1d..59e439b91e 100644 --- a/src/block/BrewingStand.php +++ b/src/block/BrewingStand.php @@ -100,7 +100,7 @@ class BrewingStand extends Transparent{ if($player instanceof Player){ $stand = $this->position->getWorld()->getTile($this->position); if($stand instanceof TileBrewingStand && $stand->canOpenWith($item->getCustomName())){ - $player->setCurrentWindow(new BrewingStandInventoryWindow($player, $stand->getInventory(), $this)); + $player->setCurrentWindow(new BrewingStandInventoryWindow($player, $stand->getInventory(), $this->position)); } } diff --git a/src/block/CartographyTable.php b/src/block/CartographyTable.php index 436850e83b..1c3e94096a 100644 --- a/src/block/CartographyTable.php +++ b/src/block/CartographyTable.php @@ -32,7 +32,7 @@ final class CartographyTable extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player !== null){ - $player->setCurrentWindow(new CartographyTableInventoryWindow($player, $this)); + $player->setCurrentWindow(new CartographyTableInventoryWindow($player, $this->position)); } return true; diff --git a/src/block/Chest.php b/src/block/Chest.php index a46252f1d0..414648d37a 100644 --- a/src/block/Chest.php +++ b/src/block/Chest.php @@ -119,10 +119,10 @@ class Chest extends Transparent implements AnimatedContainer{ //TODO: we should probably construct DoubleChestInventory here directly too using the same logic //right now it uses some weird logic in TileChest which produces incorrect results //however I'm not sure if this is currently possible - $window = new DoubleChestInventoryWindow($player, $chest->getInventory(), $left, $right); + $window = new DoubleChestInventoryWindow($player, $chest->getInventory(), $left->position, $right->position); } - $player->setCurrentWindow($window ?? new BlockInventoryWindow($player, $chest->getInventory(), $this)); + $player->setCurrentWindow($window ?? new BlockInventoryWindow($player, $chest->getInventory(), $this->position)); } } diff --git a/src/block/CraftingTable.php b/src/block/CraftingTable.php index 06824824b7..2b73d221ae 100644 --- a/src/block/CraftingTable.php +++ b/src/block/CraftingTable.php @@ -32,7 +32,7 @@ class CraftingTable extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player instanceof Player){ - $player->setCurrentWindow(new CraftingTableInventoryWindow($player, $this)); + $player->setCurrentWindow(new CraftingTableInventoryWindow($player, $this->position)); } return true; diff --git a/src/block/EnchantingTable.php b/src/block/EnchantingTable.php index 6594c3d611..a5ac989d49 100644 --- a/src/block/EnchantingTable.php +++ b/src/block/EnchantingTable.php @@ -45,7 +45,7 @@ class EnchantingTable extends Transparent{ if($player instanceof Player){ //TODO lock - $player->setCurrentWindow(new EnchantingTableInventoryWindow($player, $this)); + $player->setCurrentWindow(new EnchantingTableInventoryWindow($player, $this->position)); } return true; diff --git a/src/block/EnderChest.php b/src/block/EnderChest.php index 9cb3552eaa..0d1d7fd5cc 100644 --- a/src/block/EnderChest.php +++ b/src/block/EnderChest.php @@ -65,7 +65,7 @@ class EnderChest extends Transparent implements AnimatedContainer{ if($player instanceof Player){ $enderChest = $this->position->getWorld()->getTile($this->position); if($enderChest instanceof TileEnderChest && $this->getSide(Facing::UP)->isTransparent()){ - $player->setCurrentWindow(new BlockInventoryWindow($player, $player->getEnderInventory(), $this)); + $player->setCurrentWindow(new BlockInventoryWindow($player, $player->getEnderInventory(), $this->position)); } } diff --git a/src/block/Furnace.php b/src/block/Furnace.php index 412ac74a81..2c4433413b 100644 --- a/src/block/Furnace.php +++ b/src/block/Furnace.php @@ -62,7 +62,7 @@ class Furnace extends Opaque{ if($player instanceof Player){ $furnace = $this->position->getWorld()->getTile($this->position); if($furnace instanceof TileFurnace && $furnace->canOpenWith($item->getCustomName())){ - $player->setCurrentWindow(new FurnaceInventoryWindow($player, $furnace->getInventory(), $this, $this->furnaceType)); + $player->setCurrentWindow(new FurnaceInventoryWindow($player, $furnace->getInventory(), $this->position, $this->furnaceType)); } } diff --git a/src/block/Hopper.php b/src/block/Hopper.php index 67273b04df..8c65e836c9 100644 --- a/src/block/Hopper.php +++ b/src/block/Hopper.php @@ -85,7 +85,7 @@ class Hopper extends Transparent{ if($player !== null){ $tile = $this->position->getWorld()->getTile($this->position); if($tile instanceof TileHopper){ //TODO: find a way to have inventories open on click without this boilerplate in every block - $player->setCurrentWindow(new HopperInventoryWindow($player, $tile->getInventory(), $this)); + $player->setCurrentWindow(new HopperInventoryWindow($player, $tile->getInventory(), $this->position)); } return true; } diff --git a/src/block/Loom.php b/src/block/Loom.php index a4d6f7da41..d19fc9449d 100644 --- a/src/block/Loom.php +++ b/src/block/Loom.php @@ -34,7 +34,7 @@ final class Loom extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player !== null){ - $player->setCurrentWindow(new LoomInventoryWindow($player, $this)); + $player->setCurrentWindow(new LoomInventoryWindow($player, $this->position)); return true; } return false; diff --git a/src/block/ShulkerBox.php b/src/block/ShulkerBox.php index c575ecae1b..1700339633 100644 --- a/src/block/ShulkerBox.php +++ b/src/block/ShulkerBox.php @@ -115,7 +115,7 @@ class ShulkerBox extends Opaque implements AnimatedContainer{ return true; } - $player->setCurrentWindow(new BlockInventoryWindow($player, $shulker->getInventory(), $this)); + $player->setCurrentWindow(new BlockInventoryWindow($player, $shulker->getInventory(), $this->position)); } } diff --git a/src/block/SmithingTable.php b/src/block/SmithingTable.php index 77816c42de..b96a582d10 100644 --- a/src/block/SmithingTable.php +++ b/src/block/SmithingTable.php @@ -32,7 +32,7 @@ final class SmithingTable extends Opaque{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player !== null){ - $player->setCurrentWindow(new SmithingTableInventoryWindow($player, $this)); + $player->setCurrentWindow(new SmithingTableInventoryWindow($player, $this->position)); } return true; diff --git a/src/block/Stonecutter.php b/src/block/Stonecutter.php index 20fc73da52..3c22e74a83 100644 --- a/src/block/Stonecutter.php +++ b/src/block/Stonecutter.php @@ -37,7 +37,7 @@ class Stonecutter extends Transparent{ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player !== null){ - $player->setCurrentWindow(new StonecutterInventoryWindow($player, $this)); + $player->setCurrentWindow(new StonecutterInventoryWindow($player, $this->position)); } return true; } diff --git a/src/block/inventory/window/AnvilInventoryWindow.php b/src/block/inventory/window/AnvilInventoryWindow.php index 8137201514..2b994a90da 100644 --- a/src/block/inventory/window/AnvilInventoryWindow.php +++ b/src/block/inventory/window/AnvilInventoryWindow.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\SimpleInventory; use pocketmine\player\Player; use pocketmine\player\TemporaryInventoryWindow; +use pocketmine\world\Position; final class AnvilInventoryWindow extends BlockInventoryWindow implements TemporaryInventoryWindow{ public const SLOT_INPUT = 0; @@ -34,7 +34,7 @@ final class AnvilInventoryWindow extends BlockInventoryWindow implements Tempora public function __construct( Player $viewer, - Block $holder + Position $holder ){ parent::__construct($viewer, new SimpleInventory(2), $holder); } diff --git a/src/block/inventory/window/BlockInventoryWindow.php b/src/block/inventory/window/BlockInventoryWindow.php index 902f4130a0..149c2e8142 100644 --- a/src/block/inventory/window/BlockInventoryWindow.php +++ b/src/block/inventory/window/BlockInventoryWindow.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\block\utils\AnimatedContainer; use pocketmine\inventory\Inventory; use pocketmine\player\InventoryWindow; diff --git a/src/block/inventory/window/CartographyTableInventoryWindow.php b/src/block/inventory/window/CartographyTableInventoryWindow.php index c9998231c3..22d2d5c430 100644 --- a/src/block/inventory/window/CartographyTableInventoryWindow.php +++ b/src/block/inventory/window/CartographyTableInventoryWindow.php @@ -23,16 +23,16 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\SimpleInventory; use pocketmine\player\Player; use pocketmine\player\TemporaryInventoryWindow; +use pocketmine\world\Position; final class CartographyTableInventoryWindow extends BlockInventoryWindow implements TemporaryInventoryWindow{ public function __construct( Player $viewer, - Block $holder + Position $holder ){ parent::__construct($viewer, new SimpleInventory(2), $holder); } diff --git a/src/block/inventory/window/CraftingTableInventoryWindow.php b/src/block/inventory/window/CraftingTableInventoryWindow.php index 914a307965..46e5485e5f 100644 --- a/src/block/inventory/window/CraftingTableInventoryWindow.php +++ b/src/block/inventory/window/CraftingTableInventoryWindow.php @@ -23,15 +23,15 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\crafting\CraftingGrid; use pocketmine\player\Player; +use pocketmine\world\Position; final class CraftingTableInventoryWindow extends BlockInventoryWindow{ public function __construct( Player $viewer, - Block $holder + Position $holder ){ //TODO: generics would be good for this, since it has special methods parent::__construct($viewer, new CraftingGrid(CraftingGrid::SIZE_BIG), $holder); diff --git a/src/block/inventory/window/DoubleChestInventoryWindow.php b/src/block/inventory/window/DoubleChestInventoryWindow.php index 3fcf96ac5e..801a6ff9d0 100644 --- a/src/block/inventory/window/DoubleChestInventoryWindow.php +++ b/src/block/inventory/window/DoubleChestInventoryWindow.php @@ -23,22 +23,22 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\Inventory; use pocketmine\player\Player; +use pocketmine\world\Position; final class DoubleChestInventoryWindow extends BlockInventoryWindow{ public function __construct( Player $viewer, Inventory $inventory, - private Block $left, - private Block $right + private Position $left, + private Position $right ){ parent::__construct($viewer, $inventory, $this->left); } - public function getLeft() : Block{ return $this->left; } + public function getLeft() : Position{ return $this->left; } - public function getRight() : Block{ return $this->right; } + public function getRight() : Position{ return $this->right; } } diff --git a/src/block/inventory/window/EnchantingTableInventoryWindow.php b/src/block/inventory/window/EnchantingTableInventoryWindow.php index 2a77870220..6a24d449e1 100644 --- a/src/block/inventory/window/EnchantingTableInventoryWindow.php +++ b/src/block/inventory/window/EnchantingTableInventoryWindow.php @@ -23,7 +23,6 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\event\player\PlayerEnchantingOptionsRequestEvent; use pocketmine\inventory\CallbackInventoryListener; use pocketmine\inventory\Inventory; @@ -33,6 +32,7 @@ use pocketmine\item\enchantment\EnchantingHelper as Helper; use pocketmine\item\enchantment\EnchantingOption; use pocketmine\item\Item; use pocketmine\player\Player; +use pocketmine\world\Position; use function array_values; use function count; @@ -47,7 +47,7 @@ final class EnchantingTableInventoryWindow extends BlockInventoryWindow{ public function __construct( Player $viewer, - Block $holder + Position $holder ){ parent::__construct($viewer, new SimpleInventory(2), $holder); @@ -75,7 +75,7 @@ final class EnchantingTableInventoryWindow extends BlockInventoryWindow{ private function regenerateOptions() : void{ $this->options = []; $item = $this->getInput(); - $options = Helper::generateOptions($this->holder->getPosition(), $item, $this->viewer->getEnchantmentSeed()); + $options = Helper::generateOptions($this->holder, $item, $this->viewer->getEnchantmentSeed()); $event = new PlayerEnchantingOptionsRequestEvent($this->viewer, $this, $options); $event->call(); diff --git a/src/block/inventory/window/FurnaceInventoryWindow.php b/src/block/inventory/window/FurnaceInventoryWindow.php index 9667bf6315..11d36324c7 100644 --- a/src/block/inventory/window/FurnaceInventoryWindow.php +++ b/src/block/inventory/window/FurnaceInventoryWindow.php @@ -23,11 +23,11 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\crafting\FurnaceType; use pocketmine\inventory\Inventory; use pocketmine\item\Item; use pocketmine\player\Player; +use pocketmine\world\Position; final class FurnaceInventoryWindow extends BlockInventoryWindow{ public const SLOT_INPUT = 0; @@ -37,7 +37,7 @@ final class FurnaceInventoryWindow extends BlockInventoryWindow{ public function __construct( Player $viewer, Inventory $inventory, - Block $holder, + Position $holder, private FurnaceType $furnaceType ){ parent::__construct($viewer, $inventory, $holder); diff --git a/src/block/inventory/window/LoomInventoryWindow.php b/src/block/inventory/window/LoomInventoryWindow.php index d59050ba45..ceb27ac1ac 100644 --- a/src/block/inventory/window/LoomInventoryWindow.php +++ b/src/block/inventory/window/LoomInventoryWindow.php @@ -23,10 +23,10 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\SimpleInventory; use pocketmine\player\Player; use pocketmine\player\TemporaryInventoryWindow; +use pocketmine\world\Position; final class LoomInventoryWindow extends BlockInventoryWindow implements TemporaryInventoryWindow{ @@ -36,7 +36,7 @@ final class LoomInventoryWindow extends BlockInventoryWindow implements Temporar public function __construct( Player $viewer, - Block $holder + Position $holder ){ parent::__construct($viewer, new SimpleInventory(3), $holder); } diff --git a/src/block/inventory/window/SmithingTableInventoryWindow.php b/src/block/inventory/window/SmithingTableInventoryWindow.php index 4524ecb2a4..7cb850ef0b 100644 --- a/src/block/inventory/window/SmithingTableInventoryWindow.php +++ b/src/block/inventory/window/SmithingTableInventoryWindow.php @@ -23,13 +23,13 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\SimpleInventory; use pocketmine\player\Player; use pocketmine\player\TemporaryInventoryWindow; +use pocketmine\world\Position; final class SmithingTableInventoryWindow extends BlockInventoryWindow implements TemporaryInventoryWindow{ - public function __construct(Player $viewer, Block $holder){ + public function __construct(Player $viewer, Position $holder){ parent::__construct($viewer, new SimpleInventory(3), $holder); } } diff --git a/src/block/inventory/window/StonecutterInventoryWindow.php b/src/block/inventory/window/StonecutterInventoryWindow.php index a17925110f..a7a29a9743 100644 --- a/src/block/inventory/window/StonecutterInventoryWindow.php +++ b/src/block/inventory/window/StonecutterInventoryWindow.php @@ -23,15 +23,15 @@ declare(strict_types=1); namespace pocketmine\block\inventory\window; -use pocketmine\block\Block; use pocketmine\inventory\SimpleInventory; use pocketmine\player\Player; use pocketmine\player\TemporaryInventoryWindow; +use pocketmine\world\Position; final class StonecutterInventoryWindow extends BlockInventoryWindow implements TemporaryInventoryWindow{ public const SLOT_INPUT = 0; - public function __construct(Player $viewer, Block $holder){ + public function __construct(Player $viewer, Position $holder){ parent::__construct($viewer, new SimpleInventory(1), $holder); } }