29        private int $requestId,
 
   30        private array $requestChangedSlots,
 
 
   34    public function getRequestId() : int{
 
   35        return $this->requestId;
 
   42        return $this->requestChangedSlots;
 
 
   46        return $this->transactionData;
 
   49    public static function read(ByteBufferReader $in) : self{
 
   50        $requestId = VarInt::readSignedInt($in);
 
   51        $requestChangedSlots = [];
 
   53            $len = VarInt::readUnsignedInt($in);
 
   54            for($i = 0; $i < $len; ++$i){
 
   55                $requestChangedSlots[] = InventoryTransactionChangedSlotsHack::read($in);
 
   58        $transactionData = 
new UseItemTransactionData();
 
   59        $transactionData->decode($in);
 
   60        return new ItemInteractionData($requestId, $requestChangedSlots, $transactionData);
 
   63    public function write(ByteBufferWriter $out) : void{
 
   64        VarInt::writeSignedInt($out, $this->requestId);
 
   65        if($this->requestId !== 0){
 
   66            VarInt::writeUnsignedInt($out, count($this->requestChangedSlots));
 
   67            foreach($this->requestChangedSlots as $changedSlot){
 
   68                $changedSlot->write($out);
 
   71        $this->transactionData->encode($out);