128 private const MAX_FORM_RESPONSE_DEPTH = 2;
130 protected float $lastRightClickTime = 0.0;
133 protected ?
Vector3 $lastPlayerAuthInputPosition =
null;
134 protected ?
float $lastPlayerAuthInputYaw =
null;
135 protected ?
float $lastPlayerAuthInputPitch =
null;
136 protected ?
BitSet $lastPlayerAuthInputFlags =
null;
140 public bool $forceMoveSync =
false;
142 protected ?
string $lastRequestedFullSkinId =
null;
144 public function __construct(
150 public function handleText(
TextPacket $packet) :
bool{
151 if($packet->type === TextPacket::TYPE_CHAT){
152 return $this->player->chat($packet->message);
164 private function resolveOnOffInputFlags(
BitSet $inputFlags,
int $startFlag,
int $stopFlag) : ?
bool{
165 $enabled = $inputFlags->get($startFlag);
166 $disabled = $inputFlags->get($stopFlag);
167 if($enabled !== $disabled){
175 $rawPos = $packet->getPosition();
176 $rawYaw = $packet->getYaw();
177 $rawPitch = $packet->getPitch();
178 foreach([$rawPos->x, $rawPos->y, $rawPos->z, $rawYaw, $packet->getHeadYaw(), $rawPitch] as $float){
179 if(is_infinite($float) || is_nan($float)){
180 $this->session->getLogger()->debug(
"Invalid movement received, contains NAN/INF components");
185 if($rawYaw !== $this->lastPlayerAuthInputYaw || $rawPitch !== $this->lastPlayerAuthInputPitch){
186 $this->lastPlayerAuthInputYaw = $rawYaw;
187 $this->lastPlayerAuthInputPitch = $rawPitch;
189 $yaw = fmod($rawYaw, 360);
190 $pitch = fmod($rawPitch, 360);
195 $this->player->setRotation($yaw, $pitch);
198 $hasMoved = $this->lastPlayerAuthInputPosition ===
null || !$this->lastPlayerAuthInputPosition->equals($rawPos);
199 $newPos = $rawPos->subtract(0, 1.62, 0)->round(4);
201 if($this->forceMoveSync && $hasMoved){
202 $curPos = $this->player->getLocation();
204 if($newPos->distanceSquared($curPos) > 1){
205 $this->session->getLogger()->debug(
"Got outdated pre-teleport movement, received " . $newPos .
", expected " . $curPos);
211 $this->forceMoveSync =
false;
214 $inputFlags = $packet->getInputFlags();
215 if($this->lastPlayerAuthInputFlags ===
null || !$inputFlags->equals($this->lastPlayerAuthInputFlags)){
216 $this->lastPlayerAuthInputFlags = $inputFlags;
219 if($this->player->isSneaking() === $sneaking){
222 $sprinting = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SPRINTING, PlayerAuthInputFlags::STOP_SPRINTING);
223 $swimming = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_SWIMMING, PlayerAuthInputFlags::STOP_SWIMMING);
224 $gliding = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_GLIDING, PlayerAuthInputFlags::STOP_GLIDING);
225 $flying = $this->resolveOnOffInputFlags($inputFlags, PlayerAuthInputFlags::START_FLYING, PlayerAuthInputFlags::STOP_FLYING);
227 ($sneaking !==
null && !$this->player->toggleSneak($sneaking)) |
228 ($sprinting !==
null && !$this->player->toggleSprint($sprinting)) |
229 ($swimming !==
null && !$this->player->toggleSwim($swimming)) |
230 ($gliding !==
null && !$this->player->toggleGlide($gliding)) |
231 ($flying !==
null && !$this->player->toggleFlight($flying));
232 if((
bool) $mismatch){
233 $this->player->sendData([$this->player]);
237 $this->player->jump();
240 $this->player->missSwing();
244 if(!$this->forceMoveSync && $hasMoved){
245 $this->lastPlayerAuthInputPosition = $rawPos;
247 $this->player->handleMovement($newPos);
250 $packetHandled =
true;
252 $useItemTransaction = $packet->getItemInteractionData();
253 if($useItemTransaction !==
null){
254 if(count($useItemTransaction->getTransactionData()->getActions()) > 100){
258 $this->inventoryManager->setCurrentItemStackRequestId($useItemTransaction->getRequestId());
259 $this->inventoryManager->addRawPredictedSlotChanges($useItemTransaction->getTransactionData()->getActions());
260 if(!$this->handleUseItemTransaction($useItemTransaction->getTransactionData())){
261 $packetHandled =
false;
262 $this->session->getLogger()->debug(
"Unhandled transaction in PlayerAuthInputPacket (type " . $useItemTransaction->getTransactionData()->getActionType() .
")");
264 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
266 $this->inventoryManager->setCurrentItemStackRequestId(
null);
269 $itemStackRequest = $packet->getItemStackRequest();
270 $itemStackResponseBuilder = $itemStackRequest !==
null ? $this->handleSingleItemStackRequest($itemStackRequest) :
null;
274 $blockActions = $packet->getBlockActions();
275 if($blockActions !==
null){
276 if(count($blockActions) > 100){
279 foreach(Utils::promoteKeys($blockActions) as $k => $blockAction){
280 $actionHandled =
false;
282 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(),
new BlockPosition(0, 0, 0), 0);
284 $actionHandled = $this->handlePlayerActionFromData($blockAction->getActionType(), $blockAction->getBlockPosition(), $blockAction->getFace());
288 $packetHandled =
false;
289 $this->session->getLogger()->debug(
"Unhandled player block action at offset $k in PlayerAuthInputPacket");
294 if($itemStackRequest !==
null){
295 $itemStackResponse = $itemStackResponseBuilder?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $itemStackRequest->getRequestId());
299 return $packetHandled;
303 if($packet->actorRuntimeId !== $this->player->getId()){
305 return $packet->actorRuntimeId === ActorEvent::EATING_ITEM;
308 switch($packet->eventId){
309 case ActorEvent::EATING_ITEM:
310 $item = $this->player->getMainHandItem();
326 if(count($packet->trData->getActions()) > 50){
329 if(count($packet->requestChangedSlots) > 10){
333 $this->inventoryManager->setCurrentItemStackRequestId($packet->requestId);
334 $this->inventoryManager->addRawPredictedSlotChanges($packet->trData->getActions());
337 $result = $this->handleNormalTransaction($packet->trData, $packet->requestId);
339 $this->session->getLogger()->debug(
"Mismatch transaction received");
340 $this->inventoryManager->requestSyncAll();
343 $result = $this->handleUseItemTransaction($packet->trData);
345 $result = $this->handleUseItemOnEntityTransaction($packet->trData);
347 $result = $this->handleReleaseItemTransaction($packet->trData);
350 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
356 foreach($packet->requestChangedSlots as $containerInfo){
357 foreach($containerInfo->getChangedSlotIndexes() as $netSlot){
359 $inventoryAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slot);
360 if($inventoryAndSlot !==
null){
361 $this->inventoryManager->requestSyncSlot($inventoryAndSlot[0], $inventoryAndSlot[1]);
366 $this->inventoryManager->setCurrentItemStackRequestId(
null);
370 private function executeInventoryTransaction(
InventoryTransaction $transaction,
int $requestId) :
bool{
371 $this->player->setUsingItem(
false);
373 $this->inventoryManager->setCurrentItemStackRequestId($requestId);
374 $this->inventoryManager->addTransactionPredictedSlotChanges($transaction);
378 $this->inventoryManager->requestSyncAll();
379 $logger = $this->session->getLogger();
380 $logger->debug(
"Invalid inventory transaction $requestId: " . $e->getMessage());
384 $this->session->getLogger()->debug(
"Inventory transaction $requestId cancelled by a plugin");
388 $this->inventoryManager->syncMismatchedPredictedSlotChanges();
389 $this->inventoryManager->setCurrentItemStackRequestId(
null);
395 private function handleNormalTransaction(
NormalTransactionData $data,
int $itemStackRequestId) :
bool{
402 if($actionCount > 2){
403 if($actionCount > 5){
409 $this->session->getLogger()->debug(
"Ignoring normal inventory transaction with $actionCount actions (drop-item should have exactly 2 actions)");
414 $clientItemStack =
null;
415 $droppedCount =
null;
417 foreach($data->
getActions() as $networkInventoryAction){
418 if($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_WORLD && $networkInventoryAction->inventorySlot === NetworkInventoryAction::ACTION_MAGIC_SLOT_DROP_ITEM){
419 $droppedCount = $networkInventoryAction->newItem->getItemStack()->getCount();
420 if($droppedCount <= 0){
423 }elseif($networkInventoryAction->sourceType === NetworkInventoryAction::SOURCE_CONTAINER && $networkInventoryAction->windowId === ContainerIds::INVENTORY){
425 $sourceSlot = $networkInventoryAction->inventorySlot;
426 $clientItemStack = $networkInventoryAction->oldItem->getItemStack();
428 $this->session->getLogger()->debug(
"Unexpected inventory action type $networkInventoryAction->sourceType in drop item transaction");
432 if($sourceSlot ===
null || $clientItemStack ===
null || $droppedCount ===
null){
433 $this->session->getLogger()->debug(
"Missing information in drop item transaction, need source slot, client item stack and dropped count");
437 $inventory = $this->player->getInventory();
439 if(!$inventory->slotExists($sourceSlot)){
443 $sourceSlotItem = $inventory->getItem($sourceSlot);
444 if($sourceSlotItem->getCount() < $droppedCount){
447 $serverItemStack = $this->session->getTypeConverter()->coreItemStackToNet($sourceSlotItem);
451 $serverItemStack->getId() !== $clientItemStack->getId() ||
452 $serverItemStack->getMeta() !== $clientItemStack->getMeta() ||
453 $serverItemStack->getCount() !== $clientItemStack->getCount() ||
454 $serverItemStack->getBlockRuntimeId() !== $clientItemStack->getBlockRuntimeId()
464 $droppedItem = $sourceSlotItem->pop($droppedCount);
467 $window = $this->inventoryManager->getInventoryWindow($inventory) ??
throw new AssumptionFailedError(
"This should never happen");
468 $builder->getActionBuilder($window)->setItem($sourceSlot, $sourceSlotItem);
472 return $this->executeInventoryTransaction($transaction, $itemStackRequestId);
476 $this->player->selectHotbarSlot($data->getHotbarSlot());
478 switch($data->getActionType()){
479 case UseItemTransactionData::ACTION_CLICK_BLOCK:
481 $clickPos = $data->getClickPosition();
482 $spamBug = ($this->lastRightClickData !==
null &&
483 microtime(
true) - $this->lastRightClickTime < 0.1 &&
484 $this->lastRightClickData->getPlayerPosition()->distanceSquared($data->getPlayerPosition()) < 0.00001 &&
485 $this->lastRightClickData->getBlockPosition()->equals($data->getBlockPosition()) &&
486 $this->lastRightClickData->getClickPosition()->distanceSquared($clickPos) < 0.00001
489 $this->lastRightClickData = $data;
490 $this->lastRightClickTime = microtime(
true);
496 $face = self::deserializeFacing($data->getFace());
498 $blockPos = $data->getBlockPosition();
499 $vBlockPos =
new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
500 $this->player->interactBlock($vBlockPos, $face, $clickPos);
505 $this->syncBlocksNearby($vBlockPos, $face);
507 case UseItemTransactionData::ACTION_CLICK_AIR:
508 if($this->player->isUsingItem()){
509 if(!$this->player->consumeHeldItem()){
510 $hungerAttr = $this->player->getAttributeMap()->get(Attribute::HUNGER) ??
throw new AssumptionFailedError();
511 $hungerAttr->markSynchronized(
false);
515 $this->player->useHeldItem();
525 private static function deserializeFacing(
int $facing) :
Facing{
527 $case = Facing::tryFrom($facing);
537 private function syncBlocksNearby(
Vector3 $blockPos, ?
Facing $face) :
void{
538 if($blockPos->distanceSquared($this->player->getLocation()) < 10000){
541 $sidePos = $blockPos->
getSide($face);
544 array_push($blocks, ...$sidePos->sidesArray());
546 $blocks[] = $blockPos;
548 foreach($this->player->getWorld()->createBlockUpdatePackets($blocks) as $packet){
549 $this->session->sendDataPacket($packet);
555 $target = $this->player->getWorld()->getEntity($data->getActorRuntimeId());
556 if($target ===
null){
560 $this->player->selectHotbarSlot($data->getHotbarSlot());
562 switch($data->getActionType()){
563 case UseItemOnEntityTransactionData::ACTION_INTERACT:
564 $this->player->interactEntity($target, $data->getClickPosition());
566 case UseItemOnEntityTransactionData::ACTION_ATTACK:
567 $this->player->attackEntity($target);
575 $this->player->selectHotbarSlot($data->getHotbarSlot());
577 if($data->getActionType() === ReleaseItemTransactionData::ACTION_RELEASE){
578 $this->player->releaseHeldItem();
601 $transaction = $executor->generateInventoryTransaction();
602 if($transaction !==
null){
603 $result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
609 $this->session->getLogger()->debug(
"ItemStackRequest #" . $request->getRequestId() .
" failed: " . $e->getMessage());
610 $this->session->getLogger()->debug(implode(
"\n", Utils::printableExceptionInfo($e)));
611 $this->inventoryManager->requestSyncAll();
614 return $result ? $executor->getItemStackResponseBuilder() :
null;
619 if(count($packet->getRequests()) > 80){
623 foreach($packet->getRequests() as $request){
624 $responses[] = $this->handleSingleItemStackRequest($request)?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
633 if($packet->windowId === ContainerIds::OFFHAND){
636 if($packet->windowId === ContainerIds::INVENTORY){
637 $this->inventoryManager->onClientSelectHotbarSlot($packet->hotbarSlot);
638 if(!$this->player->selectHotbarSlot($packet->hotbarSlot)){
639 $this->inventoryManager->syncSelectedHotbarSlot();
651 if($packet->action === InteractPacket::ACTION_MOUSEOVER){
659 $target = $this->player->getWorld()->getEntity($packet->targetActorRuntimeId);
660 if($target ===
null){
663 if($packet->action === InteractPacket::ACTION_OPEN_INVENTORY && $target === $this->player){
664 $this->inventoryManager->onClientOpenMainInventory();
671 return $this->player->pickBlock(
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData);
675 return $this->player->pickEntity($packet->actorUniqueId);
679 return $this->handlePlayerActionFromData($packet->action, $packet->blockPosition, $packet->face);
682 private function handlePlayerActionFromData(
int $action,
BlockPosition $blockPosition,
int $extraData) :
bool{
683 $pos =
new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
686 case PlayerAction::START_BREAK:
687 case PlayerAction::CONTINUE_DESTROY_BLOCK:
688 $face = self::deserializeFacing($extraData);
689 if($this->lastBlockAttacked !==
null && $blockPosition->equals($this->lastBlockAttacked)){
694 $this->session->getLogger()->debug(
"Ignoring PlayerAction $action on $pos because we were already destroying this block");
697 if(!$this->player->attackBlock($pos, $face)){
698 $this->syncBlocksNearby($pos, $face);
700 $this->lastBlockAttacked = $blockPosition;
704 case PlayerAction::ABORT_BREAK:
705 case PlayerAction::STOP_BREAK:
706 $this->player->stopBreakBlock($pos);
707 $this->lastBlockAttacked =
null;
709 case PlayerAction::START_SLEEPING:
712 case PlayerAction::STOP_SLEEPING:
713 $this->player->stopSleep();
715 case PlayerAction::CRACK_BREAK:
716 $face = self::deserializeFacing($extraData);
717 $this->player->continueBreakBlock($pos, $face);
718 $this->lastBlockAttacked = $blockPosition;
720 case PlayerAction::INTERACT_BLOCK:
722 case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
724 case PlayerAction::PREDICT_DESTROY_BLOCK:
725 if(!$this->player->breakBlock($pos)){
726 $face = self::deserializeFacing($extraData);
727 $this->syncBlocksNearby($pos, $face);
729 $this->lastBlockAttacked =
null;
731 case PlayerAction::START_ITEM_USE_ON:
732 case PlayerAction::STOP_ITEM_USE_ON:
736 $this->session->getLogger()->debug(
"Unhandled/unknown player action type " . $action);
740 $this->player->setUsingItem(
false);
754 $this->inventoryManager->onClientRemoveWindow($packet->windowId);
766 $textTag = $nbt->
getTag($tagName);
768 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textTag) .
" for tag \"$tagName\" in sign update data");
770 $textBlobTag = $textTag->getTag(Sign::TAG_TEXT_BLOB);
772 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textBlobTag) .
" for tag \"" . Sign::TAG_TEXT_BLOB .
"\" in sign update data");
776 $text = SignText::fromBlob($textBlobTag->getValue());
777 }
catch(\InvalidArgumentException $e){
778 throw PacketHandlingException::wrap($e,
"Invalid sign text update");
781 $oldText = $block->getFaceText($frontFace);
782 if($text->getLines() === $oldText->getLines()){
788 foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
789 $this->session->sendDataPacket($updatePacket);
794 }
catch(\UnexpectedValueException $e){
795 throw PacketHandlingException::wrap($e);
800 $pos =
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
801 if($pos->distanceSquared($this->player->getLocation()) > 10000){
805 $block = $this->player->getLocation()->getWorld()->getBlock($pos);
806 $nbt = $packet->nbt->getRoot();
810 if(!$this->updateSignText($nbt, Sign::TAG_FRONT_TEXT,
true, $block, $pos)){
812 $this->updateSignText($nbt, Sign::TAG_BACK_TEXT,
false, $block, $pos);
822 $gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
823 if($gameMode !== $this->player->getGamemode()){
825 $this->session->syncGameMode($this->player->getGamemode(),
true);
839 $this->player->setViewDistance($packet->radius);
853 if(str_starts_with($packet->command,
'/')){
854 $this->player->chat($packet->command);
865 if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
868 $this->session->getLogger()->debug(
"Refused duplicate skin change request");
871 $this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
873 $this->session->getLogger()->debug(
"Processing skin change request");
875 $skin = $this->session->getTypeConverter()->getSkinAdapter()->fromSkinData($packet->skin);
877 throw PacketHandlingException::wrap($e,
"Invalid skin in PlayerSkinPacket");
879 return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName);
889 private function checkBookText(
string $string,
string $fieldName,
int $softLimit,
int $hardLimit,
bool &$cancel) :
string{
890 if(strlen($string) > $hardLimit){
891 throw new PacketHandlingException(sprintf(
"Book %s must be at most %d bytes, but have %d bytes", $fieldName, $hardLimit, strlen($string)));
894 $result = TextFormat::clean($string,
false);
896 if(strlen($result) > $softLimit * 4 || mb_strlen($result,
'UTF-8') > $softLimit){
898 $this->session->getLogger()->debug(
"Cancelled book edit due to $fieldName exceeded soft limit of $softLimit chars");
905 $inventory = $this->player->getInventory();
906 if(!$inventory->slotExists($packet->inventorySlot)){
910 $oldBook = $inventory->getItem($packet->inventorySlot);
915 $newBook = clone $oldBook;
918 switch($packet->type){
919 case BookEditPacket::TYPE_REPLACE_PAGE:
920 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
921 $newBook->setPageText($packet->pageNumber, $text);
922 $modifiedPages[] = $packet->pageNumber;
924 case BookEditPacket::TYPE_ADD_PAGE:
925 if(!$newBook->pageExists($packet->pageNumber)){
930 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
931 $newBook->insertPage($packet->pageNumber, $text);
932 $modifiedPages[] = $packet->pageNumber;
934 case BookEditPacket::TYPE_DELETE_PAGE:
935 if(!$newBook->pageExists($packet->pageNumber)){
938 $newBook->deletePage($packet->pageNumber);
939 $modifiedPages[] = $packet->pageNumber;
941 case BookEditPacket::TYPE_SWAP_PAGES:
942 if(!$newBook->pageExists($packet->pageNumber) || !$newBook->pageExists($packet->secondaryPageNumber)){
944 $newBook->addPage(max($packet->pageNumber, $packet->secondaryPageNumber));
946 $newBook->swapPages($packet->pageNumber, $packet->secondaryPageNumber);
947 $modifiedPages = [$packet->pageNumber, $packet->secondaryPageNumber];
949 case BookEditPacket::TYPE_SIGN_BOOK:
950 $title = self::checkBookText($packet->title,
"title", 16, Limits::INT16_MAX, $cancel);
952 $author = self::checkBookText($packet->author,
"author", 256, Limits::INT16_MAX, $cancel);
954 $newBook = VanillaItems::WRITTEN_BOOK()
955 ->setPages($oldBook->getPages())
958 ->setGeneration(WrittenBook::GENERATION_ORIGINAL);
965 $action = match($packet->type){
966 BookEditPacket::TYPE_REPLACE_PAGE => PlayerEditBookEvent::ACTION_REPLACE_PAGE,
967 BookEditPacket::TYPE_ADD_PAGE => PlayerEditBookEvent::ACTION_ADD_PAGE,
968 BookEditPacket::TYPE_DELETE_PAGE => PlayerEditBookEvent::ACTION_DELETE_PAGE,
969 BookEditPacket::TYPE_SWAP_PAGES => PlayerEditBookEvent::ACTION_SWAP_PAGES,
970 BookEditPacket::TYPE_SIGN_BOOK => PlayerEditBookEvent::ACTION_SIGN_BOOK,
978 $oldPageCount = count($oldBook->getPages());
979 $newPageCount = count($newBook->getPages());
980 if(($newPageCount > $oldPageCount && $newPageCount > 50)){
981 $this->session->getLogger()->debug(
"Cancelled book edit due to adding too many pages (new page count would be $newPageCount)");
985 $event =
new PlayerEditBookEvent($this->player, $oldBook, $newBook, $action, $modifiedPages);
991 if($event->isCancelled()){
995 $this->player->getInventory()->setItem($packet->inventorySlot, $event->getNewBook());
1001 if($packet->cancelReason !==
null){
1003 return $this->player->onFormSubmit($packet->formId,
null);
1004 }elseif($packet->formData !==
null){
1006 $responseData = json_decode($packet->formData,
true, self::MAX_FORM_RESPONSE_DEPTH, JSON_THROW_ON_ERROR);
1007 }
catch(\JsonException $e){
1008 throw PacketHandlingException::wrap($e,
"Failed to decode form response data");
1010 return $this->player->onFormSubmit($packet->formId, $responseData);
1012 throw new PacketHandlingException(
"Expected either formData or cancelReason to be set in ModalFormResponsePacket");
1025 $pos = $packet->blockPosition;
1026 $chunkX = $pos->getX() >> Chunk::COORD_BIT_SIZE;
1027 $chunkZ = $pos->getZ() >> Chunk::COORD_BIT_SIZE;
1028 $world = $this->player->getWorld();
1029 if(!$world->isChunkLoaded($chunkX, $chunkZ) || $world->isChunkLocked($chunkX, $chunkZ)){
1033 $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ());
1034 if($lectern instanceof
Lectern && $this->player->canInteract($lectern->getPosition(), 15)){
1035 if(!$lectern->onPageTurn($packet->page)){
1036 $this->syncBlocksNearby($lectern->getPosition(),
null);
1058 public function handleEmote(
EmotePacket $packet) :
bool{
1059 $this->player->emote($packet->getEmoteId());