From 4e734989bccabac78164d6663dfa294d6974049b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 15 Jun 2019 18:56:42 +0100 Subject: [PATCH] fixing add/remove items from anvil & enchanting table the functionality of these don't work yet, but the inventories work more correctly now. --- .../protocol/types/NetworkInventoryAction.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pocketmine/network/mcpe/protocol/types/NetworkInventoryAction.php b/src/pocketmine/network/mcpe/protocol/types/NetworkInventoryAction.php index 49fa75622..8318d6159 100644 --- a/src/pocketmine/network/mcpe/protocol/types/NetworkInventoryAction.php +++ b/src/pocketmine/network/mcpe/protocol/types/NetworkInventoryAction.php @@ -23,6 +23,8 @@ declare(strict_types=1); namespace pocketmine\network\mcpe\protocol\types; +use pocketmine\inventory\AnvilInventory; +use pocketmine\inventory\EnchantInventory; use pocketmine\inventory\transaction\action\CreateItemAction; use pocketmine\inventory\transaction\action\DestroyItemAction; use pocketmine\inventory\transaction\action\DropItemAction; @@ -202,6 +204,20 @@ class NetworkInventoryAction{ case self::SOURCE_TYPE_CRAFTING_RESULT: case self::SOURCE_TYPE_CRAFTING_USE_INGREDIENT: return null; + case self::SOURCE_TYPE_ANVIL_INPUT: + case self::SOURCE_TYPE_ANVIL_MATERIAL: + $window = $player->getCurrentWindow(); + if(!($window instanceof AnvilInventory)){ + throw new \UnexpectedValueException("Current open container is not an anvil"); + } + return new SlotChangeAction($window, $this->inventorySlot, $this->oldItem, $this->newItem); + case self::SOURCE_TYPE_ENCHANT_INPUT: + case self::SOURCE_TYPE_ENCHANT_MATERIAL: + $window = $player->getCurrentWindow(); + if(!($window instanceof EnchantInventory)){ + throw new \UnexpectedValueException("Current open container is not an enchanting table"); + } + return new SlotChangeAction($window, $this->inventorySlot, $this->oldItem, $this->newItem); } //TODO: more stuff