From a3571aa597b5d7fdf0de3eb71971b78a23342499 Mon Sep 17 00:00:00 2001 From: AkmalFairuz Date: Tue, 3 Aug 2021 16:49:14 +0700 Subject: [PATCH] Support v1.17.10 --- src/shoghicp/BigBrother/BigBrother.php | 2 +- src/shoghicp/BigBrother/DesktopPlayer.php | 1 + src/shoghicp/BigBrother/network/Packet.php | 6 +- .../BigBrother/network/Translator.php | 243 ++++++++++-------- .../BigBrother/utils/InventoryUtils.php | 29 ++- 5 files changed, 154 insertions(+), 127 deletions(-) diff --git a/src/shoghicp/BigBrother/BigBrother.php b/src/shoghicp/BigBrother/BigBrother.php index 00e8ad9d..983b92d5 100644 --- a/src/shoghicp/BigBrother/BigBrother.php +++ b/src/shoghicp/BigBrother/BigBrother.php @@ -87,7 +87,7 @@ public function onEnable(){ } if($enable){ - if(Info::CURRENT_PROTOCOL === 422){ + if(Info::CURRENT_PROTOCOL === 448){ ConvertUtils::init(); $this->saveDefaultConfig(); diff --git a/src/shoghicp/BigBrother/DesktopPlayer.php b/src/shoghicp/BigBrother/DesktopPlayer.php index 27eca5ce..1a10de29 100644 --- a/src/shoghicp/BigBrother/DesktopPlayer.php +++ b/src/shoghicp/BigBrother/DesktopPlayer.php @@ -577,6 +577,7 @@ public function bigBrother_authenticate(string $uuid, ?array $onlineModeData = n } $skin = new SkinImage($skinImage); + $pk->clientData["PlayFabId"] = ""; $pk->clientData["SkinData"] = $skin->getSkinImageData(true); $skinSize = $this->getSkinImageSize(strlen($skin->getRawSkinImageData(true))); $pk->clientData["SkinImageHeight"] = $skinSize[0]; diff --git a/src/shoghicp/BigBrother/network/Packet.php b/src/shoghicp/BigBrother/network/Packet.php index ba6ccd9e..0bbd2cb2 100644 --- a/src/shoghicp/BigBrother/network/Packet.php +++ b/src/shoghicp/BigBrother/network/Packet.php @@ -30,6 +30,7 @@ namespace shoghicp\BigBrother\network; use pocketmine\item\Item; +use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; use shoghicp\BigBrother\utils\Binary; use shoghicp\BigBrother\utils\ConvertUtils; use shoghicp\BigBrother\utils\ComputerItem; @@ -103,7 +104,10 @@ protected function getSlot() : Item{ } } - protected function putSlot(Item $item) : void{ + protected function putSlot($item) : void{ + if($item instanceof ItemStackWrapper) { + $item = $item->getItemStack(); + } ConvertUtils::convertItemData(true, $item); if($item->getID() === 0){ diff --git a/src/shoghicp/BigBrother/network/Translator.php b/src/shoghicp/BigBrother/network/Translator.php index b804107a..4ba8f30b 100644 --- a/src/shoghicp/BigBrother/network/Translator.php +++ b/src/shoghicp/BigBrother/network/Translator.php @@ -40,6 +40,12 @@ use pocketmine\network\mcpe\protocol\SetActorMotionPacket; use pocketmine\network\mcpe\protocol\TakeItemActorPacket; use pocketmine\network\mcpe\protocol\types\ContainerIds; +use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; +use pocketmine\network\mcpe\protocol\types\inventory\MismatchTransactionData; +use pocketmine\network\mcpe\protocol\types\inventory\NormalTransactionData; +use pocketmine\network\mcpe\protocol\types\inventory\ReleaseItemTransactionData; +use pocketmine\network\mcpe\protocol\types\inventory\UseItemOnEntityTransactionData; +use pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData; use pocketmine\network\mcpe\protocol\types\NetworkInventoryAction; use shoghicp\BigBrother\network\protocol\Play\Client\AdvancementTabPacket; use shoghicp\BigBrother\network\protocol\Play\Client\ClientSettingsPacket; @@ -354,18 +360,18 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ if($frame !== null){ switch($packet->type){ case UseEntityPacket::INTERACT: + $clickPos = new Vector3($frame->x, $frame->y, $frame->z); $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK; - $pk->trData->x = $frame->x; - $pk->trData->y = $frame->y; - $pk->trData->z = $frame->z; - $pk->trData->face = $frame->getFacing(); - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = $player->asVector3(); - $pk->trData->clickPos = $frame->asVector3(); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_CLICK_BLOCK, + $clickPos, + $frame->getFacing(), + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $frame->asVector3(), + $player->getLevel()->getBlock($clickPos)->getRuntimeId()); return $pk; case UseEntityPacket::ATTACK: if($frame->hasItem()){ @@ -375,18 +381,18 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk->z = $frame->z; return $pk; }else{ + $clickPos = new Vector3($frame->x, $frame->y, $frame->z); $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK; - $pk->trData->x = $frame->x; - $pk->trData->y = $frame->y; - $pk->trData->z = $frame->z; - $pk->trData->face = $frame->getFacing(); - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = $player->asVector3(); - $pk->trData->clickPos = $frame->asVector3(); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_BREAK_BLOCK, + $clickPos, + $frame->getFacing(), + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $frame->asVector3(), + $player->getLevel()->getBlock($clickPos)->getRuntimeId()); return $pk; } } @@ -401,29 +407,29 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk->y = 0; $pk->z = 0; }else{ - $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY; - $pk->trData = new stdClass(); - $pk->trData->entityRuntimeId = $packet->target; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->vector1 = new Vector3(0, 0, 0); - $pk->trData->vector2 = new Vector3(0, 0, 0); - switch($packet->type){ case UseEntityPacket::INTERACT: - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_INTERACT; - break; + $actionType = UseItemOnEntityTransactionData::ACTION_INTERACT; + break; case UseEntityPacket::ATTACK: - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_ATTACK; - break; + $actionType = UseItemOnEntityTransactionData::ACTION_ATTACK; + break; default: echo "[Translator] UseItemPacket\n"; return null; } + $pk = new InventoryTransactionPacket(); + $pk->trData = UseItemOnEntityTransactionData::new( + [], + $packet->target, + $actionType, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + new Vector3(0, 0, 0) + ); } - return $pk; case InboundPacket::KEEP_ALIVE_PACKET: @@ -551,19 +557,19 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ switch($packet->status){ case 0: if($player->getGamemode() === 1){ + $clickPos = new Vector3($packet->x, $packet->y, $packet->z); $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK; - $pk->trData->x = $packet->x; - $pk->trData->y = $packet->y; - $pk->trData->z = $packet->z; - $pk->trData->face = $packet->face; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = new Vector3($player->getX(), $player->getY(), $player->getZ()); - $pk->trData->clickPos = new Vector3($packet->x, $packet->y, $packet->z); - + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_BREAK_BLOCK, + $clickPos, + $packet->face, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $clickPos, + $player->getLevel()->getBlock($clickPos)->getRuntimeId() + ); return $pk; }else{ $player->bigBrother_setBreakPosition([new Vector3($packet->x, $packet->y, $packet->z), $packet->face]); @@ -590,18 +596,19 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk->face = $packet->face; $packets[] = $pk; + $clickPos = new Vector3($packet->x, $packet->y, $packet->z); $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK; - $pk->trData->x = $packet->x; - $pk->trData->y = $packet->y; - $pk->trData->z = $packet->z; - $pk->trData->face = $packet->face; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = new Vector3($player->getX(), $player->getY(), $player->getZ()); - $pk->trData->clickPos = new Vector3($packet->x, $packet->y, $packet->z); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_BREAK_BLOCK, + $clickPos, + $packet->face, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $clickPos, + $block->getRuntimeId() + ); $packets[] = $pk; @@ -644,18 +651,19 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk->face = $packet->face; $packets[] = $pk; + $clickPos = new Vector3($packet->x, $packet->y, $packet->z); $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_BREAK_BLOCK; - $pk->trData->x = $packet->x; - $pk->trData->y = $packet->y; - $pk->trData->z = $packet->z; - $pk->trData->face = $packet->face; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = new Vector3($player->getX(), $player->getY(), $player->getZ()); - $pk->trData->clickPos = new Vector3($packet->x, $packet->y, $packet->z); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_BREAK_BLOCK, + $clickPos, + $packet->face, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $clickPos, + $player->getLevel()->getBlock($clickPos)->getRuntimeId() + ); $packets[] = $pk; $pk = new PlayerActionPacket(); @@ -690,26 +698,27 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $action->sourceType = NetworkInventoryAction::SOURCE_WORLD; $action->sourceFlags = 0; $action->inventorySlot = 0; - $action->oldItem = Item::get(Item::AIR, 0, 0); - $action->newItem = $dropItem; + $action->oldItem = ItemStackWrapper::legacy(Item::get(Item::AIR, 0, 0)); + $action->newItem = ItemStackWrapper::legacy($dropItem); $actions[] = $action; $action = new NetworkInventoryAction(); $action->sourceType = NetworkInventoryAction::SOURCE_CONTAINER; $action->windowId = ContainerIds::INVENTORY; $action->inventorySlot = $player->getInventory()->getHeldItemIndex(); - $action->oldItem = $oldItem; - $action->newItem = $newItem; + $action->oldItem = ItemStackWrapper::legacy($oldItem); + $action->newItem = ItemStackWrapper::legacy($newItem); $actions[] = $action; $packets = []; $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_NORMAL; - $pk->actions = $actions; + $pk->trData = NormalTransactionData::new( + $actions + ); $packets[] = $pk; $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_MISMATCH;//inventory refresh. + $pk->trData = MismatchTransactionData::new(); $packets[] = $pk; return $packets; @@ -717,19 +726,23 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ return null; case 5: - $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_RELEASE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $item = $player->getInventory()->getItemInHand(); - $pk->trData->headPos = new Vector3($packet->x, $packet->y, $packet->z); - + $headPos = new Vector3($packet->x, $packet->y, $packet->z); + $item = $player->getInventory()->getItemInHand(); if($item->getId() === Item::BOW){//Shoot Arrow - $pk->trData->actionType = InventoryTransactionPacket::RELEASE_ITEM_ACTION_RELEASE; + $actionType = ReleaseItemTransactionData::ACTION_RELEASE; }else{//Eating - $pk->trData->actionType = InventoryTransactionPacket::RELEASE_ITEM_ACTION_CONSUME; + $actionType = ReleaseItemTransactionData::ACTION_CONSUME; } + $pk = new InventoryTransactionPacket(); + $pk->trData = ReleaseItemTransactionData::new( + [], + $actionType, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($item), + $headPos + ); + return $pk; default: echo "PlayerDiggingPacket: ".$packet->status."\n"; @@ -790,7 +803,7 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ /** @var HeldItemChangePacket $packet */ $pk = new MobEquipmentPacket(); $pk->entityRuntimeId = $player->getId(); - $pk->item = $player->getInventory()->getHotbarSlotItem($packet->selectedSlot); + $pk->item = ItemStackWrapper::legacy($player->getInventory()->getHotbarSlotItem($packet->selectedSlot)); $pk->inventorySlot = $packet->selectedSlot; $pk->hotbarSlot = $packet->selectedSlot; @@ -837,7 +850,7 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk = new PlayerActionPacket(); $pk->entityRuntimeId = $player->getId(); - $pk->action = PlayerActionPacket::ACTION_CONTINUE_BREAK; + $pk->action = PlayerActionPacket::ACTION_CONTINUE_DESTROY_BLOCK; $pk->x = $pos[0]->x; $pk->y = $pos[0]->y; $pk->z = $pos[0]->z; @@ -862,23 +875,22 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ $pk->blockId = Block::AIR; $pk->blockMeta = 0; $player->putRawPacket($pk); - return null; } - $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_BLOCK; - $pk->trData->x = $packet->x; - $pk->trData->y = $packet->y; - $pk->trData->z = $packet->z; - $pk->trData->face = $packet->direction; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = new Vector3($player->getX(), $player->getY(), $player->getZ()); - $pk->trData->clickPos = new Vector3($packet->x, $packet->y, $packet->z); + $clickPos = new Vector3($packet->x, $packet->y, $packet->z); + $pk = new InventoryTransactionPacket(); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_CLICK_BLOCK, + $clickPos, + $packet->direction, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $clickPos, + $player->getLevel()->getBlock($clickPos)->getRuntimeId()); return $pk; case InboundPacket::USE_ITEM_PACKET: @@ -891,19 +903,20 @@ public function interfaceToServer(DesktopPlayer $player, Packet $packet){ return null; } - $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_USE_ITEM; - $pk->trData = new stdClass(); - $pk->trData->actionType = InventoryTransactionPacket::USE_ITEM_ACTION_CLICK_AIR; - $pk->trData->x = 0; - $pk->trData->y = 0; - $pk->trData->z = 0; - $pk->trData->face = -1; - $pk->trData->hotbarSlot = $player->getInventory()->getHeldItemIndex(); - $pk->trData->itemInHand = $player->getInventory()->getItemInHand(); - $pk->trData->playerPos = new Vector3($player->getX(), $player->getY(), $player->getZ()); - $pk->trData->clickPos = new Vector3(0, 0, 0); + $clickPos = new Vector3(0, 0, 0); + $pk = new InventoryTransactionPacket(); + $pk->trData = UseItemTransactionData::new( + [], + UseItemTransactionData::ACTION_CLICK_AIR, + $clickPos, + -1, + $player->getInventory()->getHeldItemIndex(), + ItemStackWrapper::legacy($player->getInventory()->getItemInHand()), + $player->asVector3(), + $clickPos, + $player->getLevel()->getBlock($clickPos)->getRuntimeId() + ); return $pk; default: @@ -1436,7 +1449,7 @@ public function serverToInterface(DesktopPlayer $player, DataPacket $packet){ case Info::ADD_ITEM_ACTOR_PACKET: /** @var AddItemActorPacket $packet */ - $item = clone $packet->item; + $item = clone $packet->item->getItemStack(); ConvertUtils::convertItemData(true, $item); $metadata = ConvertUtils::convertPEToPCMetadata($packet->metadata); $metadata[6] = [5, $item]; @@ -1719,6 +1732,8 @@ public function serverToInterface(DesktopPlayer $player, DataPacket $packet){ $id = 0; switch($packet->evid){ + case LevelEventPacket::EVENT_PARTICLE_DESTROY; + return null; case LevelEventPacket::EVENT_SOUND_IGNITE: $isSoundEffect = true; $name = "entity.tnt.primed"; diff --git a/src/shoghicp/BigBrother/utils/InventoryUtils.php b/src/shoghicp/BigBrother/utils/InventoryUtils.php index 45f14cfd..dcb753d4 100644 --- a/src/shoghicp/BigBrother/utils/InventoryUtils.php +++ b/src/shoghicp/BigBrother/utils/InventoryUtils.php @@ -30,6 +30,8 @@ namespace shoghicp\BigBrother\utils; use InvalidArgumentException; +use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; +use pocketmine\network\mcpe\protocol\types\inventory\NormalTransactionData; use const pocketmine\DEBUG; use pocketmine\inventory\ShapedRecipe; use pocketmine\inventory\ShapelessRecipe; @@ -843,7 +845,7 @@ public function onWindowClick(ClickWindowPacket $packet) : ?InventoryTransaction $pk = null; if($accepted){ $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_NORMAL; + $actions = []; if($isContainer){ $ref = &$this->getItemAndSlot($packet->windowID, $packet->slot, $windowId, $saveInventorySlot); @@ -854,17 +856,20 @@ public function onWindowClick(ClickWindowPacket $packet) : ?InventoryTransaction } $action = $this->addNetworkInventoryAction(NetworkInventoryAction::SOURCE_CONTAINER, $windowId, $saveInventorySlot, $oldItem, $item); - $pk->actions[] = $action; + $actions[] = $action; } foreach($otherAction as $action){ - $pk->actions[] = $action; + $actions[] = $action; } if(!$heldItem->equalsExact($this->playerHeldItem)){ $action = $this->addNetworkInventoryAction(NetworkInventoryAction::SOURCE_CONTAINER, ContainerIds::UI, 0, $heldItem, $this->playerHeldItem); - $pk->actions[] = $action; + $actions[] = $action; } + $pk->trData = NormalTransactionData::new( + $actions + ); } $accepted_pk = new ConfirmTransactionPacket(); @@ -947,24 +952,26 @@ public function onCreativeInventoryAction(CreativeInventoryActionPacket $packet) $this->playerInventorySlot[$inventorySlot] = $newItem; } + $this->player->getInventory()->setItem($inventorySlot, $newItem); + $action = $this->addNetworkInventoryAction(NetworkInventoryAction::SOURCE_CONTAINER, ContainerIds::INVENTORY, $saveInventorySlot, $oldItem, $newItem); } $pk = new InventoryTransactionPacket(); - $pk->transactionType = InventoryTransactionPacket::TYPE_NORMAL; - $pk->actions[] = $action; + $actions = []; if(!$oldItem->isNull() and !$oldItem->equalsExact($newItem)){ $action = $this->addNetworkInventoryAction(NetworkInventoryAction::SOURCE_CREATIVE, -1, NetworkInventoryAction::ACTION_MAGIC_SLOT_CREATIVE_DELETE_ITEM, Item::get(Item::AIR, 0, 0), $oldItem); - $pk->actions[] = $action; + $actions[] = $action; } if(!$newItem->isNull() and !$oldItem->equalsExact($newItem)){ $action = $this->addNetworkInventoryAction(NetworkInventoryAction::SOURCE_CREATIVE, -1, NetworkInventoryAction::ACTION_MAGIC_SLOT_CREATIVE_CREATE_ITEM, $newItem, Item::get(Item::AIR, 0, 0)); - $pk->actions[] = $action; + $actions[] = $action; } + $pk->trData = NormalTransactionData::new($actions); $this->checkInventoryTransactionPacket($pk); @@ -1114,8 +1121,8 @@ public function addNetworkInventoryAction(int $sourceType, int $windowId, int $i $action->sourceType = $sourceType; $action->windowId = $windowId; $action->inventorySlot = $inventorySlot; - $action->oldItem = $oldItem; - $action->newItem = $newItem; + $action->oldItem = ItemStackWrapper::legacy($oldItem); + $action->newItem = ItemStackWrapper::legacy($newItem); return $action; } @@ -1128,7 +1135,7 @@ public function addNetworkInventoryAction(int $sourceType, int $windowId, int $i public function checkInventoryTransactionPacket(InventoryTransactionPacket $packet) : bool{ $errors = 0; $actions = []; - foreach($packet->actions as $actionNumber => $networkInventoryAction){ + foreach($packet->trData->getActions() as $actionNumber => $networkInventoryAction){ $action = $networkInventoryAction->createInventoryAction($this->player); if($action === null){