34 public const NETWORK_ID = ProtocolInfo::PLAYER_AUTH_INPUT_PACKET;
39 private float $headYaw;
40 private float $moveVecX;
41 private float $moveVecZ;
42 private BitSet $inputFlags;
43 private int $inputMode;
44 private int $playMode;
45 private int $interactionMode;
46 private Vector2 $interactRotation;
52 private ?array $blockActions =
null;
54 private float $analogMoveVecX;
55 private float $analogMoveVecZ;
56 private Vector3 $cameraOrientation;
63 private static function internalCreate(
81 float $analogMoveVecX,
82 float $analogMoveVecZ,
87 $result->position = $position;
88 $result->pitch = $pitch;
90 $result->headYaw = $headYaw;
91 $result->moveVecX = $moveVecX;
92 $result->moveVecZ = $moveVecZ;
93 $result->inputFlags = $inputFlags;
94 $result->inputMode = $inputMode;
95 $result->playMode = $playMode;
96 $result->interactionMode = $interactionMode;
97 $result->interactRotation = $interactRotation;
98 $result->tick = $tick;
99 $result->delta = $delta;
100 $result->itemInteractionData = $itemInteractionData;
101 $result->itemStackRequest = $itemStackRequest;
102 $result->blockActions = $blockActions;
103 $result->vehicleInfo = $vehicleInfo;
104 $result->analogMoveVecX = $analogMoveVecX;
105 $result->analogMoveVecZ = $analogMoveVecZ;
106 $result->cameraOrientation = $cameraOrientation;
107 $result->rawMove = $rawMove;
128 int $interactionMode,
134 ?array $blockActions,
136 float $analogMoveVecX,
137 float $analogMoveVecZ,
141 if($inputFlags->getLength() !== 65){
142 throw new \InvalidArgumentException(
"Input flags must be 65 bits long");
145 $inputFlags->set(PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST, $itemStackRequest !==
null);
146 $inputFlags->set(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION, $itemInteractionData !==
null);
147 $inputFlags->set(PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS, $blockActions !==
null);
148 $inputFlags->set(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE, $vehicleInfo !==
null);
150 return self::internalCreate(
164 $itemInteractionData,
175 public function getPosition() :
Vector3{
176 return $this->position;
179 public function getPitch() : float{
183 public function getYaw() : float{
187 public function getHeadYaw() : float{
188 return $this->headYaw;
191 public function getMoveVecX() : float{
192 return $this->moveVecX;
195 public function getMoveVecZ() : float{
196 return $this->moveVecZ;
203 return $this->inputFlags;
210 return $this->inputMode;
217 return $this->playMode;
224 return $this->interactionMode;
227 public function getInteractRotation() :
Vector2{ return $this->interactRotation; }
229 public function getTick() : int{
233 public function getDelta() : Vector3{
237 public function getItemInteractionData() : ?ItemInteractionData{
238 return $this->itemInteractionData;
241 public function getItemStackRequest() : ?ItemStackRequest{
242 return $this->itemStackRequest;
249 return $this->blockActions;
254 public function getAnalogMoveVecX() : float{ return $this->analogMoveVecX; }
256 public function getAnalogMoveVecZ() : float{ return $this->analogMoveVecZ; }
258 public function getCameraOrientation() : Vector3{ return $this->cameraOrientation; }
260 public function getRawMove() : Vector2{ return $this->rawMove; }
263 $this->pitch = $in->getLFloat();
269 $this->inputFlags = BitSet::read($in, 65);
276 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION)){
277 $this->itemInteractionData = ItemInteractionData::read($in);
279 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST)){
280 $this->itemStackRequest = ItemStackRequest::read($in);
282 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS)){
283 $this->blockActions = [];
285 for($i = 0; $i < $max; ++$i){
287 $this->blockActions[] = match(
true){
288 PlayerBlockActionWithBlockInfo::isValidActionType($actionType) => PlayerBlockActionWithBlockInfo::read($in, $actionType),
289 $actionType === PlayerAction::STOP_BREAK =>
new PlayerBlockActionStopBreak(),
294 if($this->inputFlags->get(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE)){
295 $this->vehicleInfo = PlayerAuthInputVehicleInfo::read($in);
297 $this->analogMoveVecX = $in->
getLFloat();
298 $this->analogMoveVecZ = $in->
getLFloat();
304 $out->putLFloat($this->pitch);
305 $out->putLFloat($this->yaw);
307 $out->putLFloat($this->moveVecX);
308 $out->putLFloat($this->moveVecZ);
309 $out->putLFloat($this->headYaw);
310 $this->inputFlags->write($out);
317 if($this->itemInteractionData !==
null){
318 $this->itemInteractionData->write($out);
320 if($this->itemStackRequest !==
null){
321 $this->itemStackRequest->write($out);
323 if($this->blockActions !==
null){
324 $out->
putVarInt(count($this->blockActions));
325 foreach($this->blockActions as $blockAction){
326 $out->
putVarInt($blockAction->getActionType());
327 $blockAction->write($out);
330 if($this->vehicleInfo !==
null){
331 $this->vehicleInfo->write($out);
333 $out->putLFloat($this->analogMoveVecX);
334 $out->putLFloat($this->analogMoveVecZ);
340 return $handler->handlePlayerAuthInput($this);