133 int $interactionMode,
139 ?array $blockActions,
141 float $analogMoveVecX,
142 float $analogMoveVecZ,
147 throw new \InvalidArgumentException(
"Input flags must be " . PlayerAuthInputFlags::NUMBER_OF_FLAGS .
" bits long");
150 $inputFlags->set(PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST, $itemStackRequest !==
null);
151 $inputFlags->set(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION, $itemInteractionData !==
null);
152 $inputFlags->set(PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS, $blockActions !==
null);
153 $inputFlags->set(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE, $vehicleInfo !==
null);
155 return self::internalCreate(
169 $itemInteractionData,
268 $this->pitch = LE::readFloat($in);
269 $this->yaw = LE::readFloat($in);
270 $this->position = CommonTypes::getVector3($in);
271 $this->moveVecX = LE::readFloat($in);
272 $this->moveVecZ = LE::readFloat($in);
273 $this->headYaw = LE::readFloat($in);
274 $this->inputFlags = BitSet::read($in, PlayerAuthInputFlags::NUMBER_OF_FLAGS);
275 $this->inputMode = VarInt::readUnsignedInt($in);
276 $this->playMode = VarInt::readUnsignedInt($in);
277 $this->interactionMode = VarInt::readUnsignedInt($in);
278 $this->interactRotation = CommonTypes::getVector2($in);
279 $this->tick = VarInt::readUnsignedLong($in);
280 $this->delta = CommonTypes::getVector3($in);
281 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_ITEM_INTERACTION)){
282 $this->itemInteractionData = ItemInteractionData::read($in);
284 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_ITEM_STACK_REQUEST)){
285 $this->itemStackRequest = ItemStackRequest::read($in);
287 if($this->inputFlags->get(PlayerAuthInputFlags::PERFORM_BLOCK_ACTIONS)){
288 $this->blockActions = [];
289 $max = VarInt::readSignedInt($in);
290 for($i = 0; $i < $max; ++$i){
291 $actionType = VarInt::readSignedInt($in);
292 $this->blockActions[] = match(
true){
293 PlayerBlockActionWithBlockInfo::isValidActionType($actionType) => PlayerBlockActionWithBlockInfo::read($in, $actionType),
294 $actionType === PlayerAction::STOP_BREAK =>
new PlayerBlockActionStopBreak(),
299 if($this->inputFlags->get(PlayerAuthInputFlags::IN_CLIENT_PREDICTED_VEHICLE)){
300 $this->vehicleInfo = PlayerAuthInputVehicleInfo::read($in);
302 $this->analogMoveVecX = LE::readFloat($in);
303 $this->analogMoveVecZ = LE::readFloat($in);
304 $this->cameraOrientation = CommonTypes::getVector3($in);
305 $this->rawMove = CommonTypes::getVector2($in);
309 LE::writeFloat($out, $this->pitch);
310 LE::writeFloat($out, $this->yaw);
311 CommonTypes::putVector3($out, $this->position);
312 LE::writeFloat($out, $this->moveVecX);
313 LE::writeFloat($out, $this->moveVecZ);
314 LE::writeFloat($out, $this->headYaw);
315 $this->inputFlags->write($out);
316 VarInt::writeUnsignedInt($out, $this->inputMode);
317 VarInt::writeUnsignedInt($out, $this->playMode);
318 VarInt::writeUnsignedInt($out, $this->interactionMode);
319 CommonTypes::putVector2($out, $this->interactRotation);
320 VarInt::writeUnsignedLong($out, $this->tick);
321 CommonTypes::putVector3($out, $this->delta);
322 if($this->itemInteractionData !==
null){
323 $this->itemInteractionData->write($out);
325 if($this->itemStackRequest !==
null){
326 $this->itemStackRequest->write($out);
328 if($this->blockActions !==
null){
329 VarInt::writeSignedInt($out, count($this->blockActions));
330 foreach($this->blockActions as $blockAction){
331 VarInt::writeSignedInt($out, $blockAction->getActionType());
332 $blockAction->write($out);
335 if($this->vehicleInfo !==
null){
336 $this->vehicleInfo->write($out);
338 LE::writeFloat($out, $this->analogMoveVecX);
339 LE::writeFloat($out, $this->analogMoveVecZ);
340 CommonTypes::putVector3($out, $this->cameraOrientation);
341 CommonTypes::putVector2($out, $this->rawMove);