130 private const MAX_FORM_RESPONSE_DEPTH = 2;
132 protected float $lastRightClickTime = 0.0;
135 protected ?
Vector3 $lastPlayerAuthInputPosition =
null;
136 protected ?
float $lastPlayerAuthInputYaw =
null;
137 protected ?
float $lastPlayerAuthInputPitch =
null;
138 protected ?
BitSet $lastPlayerAuthInputFlags =
null;
142 public bool $forceMoveSync =
false;
144 protected ?
string $lastRequestedFullSkinId =
null;
146 public function __construct(
152 public function handleText(
TextPacket $packet) :
bool{
153 if($packet->type === TextPacket::TYPE_CHAT){
154 return $this->player->chat($packet->message);
166 private function resolveOnOffInputFlags(
BitSet $inputFlags,
int $startFlag,
int $stopFlag) : ?
bool{
167 $enabled = $inputFlags->get($startFlag);
168 $disabled = $inputFlags->get($stopFlag);
169 if($enabled !== $disabled){
177 $rawPos = $packet->getPosition();
178 $rawYaw = $packet->getYaw();
179 $rawPitch = $packet->getPitch();
180 foreach([$rawPos->x, $rawPos->y, $rawPos->z, $rawYaw, $packet->getHeadYaw(), $rawPitch] as $float){
181 if(is_infinite($float) || is_nan($float)){
182 $this->session->getLogger()->debug(
"Invalid movement received, contains NAN/INF components");
187 if($rawYaw !== $this->lastPlayerAuthInputYaw || $rawPitch !== $this->lastPlayerAuthInputPitch){
188 $this->lastPlayerAuthInputYaw = $rawYaw;
189 $this->lastPlayerAuthInputPitch = $rawPitch;
191 $yaw = fmod($rawYaw, 360);
192 $pitch = fmod($rawPitch, 360);
197 $this->player->setRotation($yaw, $pitch);
200 $hasMoved = $this->lastPlayerAuthInputPosition ===
null || !$this->lastPlayerAuthInputPosition->equals($rawPos);
201 $newPos = $rawPos->subtract(0, 1.62, 0)->round(4);
203 if($this->forceMoveSync && $hasMoved){
204 $curPos = $this->player->getLocation();
206 if($newPos->distanceSquared($curPos) > 1){
207 $this->session->getLogger()->debug(
"Got outdated pre-teleport movement, received " . $newPos .
", expected " . $curPos);
213 $this->forceMoveSync =
false;
216 $inputFlags = $packet->getInputFlags();
217 if($this->lastPlayerAuthInputFlags ===
null || !$inputFlags->equals($this->lastPlayerAuthInputFlags)){
218 $this->lastPlayerAuthInputFlags = $inputFlags;
221 if($this->player->isSneaking() === $sneaking){
224 $sprinting = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SPRINTING, PlayerAuthInputFlags::STOP_SPRINTING);
225 $swimming = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SWIMMING, PlayerAuthInputFlags::STOP_SWIMMING);
226 $gliding = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_GLIDING, PlayerAuthInputFlags::STOP_GLIDING);
227 $flying = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_FLYING, PlayerAuthInputFlags::STOP_FLYING);
229 ($sneaking !==
null && !$this->player->toggleSneak($sneaking)) |
230 ($sprinting !==
null && !$this->player->toggleSprint($sprinting)) |
231 ($swimming !==
null && !$this->player->toggleSwim($swimming)) |
232 ($gliding !==
null && !$this->player->toggleGlide($gliding)) |
233 ($flying !==
null && !$this->player->toggleFlight($flying));
234 if((
bool) $mismatch){
235 $this->player->sendData([$this->player]);
239 $this->player->jump();
242 $this->player->missSwing();
246 if(!$this->forceMoveSync && $hasMoved){
247 $this->lastPlayerAuthInputPosition = $rawPos;
249 $this->player->handleMovement($newPos);
252 $packetHandled =
true;
254 $useItemTransaction = $packet->getItemInteractionData();
255 if($useItemTransaction !==
null){
256 if(count($useItemTransaction->getTransactionData()->getActions()) > 100){
260 $this->inventoryManager->setCurrentItemStackRequestId($useItemTransaction->getRequestId());
261 $this->inventoryManager->addRawPredictedSlotChanges($useItemTransaction->getTransactionData()->getActions());
262 if(!$this->handleUseItemTransaction($useItemTransaction->getTransactionData())){
263 $packetHandled =
false;
264 $this->session->getLogger()->debug(
"Unhandled transaction in PlayerAuthInputPacket (type " . $useItemTransaction->getTransactionData()->getActionType() .
")");
266 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
268 $this->inventoryManager->setCurrentItemStackRequestId(
null);
271 $itemStackRequest = $packet->getItemStackRequest();
272 $itemStackResponseBuilder = $itemStackRequest !==
null ? $this->handleSingleItemStackRequest($itemStackRequest) :
null;
276 $blockActions = $packet->getBlockActions();
277 if($blockActions !==
null){
278 if(count($blockActions) > 100){
281 foreach(Utils::promoteKeys($blockActions) as $k => $blockAction){
282 $actionHandled =
false;
284 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(),
new BlockPosition(0, 0, 0), 0);
286 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), $blockAction->getBlockPosition(), $blockAction->getFace());
290 $packetHandled =
false;
291 $this->session->getLogger()->debug(
"Unhandled player block action at offset $k in PlayerAuthInputPacket");
296 if($itemStackRequest !==
null){
297 $itemStackResponse = $itemStackResponseBuilder?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $itemStackRequest->getRequestId());
301 return $packetHandled;
305 if($packet->actorRuntimeId !== $this->player->getId()){
307 return $packet->actorRuntimeId === ActorEvent::EATING_ITEM;
310 switch($packet->eventId){
311 case ActorEvent::EATING_ITEM:
312 $item = $this->player->getMainHandItem();
328 if(count($packet->trData->getActions()) > 50){
331 if(count($packet->requestChangedSlots) > 10){
335 $this->inventoryManager->setCurrentItemStackRequestId($packet->requestId);
336 $this->inventoryManager->addRawPredictedSlotChanges($packet->trData->getActions());
339 $result = $this->handleNormalTransaction($packet->trData, $packet->requestId);
341 $this->session->getLogger()->debug(
"Mismatch transaction received");
342 $this->inventoryManager->requestSyncAll();
345 $result = $this->handleUseItemTransaction($packet->trData);
347 $result = $this->handleUseItemOnEntityTransaction($packet->trData);
349 $result = $this->handleReleaseItemTransaction($packet->trData);
352 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
358 foreach($packet->requestChangedSlots as $containerInfo){
359 foreach($containerInfo->getChangedSlotIndexes() as $netSlot){
361 $inventoryAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slot);
362 if($inventoryAndSlot !==
null){
363 $this->inventoryManager->requestSyncSlot($inventoryAndSlot[0], $inventoryAndSlot[1]);
368 $this->inventoryManager->setCurrentItemStackRequestId(
null);
372 private function executeInventoryTransaction(
InventoryTransaction $transaction,
int $requestId) :
bool{
373 $this->player->setUsingItem(
false);
375 $this->inventoryManager->setCurrentItemStackRequestId($requestId);
376 $this->inventoryManager->addTransactionPredictedSlotChanges($transaction);
380 $this->inventoryManager->requestSyncAll();
381 $logger = $this->session->getLogger();
382 $logger->debug(
"Invalid inventory transaction $requestId: " . $e->getMessage());
386 $this->session->getLogger()->debug(
"Inventory transaction $requestId cancelled by a plugin");
390 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
391 $this->inventoryManager->setCurrentItemStackRequestId(
null);
397 private function handleNormalTransaction(
NormalTransactionData $data,
int $itemStackRequestId) :
bool{
404 if($actionCount > 2){
405 if($actionCount > 5){
411 $this->session->getLogger()->debug(
"Ignoring normal inventory transaction with $actionCount actions (drop-item should have exactly 2 actions)");
416 $clientItemStack =
null;
417 $droppedCount =
null;
419 foreach($data->
getActions() as $networkInventoryAction){
420 if($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_WORLD && $networkInventoryAction->inventorySlot === NetworkInventoryAction::ACTION_MAGIC_SLOT_DROP_ITEM){
421 $droppedCount = $networkInventoryAction->newItem->getItemStack()->getCount();
422 if($droppedCount <= 0){
425 }elseif($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_CONTAINER && $networkInventoryAction->windowId === ContainerIds::INVENTORY){
427 $sourceSlot = $networkInventoryAction->inventorySlot;
428 $clientItemStack = $networkInventoryAction->oldItem->getItemStack();
430 $this->session->getLogger()->debug(
"Unexpected inventory action type $networkInventoryAction->sourceType in drop item transaction");
434 if($sourceSlot ===
null || $clientItemStack ===
null || $droppedCount ===
null){
435 $this->session->getLogger()->debug(
"Missing information in drop item transaction, need source slot, client item stack and dropped count");
439 $inventory = $this->player->getInventory();
441 if(!$inventory->slotExists($sourceSlot)){
445 $sourceSlotItem = $inventory->getItem($sourceSlot);
446 if($sourceSlotItem->getCount() < $droppedCount){
449 $serverItemStack = $this->session->getTypeConverter()->coreItemStackToNet($sourceSlotItem);
453 $serverItemStack->getId() !== $clientItemStack->getId() ||
454 $serverItemStack->getMeta() !== $clientItemStack->getMeta() ||
455 $serverItemStack->getCount() !== $clientItemStack->getCount() ||
456 $serverItemStack->getBlockRuntimeId() !== $clientItemStack->getBlockRuntimeId()
466 $droppedItem = $sourceSlotItem->pop($droppedCount);
469 $window = $this->inventoryManager->getInventoryWindow($inventory) ??
throw new AssumptionFailedError(
"This should never happen");
470 $builder->getActionBuilder($window)->setItem($sourceSlot, $sourceSlotItem);
474 return $this->executeInventoryTransaction($transaction, $itemStackRequestId);
478 $this->player->selectHotbarSlot($data->getHotbarSlot());
480 switch($data->getActionType()){
481 case UseItemTransactionData::ACTION_CLICK_BLOCK:
483 $clickPos = $data->getClickPosition();
484 $spamBug = ($this->lastRightClickData !==
null &&
485 microtime(
true) - $this->lastRightClickTime < 0.1 &&
486 $this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 &&
487 $this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) &&
488 $this->lastRightClickData->getClickPosition()->distanceSquared($clickPos) < 0.00001
491 $this->lastRightClickData = $data;
492 $this->lastRightClickTime = microtime(
true);
498 $face = self::deserializeFacing($data->getFace());
500 $blockPos = $data->getBlockPosition();
501 $vBlockPos =
new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
502 $this->player->interactBlock($vBlockPos, $face, $clickPos);
503 if($data->getClientInteractPrediction() === PredictedResult::SUCCESS){
508 $this->syncBlocksNearby($vBlockPos, $face);
511 case UseItemTransactionData::ACTION_CLICK_AIR:
512 if($this->player->isUsingItem()){
513 if(!$this->player->consumeHeldItem()){
514 $hungerAttr = $this->player->getAttributeMap()->get(Attribute::HUNGER) ??
throw new AssumptionFailedError();
515 $hungerAttr->markSynchronized(
false);
519 $this->player->useHeldItem();
529 private static function deserializeFacing(
int $facing) :
Facing{
531 $case = Facing::tryFrom($facing);
541 private function syncBlocksNearby(
Vector3 $blockPos, ?
Facing $face) :
void{
542 if($blockPos->distanceSquared($this->player->getLocation()) < 10000){
545 $sidePos = $blockPos->
getSide($face);
548 array_push($blocks, ...$sidePos->sidesArray());
550 $blocks[] = $blockPos;
552 foreach($this->player->getWorld()->createBlockUpdatePackets($blocks) as $packet){
553 $this->session->sendDataPacket($packet);
559 $target = $this->player->getWorld()->getEntity($data->getActorRuntimeId());
560 if($target ===
null){
564 $this->player->selectHotbarSlot($data->getHotbarSlot());
566 switch($data->getActionType()){
567 case UseItemOnEntityTransactionData::ACTION_INTERACT:
568 $this->player->interactEntity($target, $data->getClickPosition());
570 case UseItemOnEntityTransactionData::ACTION_ATTACK:
571 $this->player->attackEntity($target);
579 $this->player->selectHotbarSlot($data->getHotbarSlot());
581 if($data->getActionType() === ReleaseItemTransactionData::ACTION_RELEASE){
582 $this->player->releaseHeldItem();
605 $transaction = $executor->generateInventoryTransaction();
606 if($transaction !==
null){
607 $result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
613 $this->session->getLogger()->debug(
"ItemStackRequest #" . $request->getRequestId() .
" failed: " . $e->getMessage());
614 $this->session->getLogger()->debug(implode(
"\n", Utils::printableExceptionInfo($e)));
615 $this->inventoryManager->requestSyncAll();
618 return $result ? $executor->getItemStackResponseBuilder() :
null;
623 if(count($packet->getRequests()) > 80){
627 foreach($packet->getRequests() as $request){
628 $responses[] = $this->handleSingleItemStackRequest($request)?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
637 if($packet->windowId === ContainerIds::OFFHAND){
640 if($packet->windowId === ContainerIds::INVENTORY){
641 $this->inventoryManager->onClientSelectHotbarSlot($packet->hotbarSlot);
642 if(!$this->player->selectHotbarSlot($packet->hotbarSlot)){
643 $this->inventoryManager->syncSelectedHotbarSlot();
655 if($packet->action === InteractPacket::ACTION_MOUSEOVER){
663 $target = $this->player->getWorld()->getEntity($packet->targetActorRuntimeId);
664 if($target ===
null){
667 if($packet->action === InteractPacket::ACTION_OPEN_INVENTORY && $target === $this->player){
668 $this->inventoryManager->onClientOpenMainInventory();
675 return $this->player->pickBlock(
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData);
679 return $this->player->pickEntity($packet->actorUniqueId);
683 return $this->handlePlayerActionFromData($packet->action, $packet->blockPosition, $packet->face);
686 private function handlePlayerActionFromData(
int $action,
BlockPosition $blockPosition,
int $extraData) :
bool{
687 $pos =
new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
690 case PlayerAction::START_BREAK:
691 case PlayerAction::CONTINUE_DESTROY_BLOCK:
692 $face = self::deserializeFacing($extraData);
693 if($this->lastBlockAttacked !==
null && $blockPosition->equals($this->lastBlockAttacked)){
698 $this->session->getLogger()->debug(
"Ignoring PlayerAction $action on $pos because we were already destroying this block");
701 if(!$this->player->attackBlock($pos, $face)){
702 $this->syncBlocksNearby($pos, $face);
704 $this->lastBlockAttacked = $blockPosition;
708 case PlayerAction::ABORT_BREAK:
709 case PlayerAction::STOP_BREAK:
710 $this->player->stopBreakBlock($pos);
711 $this->lastBlockAttacked =
null;
713 case PlayerAction::START_SLEEPING:
716 case PlayerAction::STOP_SLEEPING:
717 $this->player->stopSleep();
719 case PlayerAction::CRACK_BREAK:
720 $face = self::deserializeFacing($extraData);
721 $this->player->continueBreakBlock($pos, $face);
722 $this->lastBlockAttacked = $blockPosition;
724 case PlayerAction::INTERACT_BLOCK:
726 case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
729 case PlayerAction::PREDICT_DESTROY_BLOCK:
730 if(!$this->player->breakBlock($pos)){
731 $face = self::deserializeFacing($extraData);
732 $this->syncBlocksNearby($pos, $face);
734 $this->lastBlockAttacked =
null;
736 case PlayerAction::START_ITEM_USE_ON:
737 case PlayerAction::STOP_ITEM_USE_ON:
741 $this->session->getLogger()->debug(
"Unhandled/unknown player action type " . $action);
745 $this->player->setUsingItem(
false);
761 $this->inventoryManager->onClientRemoveWindow($packet->windowId);
773 $textTag = $nbt->
getTag($tagName);
775 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textTag) .
" for tag \"$tagName\" in sign update data");
777 $textBlobTag = $textTag->getTag(Sign::TAG_TEXT_BLOB);
779 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textBlobTag) .
" for tag \"" . Sign::TAG_TEXT_BLOB .
"\" in sign update data");
783 $text = SignText::fromBlob($textBlobTag->getValue());
784 }
catch(\InvalidArgumentException $e){
785 throw PacketHandlingException::wrap($e,
"Invalid sign text update");
788 $oldText = $block->getFaceText($frontFace);
789 if($text->getLines() === $oldText->getLines()){
795 foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
796 $this->session->sendDataPacket($updatePacket);
801 }
catch(\UnexpectedValueException $e){
802 throw PacketHandlingException::wrap($e);
807 $pos =
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
808 if($pos->distanceSquared($this->player->getLocation()) > 10000){
812 $block = $this->player->getLocation()->getWorld()->getBlock($pos);
813 $nbt = $packet->nbt->getRoot();
817 if(!$this->updateSignText($nbt, Sign::TAG_FRONT_TEXT,
true, $block, $pos)){
819 $this->updateSignText($nbt, Sign::TAG_BACK_TEXT,
false, $block, $pos);
829 $gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
830 if($gameMode !== $this->player->getGamemode()){
832 $this->session->syncGameMode($this->player->getGamemode(),
true);
846 $this->player->setViewDistance($packet->radius);
860 if(str_starts_with($packet->command,
'/')){
861 $this->player->chat($packet->command);
872 if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
875 $this->session->getLogger()->debug(
"Refused duplicate skin change request");
878 $this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
880 $this->session->getLogger()->debug(
"Processing skin change request");
882 $skin = $this->session->getTypeConverter()->getSkinAdapter()->fromSkinData($packet->skin);
884 throw PacketHandlingException::wrap($e,
"Invalid skin in PlayerSkinPacket");
886 return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName);
896 private function checkBookText(
string $string,
string $fieldName,
int $softLimit,
int $hardLimit,
bool &$cancel) :
string{
897 if(strlen($string) > $hardLimit){
898 throw new PacketHandlingException(sprintf(
"Book %s must be at most %d bytes, but have %d bytes", $fieldName, $hardLimit, strlen($string)));
901 $result = TextFormat::clean($string,
false);
903 if(strlen($result) > $softLimit * 4 || mb_strlen($result,
'UTF-8') > $softLimit){
905 $this->session->getLogger()->debug(
"Cancelled book edit due to $fieldName exceeded soft limit of $softLimit chars");
912 $inventory = $this->player->getInventory();
913 if(!$inventory->slotExists($packet->inventorySlot)){
917 $oldBook = $inventory->getItem($packet->inventorySlot);
922 $newBook = clone $oldBook;
925 switch($packet->type){
926 case BookEditPacket::TYPE_REPLACE_PAGE:
927 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
928 $newBook->setPageText($packet->pageNumber, $text);
929 $modifiedPages[] = $packet->pageNumber;
931 case BookEditPacket::TYPE_ADD_PAGE:
932 if(!$newBook->pageExists($packet->pageNumber)){
937 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
938 $newBook->insertPage($packet->pageNumber, $text);
939 $modifiedPages[] = $packet->pageNumber;
941 case BookEditPacket::TYPE_DELETE_PAGE:
942 if(!$newBook->pageExists($packet->pageNumber)){
945 $newBook->deletePage($packet->pageNumber);
946 $modifiedPages[] = $packet->pageNumber;
948 case BookEditPacket::TYPE_SWAP_PAGES:
949 if(!$newBook->pageExists($packet->pageNumber) || !$newBook->pageExists($packet->secondaryPageNumber)){
951 $newBook->addPage(max($packet->pageNumber, $packet->secondaryPageNumber));
953 $newBook->swapPages($packet->pageNumber, $packet->secondaryPageNumber);
954 $modifiedPages = [$packet->pageNumber, $packet->secondaryPageNumber];
956 case BookEditPacket::TYPE_SIGN_BOOK:
957 $title = self::checkBookText($packet->title,
"title", 16, Limits::INT16_MAX, $cancel);
959 $author = self::checkBookText($packet->author,
"author", 256, Limits::INT16_MAX, $cancel);
961 $newBook = VanillaItems::WRITTEN_BOOK()
962 ->setPages($oldBook->getPages())
965 ->setGeneration(WrittenBook::GENERATION_ORIGINAL);
972 $action = match($packet->type){
973 BookEditPacket::TYPE_REPLACE_PAGE => PlayerEditBookEvent::ACTION_REPLACE_PAGE,
974 BookEditPacket::TYPE_ADD_PAGE => PlayerEditBookEvent::ACTION_ADD_PAGE,
975 BookEditPacket::TYPE_DELETE_PAGE => PlayerEditBookEvent::ACTION_DELETE_PAGE,
976 BookEditPacket::TYPE_SWAP_PAGES => PlayerEditBookEvent::ACTION_SWAP_PAGES,
977 BookEditPacket::TYPE_SIGN_BOOK => PlayerEditBookEvent::ACTION_SIGN_BOOK,
985 $oldPageCount = count($oldBook->getPages());
986 $newPageCount = count($newBook->getPages());
987 if(($newPageCount > $oldPageCount && $newPageCount > 50)){
988 $this->session->getLogger()->debug(
"Cancelled book edit due to adding too many pages (new page count would be $newPageCount)");
992 $event =
new PlayerEditBookEvent($this->player, $oldBook, $newBook, $action, $modifiedPages);
998 if($event->isCancelled()){
1002 $this->player->getInventory()->setItem($packet->inventorySlot, $event->getNewBook());
1008 if($packet->cancelReason !==
null){
1010 return $this->player->onFormSubmit($packet->formId,
null);
1011 }elseif($packet->formData !==
null){
1013 $responseData = json_decode($packet->formData,
true, self::MAX_FORM_RESPONSE_DEPTH, JSON_THROW_ON_ERROR);
1014 }
catch(\JsonException $e){
1015 throw PacketHandlingException::wrap($e,
"Failed to decode form response data");
1017 return $this->player->onFormSubmit($packet->formId, $responseData);
1019 throw new PacketHandlingException(
"Expected either formData or cancelReason to be set in ModalFormResponsePacket");
1032 $pos = $packet->blockPosition;
1033 $chunkX = $pos->getX() >> Chunk::COORD_BIT_SIZE;
1034 $chunkZ = $pos->getZ() >> Chunk::COORD_BIT_SIZE;
1035 $world = $this->player->getWorld();
1036 if(!$world->isChunkLoaded($chunkX, $chunkZ) || $world->isChunkLocked($chunkX, $chunkZ)){
1040 $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ());
1041 if($lectern instanceof
Lectern && $this->player->canInteract($lectern->getPosition(), 15)){
1042 if(!$lectern->onPageTurn($packet->page)){
1043 $this->syncBlocksNearby($lectern->getPosition(),
null);
1065 public function handleEmote(
EmotePacket $packet) :
bool{
1066 $this->player->emote($packet->getEmoteId());