75 $this->sourceType = VarInt::readUnsignedInt($in);
77 switch($this->sourceType){
78 case self::SOURCE_CONTAINER:
79 $this->windowId = VarInt::readSignedInt($in);
81 case self::SOURCE_WORLD:
82 $this->sourceFlags = VarInt::readUnsignedInt($in);
84 case self::SOURCE_CREATIVE:
86 case self::SOURCE_TODO:
87 $this->windowId = VarInt::readSignedInt($in);
93 $this->inventorySlot = VarInt::readUnsignedInt($in);
94 $this->oldItem = CommonTypes::getItemStackWrapper($in);
95 $this->newItem = CommonTypes::getItemStackWrapper($in);
103 public function write(ByteBufferWriter $out) : void{
104 VarInt::writeUnsignedInt($out, $this->sourceType);
106 switch($this->sourceType){
107 case self::SOURCE_CONTAINER:
108 VarInt::writeSignedInt($out, $this->windowId);
110 case self::SOURCE_WORLD:
111 VarInt::writeUnsignedInt($out, $this->sourceFlags);
113 case self::SOURCE_CREATIVE:
115 case self::SOURCE_TODO:
116 VarInt::writeSignedInt($out, $this->windowId);
119 throw new \InvalidArgumentException(
"Unknown inventory action source type $this->sourceType");
122 VarInt::writeUnsignedInt($out, $this->inventorySlot);
123 CommonTypes::putItemStackWrapper($out, $this->oldItem);
124 CommonTypes::putItemStackWrapper($out, $this->newItem);