26 use GetTypeIdFromConstTrait;
28 public const ID = InventoryTransactionPacket::TYPE_RELEASE_ITEM;
30 public const ACTION_RELEASE = 0;
31 public const ACTION_CONSUME = 1;
33 private int $actionType;
34 private int $hotbarSlot;
38 public function getActionType() :
int{
39 return $this->actionType;
42 public function getHotbarSlot() :
int{
43 return $this->hotbarSlot;
47 return $this->itemInHand;
50 public function getHeadPosition() :
Vector3{
51 return $this->headPosition;
54 protected function decodeData(ByteBufferReader $in) : void{
55 $this->actionType = VarInt::readUnsignedInt($in);
56 $this->hotbarSlot = VarInt::readSignedInt($in);
57 $this->itemInHand = CommonTypes::getItemStackWrapper($in);
58 $this->headPosition = CommonTypes::getVector3($in);
61 protected function encodeData(ByteBufferWriter $out) : void{
62 VarInt::writeUnsignedInt($out, $this->actionType);
63 VarInt::writeSignedInt($out, $this->hotbarSlot);
64 CommonTypes::putItemStackWrapper($out, $this->itemInHand);
65 CommonTypes::putVector3($out, $this->headPosition);
71 public static function new(array $actions,
int $actionType,
int $hotbarSlot,
ItemStackWrapper $itemInHand,
Vector3 $headPosition) : self{
73 $result->actions = $actions;
74 $result->actionType = $actionType;
75 $result->hotbarSlot = $hotbarSlot;
76 $result->itemInHand = $itemInHand;
77 $result->headPosition = $headPosition;