13declare(strict_types=1);
15namespace pocketmine\network\mcpe\protocol\types\inventory;
21use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait;
24 use GetTypeIdFromConstTrait;
26 public const ID = InventoryTransactionPacket::TYPE_USE_ITEM;
28 public const ACTION_CLICK_BLOCK = 0;
29 public const ACTION_CLICK_AIR = 1;
30 public const ACTION_BREAK_BLOCK = 2;
32 private int $actionType;
33 private TriggerType $triggerType;
36 private int $hotbarSlot;
38 private Vector3 $playerPosition;
40 private int $blockRuntimeId;
41 private PredictedResult $clientInteractPrediction;
43 public function getActionType() :
int{
44 return $this->actionType;
47 public function getTriggerType() : TriggerType{
return $this->triggerType; }
50 return $this->blockPosition;
53 public function getFace() :
int{
57 public function getHotbarSlot() :
int{
58 return $this->hotbarSlot;
62 return $this->itemInHand;
65 public function getPlayerPosition() :
Vector3{
66 return $this->playerPosition;
69 public function getClickPosition() :
Vector3{
70 return $this->clickPosition;
73 public function getBlockRuntimeId() :
int{
74 return $this->blockRuntimeId;
77 public function getClientInteractPrediction() : PredictedResult{
return $this->clientInteractPrediction; }
80 $this->actionType = $stream->getUnsignedVarInt();
85 $this->itemInHand = $stream->getItemStackWrapper();
89 $this->clientInteractPrediction = PredictedResult::fromPacket($stream->
getUnsignedVarInt());
93 $stream->putUnsignedVarInt($this->actionType);
98 $stream->putItemStackWrapper($this->itemInHand);
108 public static function new(array $actions,
int $actionType, TriggerType $triggerType,
BlockPosition $blockPosition,
int $face,
int $hotbarSlot,
ItemStackWrapper $itemInHand,
Vector3 $playerPosition,
Vector3 $clickPosition,
int $blockRuntimeId, PredictedResult $clientInteractPrediction) :
self{
110 $result->actions = $actions;
111 $result->actionType = $actionType;
112 $result->triggerType = $triggerType;
113 $result->blockPosition = $blockPosition;
114 $result->face = $face;
115 $result->hotbarSlot = $hotbarSlot;
116 $result->itemInHand = $itemInHand;
117 $result->playerPosition = $playerPosition;
118 $result->clickPosition = $clickPosition;
119 $result->blockRuntimeId = $blockRuntimeId;
120 $result->clientInteractPrediction = $clientInteractPrediction;
putVector3(Vector3 $vector)
putBlockPosition(BlockPosition $blockPosition)
decodeData(PacketSerializer $stream)
putUnsignedVarInt(int $v)