33 public const NETWORK_ID = ProtocolInfo::PLAYER_AUTH_INPUT_PACKET;
38 private float $headYaw;
39 private float $moveVecX;
40 private float $moveVecZ;
41 private int $inputFlags;
42 private int $inputMode;
43 private int $playMode;
44 private int $interactionMode;
45 private Vector2 $interactRotation;
51 private ?array $blockActions =
null;
53 private float $analogMoveVecX;
54 private float $analogMoveVecZ;
55 private Vector3 $cameraOrientation;
61 private static function internalCreate(
79 float $analogMoveVecX,
80 float $analogMoveVecZ,
84 $result->position = $position;
85 $result->pitch = $pitch;
87 $result->headYaw = $headYaw;
88 $result->moveVecX = $moveVecX;
89 $result->moveVecZ = $moveVecZ;
90 $result->inputFlags = $inputFlags;
91 $result->inputMode = $inputMode;
92 $result->playMode = $playMode;
93 $result->interactionMode = $interactionMode;
94 $result->interactRotation = $interactRotation;
95 $result->tick = $tick;
96 $result->delta = $delta;
97 $result->itemInteractionData = $itemInteractionData;
98 $result->itemStackRequest = $itemStackRequest;
99 $result->blockActions = $blockActions;
100 $result->vehicleInfo = $vehicleInfo;
101 $result->analogMoveVecX = $analogMoveVecX;
102 $result->analogMoveVecZ = $analogMoveVecZ;
103 $result->cameraOrientation = $cameraOrientation;
124 int $interactionMode,
130 ?array $blockActions,
132 float $analogMoveVecX,
133 float $analogMoveVecZ,
137 if($itemStackRequest !==
null){
138 $realInputFlags |= 1 << PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST;
140 if($itemInteractionData !==
null){
141 $realInputFlags |= 1 << PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION;
143 if($blockActions !==
null){
144 $realInputFlags |= 1 << PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS;
146 if($vehicleInfo !==
null){
147 $realInputFlags |= 1 << PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE;
150 return self::internalCreate(
164 $itemInteractionData,
174 public function getPosition() : Vector3{
175 return $this->position;
178 public function getPitch() : float{
182 public function getYaw() : float{
186 public function getHeadYaw() : float{
187 return $this->headYaw;
190 public function getMoveVecX() : float{
191 return $this->moveVecX;
194 public function getMoveVecZ() : float{
195 return $this->moveVecZ;
202 return $this->inputFlags;
209 return $this->inputMode;
216 return $this->playMode;
223 return $this->interactionMode;
226 public function getInteractRotation() :
Vector2{ return $this->interactRotation; }
228 public function getTick() : int{
232 public function getDelta() : Vector3{
236 public function getItemInteractionData() : ?ItemInteractionData{
237 return $this->itemInteractionData;
240 public function getItemStackRequest() : ?ItemStackRequest{
241 return $this->itemStackRequest;
248 return $this->blockActions;
253 public function getAnalogMoveVecX() : float{ return $this->analogMoveVecX; }
255 public function getAnalogMoveVecZ() : float{ return $this->analogMoveVecZ; }
257 public function getCameraOrientation() : Vector3{ return $this->cameraOrientation; }
259 public function hasFlag(
int $flag) : bool{
260 return ($this->inputFlags & (1 << $flag)) !== 0;
264 $this->pitch = $in->getLFloat();
277 if($this->hasFlag(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION)){
278 $this->itemInteractionData = ItemInteractionData::read($in);
280 if($this->hasFlag(PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST)){
281 $this->itemStackRequest = ItemStackRequest::read($in);
283 if($this->hasFlag(PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS)){
284 $this->blockActions = [];
286 for($i = 0; $i < $max; ++$i){
288 $this->blockActions[] = match(
true){
289 PlayerBlockActionWithBlockInfo::isValidActionType($actionType) => PlayerBlockActionWithBlockInfo::read($in, $actionType),
290 $actionType === PlayerAction::STOP_BREAK =>
new PlayerBlockActionStopBreak(),
295 if($this->hasFlag(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE)){
296 $this->vehicleInfo = PlayerAuthInputVehicleInfo::read($in);
298 $this->analogMoveVecX = $in->
getLFloat();
299 $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);
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);
339 return $handler->handlePlayerAuthInput($this);