13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol;
31 public const NETWORK_ID = ProtocolInfo::INVENTORY_TRANSACTION_PACKET;
33 public const TYPE_NORMAL = 0;
34 public const TYPE_MISMATCH = 1;
35 public const TYPE_USE_ITEM = 2;
36 public const TYPE_USE_ITEM_ON_ENTITY = 3;
37 public const TYPE_RELEASE_ITEM = 4;
39 public int $requestId;
41 public array $requestChangedSlots;
50 $result->requestId = $requestId;
51 $result->requestChangedSlots = $requestChangedSlots;
52 $result->trData = $trData;
57 $this->requestId = $in->readLegacyItemStackRequestId();
58 $this->requestChangedSlots = [];
59 if($this->requestId !== 0){
61 $this->requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($in);
67 $this->trData = match($transactionType){
76 $this->trData->decode($in);
80 $out->writeLegacyItemStackRequestId($this->requestId);
81 if($this->requestId !== 0){
83 foreach($this->requestChangedSlots as $changedSlots){
84 $changedSlots->write($out);
90 $this->trData->encode($out);
94 return $handler->handleInventoryTransaction($this);
static create(int $requestId, array $requestChangedSlots, TransactionData $trData)
decodePayload(PacketSerializer $in)
handle(PacketHandlerInterface $handler)
encodePayload(PacketSerializer $out)
putUnsignedVarInt(int $v)