I'm looking for an event which is called when a chest is opened. I tried PHP: public function onOpenChest(DataPacketSendEvent $event){ if($event->getPacket() instanceof ContainerOpenPacket){ $this->getLogger()->info("Open"); } } but the server also said "Open" when a double chest is opened. Would you tell me how to check if it is a (single)chest's packet?
I used PHP: public function onPlayerInteract(PlayerInteractEvent $event){ if ($event->getBlock()->getID() == 54){ //if chest This detects when a chest is used, single or double. I'm sure you could make it apply to single only though by telling if the nearby block is a chest or not.
and you should specify what type of inventory you want use this $event->getInventory()->getNetworktype(); and that well return a number chest =0 Double chest = 1 player = 2 furnace = 3 crafting = 4 workbench = 5 stonecutter = 6 and for closing the inventory use InventoryCloseEvent and the same thing as InventoryOpenEvent
use this $event->getInventory()->getNetworktype(); and that well return a number chest =0 Double chest = 1 player = 2 furnace = 3 crafting = 4 workbench = 5 stonecutter = 6
Wrong. Network type ID should be referred to at https://github.com/PocketMine/Pocke...rc/pocketmine/inventory/InventoryType.php#L56
Network ID should be referred to as the third parameter in the constructor actually. The IDs you gave are purely the offsets of the inventory type, but it is internal and PocketMine never sends internal things into packets.
Thank you for replying. I'm making the ender chest so what i want to do is to catch the inventory packet and to rewrite the packet. Sorry,poor English