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), Facing::DOWN);
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->getInventory()->getItemInHand();
316 $this->player->broadcastAnimation(
new ConsumingItemAnimation($this->player, $this->player->getInventory()->getItemInHand()));
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->onSlotChange($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 $builder->getInventory($inventory)->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 self::validateFacing($data->getFace());
499 $blockPos = $data->getBlockPosition();
500 $vBlockPos =
new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
501 $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos);
502 if($data->getClientInteractPrediction() === PredictedResult::SUCCESS){
507 $this->syncBlocksNearby($vBlockPos, $data->getFace());
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 validateFacing(
int $facing) :
void{
529 if(!in_array($facing, Facing::ALL,
true)){
537 private function syncBlocksNearby(
Vector3 $blockPos, ?
int $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 $face) :
bool{
683 $pos =
new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
686 case PlayerAction::START_BREAK:
687 case PlayerAction::CONTINUE_DESTROY_BLOCK:
688 self::validateFacing($face);
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 self::validateFacing($face);
717 $this->player->continueBreakBlock($pos, $face);
718 $this->lastBlockAttacked = $blockPosition;
720 case PlayerAction::INTERACT_BLOCK:
722 case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
725 case PlayerAction::PREDICT_DESTROY_BLOCK:
726 self::validateFacing($face);
727 if(!$this->player->breakBlock($pos)){
728 $this->syncBlocksNearby($pos, $face);
730 $this->lastBlockAttacked =
null;
732 case PlayerAction::START_ITEM_USE_ON:
733 case PlayerAction::STOP_ITEM_USE_ON:
737 $this->session->getLogger()->debug(
"Unhandled/unknown player action type " . $action);
741 $this->player->setUsingItem(
false);
755 $this->inventoryManager->onClientRemoveWindow($packet->windowId);
767 $textTag = $nbt->
getTag($tagName);
769 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textTag) .
" for tag \"$tagName\" in sign update data");
771 $textBlobTag = $textTag->getTag(Sign::TAG_TEXT_BLOB);
773 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textBlobTag) .
" for tag \"" . Sign::TAG_TEXT_BLOB .
"\" in sign update data");
777 $text = SignText::fromBlob($textBlobTag->getValue());
778 }
catch(\InvalidArgumentException $e){
779 throw PacketHandlingException::wrap($e,
"Invalid sign text update");
782 $oldText = $block->getFaceText($frontFace);
783 if($text->getLines() === $oldText->getLines()){
789 foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
790 $this->session->sendDataPacket($updatePacket);
795 }
catch(\UnexpectedValueException $e){
796 throw PacketHandlingException::wrap($e);
801 $pos =
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
802 if($pos->distanceSquared($this->player->getLocation()) > 10000){
806 $block = $this->player->getLocation()->getWorld()->getBlock($pos);
807 $nbt = $packet->nbt->getRoot();
811 if(!$this->updateSignText($nbt, Sign::TAG_FRONT_TEXT,
true, $block, $pos)){
813 $this->updateSignText($nbt, Sign::TAG_BACK_TEXT,
false, $block, $pos);
823 $gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
824 if($gameMode !== $this->player->getGamemode()){
826 $this->session->syncGameMode($this->player->getGamemode(),
true);
840 $this->player->setViewDistance($packet->radius);
854 if(str_starts_with($packet->command,
'/')){
855 $this->player->chat($packet->command);
866 if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
869 $this->session->getLogger()->debug(
"Refused duplicate skin change request");
872 $this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
874 $this->session->getLogger()->debug(
"Processing skin change request");
876 $skin = $this->session->getTypeConverter()->getSkinAdapter()->fromSkinData($packet->skin);
878 throw PacketHandlingException::wrap($e,
"Invalid skin in PlayerSkinPacket");
880 return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName);
890 private function checkBookText(
string $string,
string $fieldName,
int $softLimit,
int $hardLimit,
bool &$cancel) :
string{
891 if(strlen($string) > $hardLimit){
892 throw new PacketHandlingException(sprintf(
"Book %s must be at most %d bytes, but have %d bytes", $fieldName, $hardLimit, strlen($string)));
895 $result = TextFormat::clean($string,
false);
897 if(strlen($result) > $softLimit * 4 || mb_strlen($result,
'UTF-8') > $softLimit){
899 $this->session->getLogger()->debug(
"Cancelled book edit due to $fieldName exceeded soft limit of $softLimit chars");
906 $inventory = $this->player->getInventory();
907 if(!$inventory->slotExists($packet->inventorySlot)){
911 $oldBook = $inventory->getItem($packet->inventorySlot);
916 $newBook = clone $oldBook;
919 switch($packet->type){
920 case BookEditPacket::TYPE_REPLACE_PAGE:
921 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
922 $newBook->setPageText($packet->pageNumber, $text);
923 $modifiedPages[] = $packet->pageNumber;
925 case BookEditPacket::TYPE_ADD_PAGE:
926 if(!$newBook->pageExists($packet->pageNumber)){
931 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
932 $newBook->insertPage($packet->pageNumber, $text);
933 $modifiedPages[] = $packet->pageNumber;
935 case BookEditPacket::TYPE_DELETE_PAGE:
936 if(!$newBook->pageExists($packet->pageNumber)){
939 $newBook->deletePage($packet->pageNumber);
940 $modifiedPages[] = $packet->pageNumber;
942 case BookEditPacket::TYPE_SWAP_PAGES:
943 if(!$newBook->pageExists($packet->pageNumber) || !$newBook->pageExists($packet->secondaryPageNumber)){
945 $newBook->addPage(max($packet->pageNumber, $packet->secondaryPageNumber));
947 $newBook->swapPages($packet->pageNumber, $packet->secondaryPageNumber);
948 $modifiedPages = [$packet->pageNumber, $packet->secondaryPageNumber];
950 case BookEditPacket::TYPE_SIGN_BOOK:
951 $title = self::checkBookText($packet->title,
"title", 16, Limits::INT16_MAX, $cancel);
953 $author = self::checkBookText($packet->author,
"author", 256, Limits::INT16_MAX, $cancel);
955 $newBook = VanillaItems::WRITTEN_BOOK()
956 ->setPages($oldBook->getPages())
959 ->setGeneration(WrittenBook::GENERATION_ORIGINAL);
966 $action = match($packet->type){
967 BookEditPacket::TYPE_REPLACE_PAGE => PlayerEditBookEvent::ACTION_REPLACE_PAGE,
968 BookEditPacket::TYPE_ADD_PAGE => PlayerEditBookEvent::ACTION_ADD_PAGE,
969 BookEditPacket::TYPE_DELETE_PAGE => PlayerEditBookEvent::ACTION_DELETE_PAGE,
970 BookEditPacket::TYPE_SWAP_PAGES => PlayerEditBookEvent::ACTION_SWAP_PAGES,
971 BookEditPacket::TYPE_SIGN_BOOK => PlayerEditBookEvent::ACTION_SIGN_BOOK,
979 $oldPageCount = count($oldBook->getPages());
980 $newPageCount = count($newBook->getPages());
981 if(($newPageCount > $oldPageCount && $newPageCount > 50)){
982 $this->session->getLogger()->debug(
"Cancelled book edit due to adding too many pages (new page count would be $newPageCount)");
986 $event =
new PlayerEditBookEvent($this->player, $oldBook, $newBook, $action, $modifiedPages);
992 if($event->isCancelled()){
996 $this->player->getInventory()->setItem($packet->inventorySlot, $event->getNewBook());
1002 if($packet->cancelReason !==
null){
1004 return $this->player->onFormSubmit($packet->formId,
null);
1005 }elseif($packet->formData !==
null){
1007 $responseData = json_decode($packet->formData,
true, self::MAX_FORM_RESPONSE_DEPTH, JSON_THROW_ON_ERROR);
1008 }
catch(\JsonException $e){
1009 throw PacketHandlingException::wrap($e,
"Failed to decode form response data");
1011 return $this->player->onFormSubmit($packet->formId, $responseData);
1013 throw new PacketHandlingException(
"Expected either formData or cancelReason to be set in ModalFormResponsePacket");
1026 $pos = $packet->blockPosition;
1027 $chunkX = $pos->getX() >> Chunk::COORD_BIT_SIZE;
1028 $chunkZ = $pos->getZ() >> Chunk::COORD_BIT_SIZE;
1029 $world = $this->player->getWorld();
1030 if(!$world->isChunkLoaded($chunkX, $chunkZ) || $world->isChunkLocked($chunkX, $chunkZ)){
1034 $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ());
1035 if($lectern instanceof
Lectern && $this->player->canInteract($lectern->getPosition(), 15)){
1036 if(!$lectern->onPageTurn($packet->page)){
1037 $this->syncBlocksNearby($lectern->getPosition(),
null);
1059 public function handleEmote(
EmotePacket $packet) :
bool{
1060 $this->player->emote($packet->getEmoteId());