129 private const MAX_FORM_RESPONSE_DEPTH = 2;
131 protected float $lastRightClickTime = 0.0;
134 protected ?
Vector3 $lastPlayerAuthInputPosition =
null;
135 protected ?
float $lastPlayerAuthInputYaw =
null;
136 protected ?
float $lastPlayerAuthInputPitch =
null;
137 protected ?
BitSet $lastPlayerAuthInputFlags =
null;
141 public bool $forceMoveSync =
false;
143 protected ?
string $lastRequestedFullSkinId =
null;
145 public function __construct(
151 public function handleText(
TextPacket $packet) :
bool{
152 if($packet->type === TextPacket::TYPE_CHAT){
153 return $this->player->chat($packet->message);
165 private function resolveOnOffInputFlags(
BitSet $inputFlags,
int $startFlag,
int $stopFlag) : ?
bool{
166 $enabled = $inputFlags->get($startFlag);
167 $disabled = $inputFlags->get($stopFlag);
168 if($enabled !== $disabled){
176 $rawPos = $packet->getPosition();
177 $rawYaw = $packet->getYaw();
178 $rawPitch = $packet->getPitch();
179 foreach([$rawPos->x, $rawPos->y, $rawPos->z, $rawYaw, $packet->getHeadYaw(), $rawPitch] as $float){
180 if(is_infinite($float) || is_nan($float)){
181 $this->session->getLogger()->debug(
"Invalid movement received, contains NAN/INF components");
186 if($rawYaw !== $this->lastPlayerAuthInputYaw || $rawPitch !== $this->lastPlayerAuthInputPitch){
187 $this->lastPlayerAuthInputYaw = $rawYaw;
188 $this->lastPlayerAuthInputPitch = $rawPitch;
190 $yaw = fmod($rawYaw, 360);
191 $pitch = fmod($rawPitch, 360);
196 $this->player->setRotation($yaw, $pitch);
199 $hasMoved = $this->lastPlayerAuthInputPosition ===
null || !$this->lastPlayerAuthInputPosition->equals($rawPos);
200 $newPos = $rawPos->subtract(0, 1.62, 0)->round(4);
202 if($this->forceMoveSync && $hasMoved){
203 $curPos = $this->player->getLocation();
205 if($newPos->distanceSquared($curPos) > 1){
206 $this->session->getLogger()->debug(
"Got outdated pre-teleport movement, received " . $newPos .
", expected " . $curPos);
212 $this->forceMoveSync =
false;
215 $inputFlags = $packet->getInputFlags();
216 if($this->lastPlayerAuthInputFlags ===
null || !$inputFlags->equals($this->lastPlayerAuthInputFlags)){
217 $this->lastPlayerAuthInputFlags = $inputFlags;
220 if($this->player->isSneaking() === $sneaking){
223 $sprinting = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SPRINTING, PlayerAuthInputFlags::STOP_SPRINTING);
224 $swimming = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SWIMMING, PlayerAuthInputFlags::STOP_SWIMMING);
225 $gliding = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_GLIDING, PlayerAuthInputFlags::STOP_GLIDING);
226 $flying = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_FLYING, PlayerAuthInputFlags::STOP_FLYING);
228 ($sneaking !==
null && !$this->player->toggleSneak($sneaking)) |
229 ($sprinting !==
null && !$this->player->toggleSprint($sprinting)) |
230 ($swimming !==
null && !$this->player->toggleSwim($swimming)) |
231 ($gliding !==
null && !$this->player->toggleGlide($gliding)) |
232 ($flying !==
null && !$this->player->toggleFlight($flying));
233 if((
bool) $mismatch){
234 $this->player->sendData([$this->player]);
238 $this->player->jump();
241 $this->player->missSwing();
245 if(!$this->forceMoveSync && $hasMoved){
246 $this->lastPlayerAuthInputPosition = $rawPos;
248 $this->player->handleMovement($newPos);
251 $packetHandled =
true;
253 $useItemTransaction = $packet->getItemInteractionData();
254 if($useItemTransaction !==
null){
255 if(count($useItemTransaction->getTransactionData()->getActions()) > 100){
259 $this->inventoryManager->setCurrentItemStackRequestId($useItemTransaction->getRequestId());
260 $this->inventoryManager->addRawPredictedSlotChanges($useItemTransaction->getTransactionData()->getActions());
261 if(!$this->handleUseItemTransaction($useItemTransaction->getTransactionData())){
262 $packetHandled =
false;
263 $this->session->getLogger()->debug(
"Unhandled transaction in PlayerAuthInputPacket (type " . $useItemTransaction->getTransactionData()->getActionType() .
")");
265 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
267 $this->inventoryManager->setCurrentItemStackRequestId(
null);
270 $itemStackRequest = $packet->getItemStackRequest();
271 $itemStackResponseBuilder = $itemStackRequest !==
null ? $this->handleSingleItemStackRequest($itemStackRequest) :
null;
275 $blockActions = $packet->getBlockActions();
276 if($blockActions !==
null){
277 if(count($blockActions) > 100){
280 foreach(Utils::promoteKeys($blockActions) as $k => $blockAction){
281 $actionHandled =
false;
283 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(),
new BlockPosition(0, 0, 0), 0);
285 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), $blockAction->getBlockPosition(), $blockAction->getFace());
289 $packetHandled =
false;
290 $this->session->getLogger()->debug(
"Unhandled player block action at offset $k in PlayerAuthInputPacket");
295 if($itemStackRequest !==
null){
296 $itemStackResponse = $itemStackResponseBuilder?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $itemStackRequest->getRequestId());
300 return $packetHandled;
304 if($packet->actorRuntimeId !== $this->player->getId()){
306 return $packet->actorRuntimeId === ActorEvent::EATING_ITEM;
309 switch($packet->eventId){
310 case ActorEvent::EATING_ITEM:
311 $item = $this->player->getMainHandItem();
327 if(count($packet->trData->getActions()) > 50){
330 if(count($packet->requestChangedSlots) > 10){
334 $this->inventoryManager->setCurrentItemStackRequestId($packet->requestId);
335 $this->inventoryManager->addRawPredictedSlotChanges($packet->trData->getActions());
338 $result = $this->handleNormalTransaction($packet->trData, $packet->requestId);
340 $this->session->getLogger()->debug(
"Mismatch transaction received");
341 $this->inventoryManager->requestSyncAll();
344 $result = $this->handleUseItemTransaction($packet->trData);
346 $result = $this->handleUseItemOnEntityTransaction($packet->trData);
348 $result = $this->handleReleaseItemTransaction($packet->trData);
351 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
357 foreach($packet->requestChangedSlots as $containerInfo){
358 foreach($containerInfo->getChangedSlotIndexes() as $netSlot){
360 $inventoryAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slot);
361 if($inventoryAndSlot !==
null){
362 $this->inventoryManager->requestSyncSlot($inventoryAndSlot[0], $inventoryAndSlot[1]);
367 $this->inventoryManager->setCurrentItemStackRequestId(
null);
371 private function executeInventoryTransaction(
InventoryTransaction $transaction,
int $requestId) :
bool{
372 $this->player->setUsingItem(
false);
374 $this->inventoryManager->setCurrentItemStackRequestId($requestId);
375 $this->inventoryManager->addTransactionPredictedSlotChanges($transaction);
379 $this->inventoryManager->requestSyncAll();
380 $logger = $this->session->getLogger();
381 $logger->debug(
"Invalid inventory transaction $requestId: " . $e->getMessage());
385 $this->session->getLogger()->debug(
"Inventory transaction $requestId cancelled by a plugin");
389 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
390 $this->inventoryManager->setCurrentItemStackRequestId(
null);
396 private function handleNormalTransaction(
NormalTransactionData $data,
int $itemStackRequestId) :
bool{
403 if($actionCount > 2){
404 if($actionCount > 5){
410 $this->session->getLogger()->debug(
"Ignoring normal inventory transaction with $actionCount actions (drop-item should have exactly 2 actions)");
415 $clientItemStack =
null;
416 $droppedCount =
null;
418 foreach($data->
getActions() as $networkInventoryAction){
419 if($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_WORLD && $networkInventoryAction->inventorySlot === NetworkInventoryAction::ACTION_MAGIC_SLOT_DROP_ITEM){
420 $droppedCount = $networkInventoryAction->newItem->getItemStack()->getCount();
421 if($droppedCount <= 0){
424 }elseif($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_CONTAINER && $networkInventoryAction->windowId === ContainerIds::INVENTORY){
426 $sourceSlot = $networkInventoryAction->inventorySlot;
427 $clientItemStack = $networkInventoryAction->oldItem->getItemStack();
429 $this->session->getLogger()->debug(
"Unexpected inventory action type $networkInventoryAction->sourceType in drop item transaction");
433 if($sourceSlot ===
null || $clientItemStack ===
null || $droppedCount ===
null){
434 $this->session->getLogger()->debug(
"Missing information in drop item transaction, need source slot, client item stack and dropped count");
438 $inventory = $this->player->getInventory();
440 if(!$inventory->slotExists($sourceSlot)){
444 $sourceSlotItem = $inventory->getItem($sourceSlot);
445 if($sourceSlotItem->getCount() < $droppedCount){
448 $serverItemStack = $this->session->getTypeConverter()->coreItemStackToNet($sourceSlotItem);
452 $serverItemStack->getId() !== $clientItemStack->getId() ||
453 $serverItemStack->getMeta() !== $clientItemStack->getMeta() ||
454 $serverItemStack->getCount() !== $clientItemStack->getCount() ||
455 $serverItemStack->getBlockRuntimeId() !== $clientItemStack->getBlockRuntimeId()
465 $droppedItem = $sourceSlotItem->pop($droppedCount);
468 $window = $this->inventoryManager->getInventoryWindow($inventory) ??
throw new AssumptionFailedError(
"This should never happen");
469 $builder->getActionBuilder($window)->setItem($sourceSlot, $sourceSlotItem);
473 return $this->executeInventoryTransaction($transaction, $itemStackRequestId);
477 $this->player->selectHotbarSlot($data->getHotbarSlot());
479 switch($data->getActionType()){
480 case UseItemTransactionData::ACTION_CLICK_BLOCK:
482 $clickPos = $data->getClickPosition();
483 $spamBug = ($this->lastRightClickData !==
null &&
484 microtime(
true) - $this->lastRightClickTime < 0.1 &&
485 $this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 &&
486 $this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) &&
487 $this->lastRightClickData->getClickPosition()->distanceSquared($clickPos) < 0.00001
490 $this->lastRightClickData = $data;
491 $this->lastRightClickTime = microtime(
true);
497 $face = self::deserializeFacing($data->getFace());
499 $blockPos = $data->getBlockPosition();
500 $vBlockPos =
new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
501 $this->player->interactBlock($vBlockPos, $face, $clickPos);
502 if($data->getClientInteractPrediction() === PredictedResult::SUCCESS){
507 $this->syncBlocksNearby($vBlockPos, $face);
510 case UseItemTransactionData::ACTION_CLICK_AIR:
511 if($this->player->isUsingItem()){
512 if(!$this->player->consumeHeldItem()){
513 $hungerAttr = $this->player->getAttributeMap()->get(Attribute::HUNGER) ??
throw new AssumptionFailedError();
514 $hungerAttr->markSynchronized(
false);
518 $this->player->useHeldItem();
528 private static function deserializeFacing(
int $facing) :
Facing{
530 $case = Facing::tryFrom($facing);
540 private function syncBlocksNearby(
Vector3 $blockPos, ?
Facing $face) :
void{
541 if($blockPos->distanceSquared($this->player->getLocation()) < 10000){
544 $sidePos = $blockPos->
getSide($face);
547 array_push($blocks, ...$sidePos->sidesArray());
549 $blocks[] = $blockPos;
551 foreach($this->player->getWorld()->createBlockUpdatePackets($blocks) as $packet){
552 $this->session->sendDataPacket($packet);
558 $target = $this->player->getWorld()->getEntity($data->getActorRuntimeId());
559 if($target ===
null){
563 $this->player->selectHotbarSlot($data->getHotbarSlot());
565 switch($data->getActionType()){
566 case UseItemOnEntityTransactionData::ACTION_INTERACT:
567 $this->player->interactEntity($target, $data->getClickPosition());
569 case UseItemOnEntityTransactionData::ACTION_ATTACK:
570 $this->player->attackEntity($target);
578 $this->player->selectHotbarSlot($data->getHotbarSlot());
580 if($data->getActionType() === ReleaseItemTransactionData::ACTION_RELEASE){
581 $this->player->releaseHeldItem();
604 $transaction = $executor->generateInventoryTransaction();
605 if($transaction !==
null){
606 $result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
612 $this->session->getLogger()->debug(
"ItemStackRequest #" . $request->getRequestId() .
" failed: " . $e->getMessage());
613 $this->session->getLogger()->debug(implode(
"\n", Utils::printableExceptionInfo($e)));
614 $this->inventoryManager->requestSyncAll();
617 return $result ? $executor->getItemStackResponseBuilder() :
null;
622 if(count($packet->getRequests()) > 80){
626 foreach($packet->getRequests() as $request){
627 $responses[] = $this->handleSingleItemStackRequest($request)?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
636 if($packet->windowId === ContainerIds::OFFHAND){
639 if($packet->windowId === ContainerIds::INVENTORY){
640 $this->inventoryManager->onClientSelectHotbarSlot($packet->hotbarSlot);
641 if(!$this->player->selectHotbarSlot($packet->hotbarSlot)){
642 $this->inventoryManager->syncSelectedHotbarSlot();
654 if($packet->action === InteractPacket::ACTION_MOUSEOVER){
662 $target = $this->player->getWorld()->getEntity($packet->targetActorRuntimeId);
663 if($target ===
null){
666 if($packet->action === InteractPacket::ACTION_OPEN_INVENTORY && $target === $this->player){
667 $this->inventoryManager->onClientOpenMainInventory();
674 return $this->player->pickBlock(
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData);
678 return $this->player->pickEntity($packet->actorUniqueId);
682 return $this->handlePlayerActionFromData($packet->action, $packet->blockPosition, $packet->face);
685 private function handlePlayerActionFromData(
int $action,
BlockPosition $blockPosition,
int $extraData) :
bool{
686 $pos =
new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
689 case PlayerAction::START_BREAK:
690 case PlayerAction::CONTINUE_DESTROY_BLOCK:
691 $face = self::deserializeFacing($extraData);
692 if($this->lastBlockAttacked !==
null && $blockPosition->equals($this->lastBlockAttacked)){
697 $this->session->getLogger()->debug(
"Ignoring PlayerAction $action on $pos because we were already destroying this block");
700 if(!$this->player->attackBlock($pos, $face)){
701 $this->syncBlocksNearby($pos, $face);
703 $this->lastBlockAttacked = $blockPosition;
707 case PlayerAction::ABORT_BREAK:
708 case PlayerAction::STOP_BREAK:
709 $this->player->stopBreakBlock($pos);
710 $this->lastBlockAttacked =
null;
712 case PlayerAction::START_SLEEPING:
715 case PlayerAction::STOP_SLEEPING:
716 $this->player->stopSleep();
718 case PlayerAction::CRACK_BREAK:
719 $face = self::deserializeFacing($extraData);
720 $this->player->continueBreakBlock($pos, $face);
721 $this->lastBlockAttacked = $blockPosition;
723 case PlayerAction::INTERACT_BLOCK:
725 case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
728 case PlayerAction::PREDICT_DESTROY_BLOCK:
729 if(!$this->player->breakBlock($pos)){
730 $face = self::deserializeFacing($extraData);
731 $this->syncBlocksNearby($pos, $face);
733 $this->lastBlockAttacked =
null;
735 case PlayerAction::START_ITEM_USE_ON:
736 case PlayerAction::STOP_ITEM_USE_ON:
740 $this->session->getLogger()->debug(
"Unhandled/unknown player action type " . $action);
744 $this->player->setUsingItem(
false);
758 $this->inventoryManager->onClientRemoveWindow($packet->windowId);
770 $textTag = $nbt->
getTag($tagName);
772 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textTag) .
" for tag \"$tagName\" in sign update data");
774 $textBlobTag = $textTag->getTag(Sign::TAG_TEXT_BLOB);
776 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textBlobTag) .
" for tag \"" . Sign::TAG_TEXT_BLOB .
"\" in sign update data");
780 $text = SignText::fromBlob($textBlobTag->getValue());
781 }
catch(\InvalidArgumentException $e){
782 throw PacketHandlingException::wrap($e,
"Invalid sign text update");
785 $oldText = $block->getFaceText($frontFace);
786 if($text->getLines() === $oldText->getLines()){
792 foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
793 $this->session->sendDataPacket($updatePacket);
798 }
catch(\UnexpectedValueException $e){
799 throw PacketHandlingException::wrap($e);
804 $pos =
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
805 if($pos->distanceSquared($this->player->getLocation()) > 10000){
809 $block = $this->player->getLocation()->getWorld()->getBlock($pos);
810 $nbt = $packet->nbt->getRoot();
814 if(!$this->updateSignText($nbt, Sign::TAG_FRONT_TEXT,
true, $block, $pos)){
816 $this->updateSignText($nbt, Sign::TAG_BACK_TEXT,
false, $block, $pos);
826 $gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
827 if($gameMode !== $this->player->getGamemode()){
829 $this->session->syncGameMode($this->player->getGamemode(),
true);
843 $this->player->setViewDistance($packet->radius);
857 if(str_starts_with($packet->command,
'/')){
858 $this->player->chat($packet->command);
869 if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
872 $this->session->getLogger()->debug(
"Refused duplicate skin change request");
875 $this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
877 $this->session->getLogger()->debug(
"Processing skin change request");
879 $skin = $this->session->getTypeConverter()->getSkinAdapter()->fromSkinData($packet->skin);
881 throw PacketHandlingException::wrap($e,
"Invalid skin in PlayerSkinPacket");
883 return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName);
893 private function checkBookText(
string $string,
string $fieldName,
int $softLimit,
int $hardLimit,
bool &$cancel) :
string{
894 if(strlen($string) > $hardLimit){
895 throw new PacketHandlingException(sprintf(
"Book %s must be at most %d bytes, but have %d bytes", $fieldName, $hardLimit, strlen($string)));
898 $result = TextFormat::clean($string,
false);
900 if(strlen($result) > $softLimit * 4 || mb_strlen($result,
'UTF-8') > $softLimit){
902 $this->session->getLogger()->debug(
"Cancelled book edit due to $fieldName exceeded soft limit of $softLimit chars");
909 $inventory = $this->player->getInventory();
910 if(!$inventory->slotExists($packet->inventorySlot)){
914 $oldBook = $inventory->getItem($packet->inventorySlot);
919 $newBook = clone $oldBook;
922 switch($packet->type){
923 case BookEditPacket::TYPE_REPLACE_PAGE:
924 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
925 $newBook->setPageText($packet->pageNumber, $text);
926 $modifiedPages[] = $packet->pageNumber;
928 case BookEditPacket::TYPE_ADD_PAGE:
929 if(!$newBook->pageExists($packet->pageNumber)){
934 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
935 $newBook->insertPage($packet->pageNumber, $text);
936 $modifiedPages[] = $packet->pageNumber;
938 case BookEditPacket::TYPE_DELETE_PAGE:
939 if(!$newBook->pageExists($packet->pageNumber)){
942 $newBook->deletePage($packet->pageNumber);
943 $modifiedPages[] = $packet->pageNumber;
945 case BookEditPacket::TYPE_SWAP_PAGES:
946 if(!$newBook->pageExists($packet->pageNumber) || !$newBook->pageExists($packet->secondaryPageNumber)){
948 $newBook->addPage(max($packet->pageNumber, $packet->secondaryPageNumber));
950 $newBook->swapPages($packet->pageNumber, $packet->secondaryPageNumber);
951 $modifiedPages = [$packet->pageNumber, $packet->secondaryPageNumber];
953 case BookEditPacket::TYPE_SIGN_BOOK:
954 $title = self::checkBookText($packet->title,
"title", 16, Limits::INT16_MAX, $cancel);
956 $author = self::checkBookText($packet->author,
"author", 256, Limits::INT16_MAX, $cancel);
958 $newBook = VanillaItems::WRITTEN_BOOK()
959 ->setPages($oldBook->getPages())
962 ->setGeneration(WrittenBook::GENERATION_ORIGINAL);
969 $action = match($packet->type){
970 BookEditPacket::TYPE_REPLACE_PAGE => PlayerEditBookEvent::ACTION_REPLACE_PAGE,
971 BookEditPacket::TYPE_ADD_PAGE => PlayerEditBookEvent::ACTION_ADD_PAGE,
972 BookEditPacket::TYPE_DELETE_PAGE => PlayerEditBookEvent::ACTION_DELETE_PAGE,
973 BookEditPacket::TYPE_SWAP_PAGES => PlayerEditBookEvent::ACTION_SWAP_PAGES,
974 BookEditPacket::TYPE_SIGN_BOOK => PlayerEditBookEvent::ACTION_SIGN_BOOK,
982 $oldPageCount = count($oldBook->getPages());
983 $newPageCount = count($newBook->getPages());
984 if(($newPageCount > $oldPageCount && $newPageCount > 50)){
985 $this->session->getLogger()->debug(
"Cancelled book edit due to adding too many pages (new page count would be $newPageCount)");
989 $event =
new PlayerEditBookEvent($this->player, $oldBook, $newBook, $action, $modifiedPages);
995 if($event->isCancelled()){
999 $this->player->getInventory()->setItem($packet->inventorySlot, $event->getNewBook());
1005 if($packet->cancelReason !==
null){
1007 return $this->player->onFormSubmit($packet->formId,
null);
1008 }elseif($packet->formData !==
null){
1010 $responseData = json_decode($packet->formData,
true, self::MAX_FORM_RESPONSE_DEPTH, JSON_THROW_ON_ERROR);
1011 }
catch(\JsonException $e){
1012 throw PacketHandlingException::wrap($e,
"Failed to decode form response data");
1014 return $this->player->onFormSubmit($packet->formId, $responseData);
1016 throw new PacketHandlingException(
"Expected either formData or cancelReason to be set in ModalFormResponsePacket");
1029 $pos = $packet->blockPosition;
1030 $chunkX = $pos->getX() >> Chunk::COORD_BIT_SIZE;
1031 $chunkZ = $pos->getZ() >> Chunk::COORD_BIT_SIZE;
1032 $world = $this->player->getWorld();
1033 if(!$world->isChunkLoaded($chunkX, $chunkZ) || $world->isChunkLocked($chunkX, $chunkZ)){
1037 $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ());
1038 if($lectern instanceof
Lectern && $this->player->canInteract($lectern->getPosition(), 15)){
1039 if(!$lectern->onPageTurn($packet->page)){
1040 $this->syncBlocksNearby($lectern->getPosition(),
null);
1062 public function handleEmote(
EmotePacket $packet) :
bool{
1063 $this->player->emote($packet->getEmoteId());