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), Facing::DOWN);
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->getInventory()->getItemInHand();
315 $this->player->broadcastAnimation(
new ConsumingItemAnimation($this->player, $this->player->getInventory()->getItemInHand()));
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->onSlotChange($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 $builder->getInventory($inventory)->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 self::validateFacing($data->getFace());
498 $blockPos = $data->getBlockPosition();
499 $vBlockPos =
new Vector3($blockPos->getX(), $blockPos->getY(), $blockPos->getZ());
500 $this->player->interactBlock($vBlockPos, $data->getFace(), $clickPos);
505 $this->syncBlocksNearby($vBlockPos, $data->getFace());
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 validateFacing(
int $facing) :
void{
526 if(!in_array($facing, Facing::ALL,
true)){
534 private function syncBlocksNearby(
Vector3 $blockPos, ?
int $face) :
void{
535 if($blockPos->distanceSquared($this->player->getLocation()) < 10000){
538 $sidePos = $blockPos->
getSide($face);
541 array_push($blocks, ...$sidePos->sidesArray());
543 $blocks[] = $blockPos;
545 foreach($this->player->getWorld()->createBlockUpdatePackets($blocks) as $packet){
546 $this->session->sendDataPacket($packet);
552 $target = $this->player->getWorld()->getEntity($data->getActorRuntimeId());
553 if($target ===
null){
557 $this->player->selectHotbarSlot($data->getHotbarSlot());
559 switch($data->getActionType()){
560 case UseItemOnEntityTransactionData::ACTION_INTERACT:
561 $this->player->interactEntity($target, $data->getClickPosition());
563 case UseItemOnEntityTransactionData::ACTION_ATTACK:
564 $this->player->attackEntity($target);
572 $this->player->selectHotbarSlot($data->getHotbarSlot());
574 if($data->getActionType() === ReleaseItemTransactionData::ACTION_RELEASE){
575 $this->player->releaseHeldItem();
598 $transaction = $executor->generateInventoryTransaction();
599 if($transaction !==
null){
600 $result = $this->executeInventoryTransaction($transaction, $request->getRequestId());
606 $this->session->getLogger()->debug(
"ItemStackRequest #" . $request->getRequestId() .
" failed: " . $e->getMessage());
607 $this->session->getLogger()->debug(implode(
"\n", Utils::printableExceptionInfo($e)));
608 $this->inventoryManager->requestSyncAll();
611 return $result ? $executor->getItemStackResponseBuilder() :
null;
616 if(count($packet->getRequests()) > 80){
620 foreach($packet->getRequests() as $request){
621 $responses[] = $this->handleSingleItemStackRequest($request)?->build() ??
new ItemStackResponse(ItemStackResponse::RESULT_ERROR, $request->getRequestId());
630 if($packet->windowId === ContainerIds::OFFHAND){
633 if($packet->windowId === ContainerIds::INVENTORY){
634 $this->inventoryManager->onClientSelectHotbarSlot($packet->hotbarSlot);
635 if(!$this->player->selectHotbarSlot($packet->hotbarSlot)){
636 $this->inventoryManager->syncSelectedHotbarSlot();
648 if($packet->action === InteractPacket::ACTION_MOUSEOVER){
656 $target = $this->player->getWorld()->getEntity($packet->targetActorRuntimeId);
657 if($target ===
null){
660 if($packet->action === InteractPacket::ACTION_OPEN_INVENTORY && $target === $this->player){
661 $this->inventoryManager->onClientOpenMainInventory();
668 return $this->player->pickBlock(
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ()), $packet->addUserData);
672 return $this->player->pickEntity($packet->actorUniqueId);
676 return $this->handlePlayerActionFromData($packet->action, $packet->blockPosition, $packet->face);
679 private function handlePlayerActionFromData(
int $action,
BlockPosition $blockPosition,
int $face) :
bool{
680 $pos =
new Vector3($blockPosition->getX(), $blockPosition->getY(), $blockPosition->getZ());
683 case PlayerAction::START_BREAK:
684 case PlayerAction::CONTINUE_DESTROY_BLOCK:
685 self::validateFacing($face);
686 if($this->lastBlockAttacked !==
null && $blockPosition->equals($this->lastBlockAttacked)){
691 $this->session->getLogger()->debug(
"Ignoring PlayerAction $action on $pos because we were already destroying this block");
694 if(!$this->player->attackBlock($pos, $face)){
695 $this->syncBlocksNearby($pos, $face);
697 $this->lastBlockAttacked = $blockPosition;
701 case PlayerAction::ABORT_BREAK:
702 case PlayerAction::STOP_BREAK:
703 $this->player->stopBreakBlock($pos);
704 $this->lastBlockAttacked =
null;
706 case PlayerAction::START_SLEEPING:
709 case PlayerAction::STOP_SLEEPING:
710 $this->player->stopSleep();
712 case PlayerAction::CRACK_BREAK:
713 self::validateFacing($face);
714 $this->player->continueBreakBlock($pos, $face);
715 $this->lastBlockAttacked = $blockPosition;
717 case PlayerAction::INTERACT_BLOCK:
719 case PlayerAction::CREATIVE_PLAYER_DESTROY_BLOCK:
721 case PlayerAction::PREDICT_DESTROY_BLOCK:
722 if(!$this->player->breakBlock($pos)){
723 $this->syncBlocksNearby($pos, $face);
725 $this->lastBlockAttacked =
null;
727 case PlayerAction::START_ITEM_USE_ON:
728 case PlayerAction::STOP_ITEM_USE_ON:
732 $this->session->getLogger()->debug(
"Unhandled/unknown player action type " . $action);
736 $this->player->setUsingItem(
false);
750 $this->inventoryManager->onClientRemoveWindow($packet->windowId);
759 $pos =
new Vector3($packet->blockPosition->getX(), $packet->blockPosition->getY(), $packet->blockPosition->getZ());
760 if($pos->distanceSquared($this->player->getLocation()) > 10000){
764 $block = $this->player->getLocation()->getWorld()->getBlock($pos);
765 $nbt = $packet->nbt->getRoot();
769 $frontTextTag = $nbt->getTag(Sign::TAG_FRONT_TEXT);
771 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($frontTextTag) .
" for tag \"" . Sign::TAG_FRONT_TEXT .
"\" in sign update data");
773 $textBlobTag = $frontTextTag->getTag(Sign::TAG_TEXT_BLOB);
775 throw new PacketHandlingException(
"Invalid tag type " . get_debug_type($textBlobTag) .
" for tag \"" . Sign::TAG_TEXT_BLOB .
"\" in sign update data");
779 $text = SignText::fromBlob($textBlobTag->getValue());
780 }
catch(\InvalidArgumentException $e){
781 throw PacketHandlingException::wrap($e,
"Invalid sign text update");
785 if(!$block->updateText($this->player, $text)){
786 foreach($this->player->getWorld()->createBlockUpdatePackets([$pos]) as $updatePacket){
787 $this->session->sendDataPacket($updatePacket);
790 }
catch(\UnexpectedValueException $e){
791 throw PacketHandlingException::wrap($e);
801 $gameMode = $this->session->getTypeConverter()->protocolGameModeToCore($packet->gamemode);
802 if($gameMode !== $this->player->getGamemode()){
804 $this->session->syncGameMode($this->player->getGamemode(),
true);
818 $this->player->setViewDistance($packet->radius);
832 if(str_starts_with($packet->command,
'/')){
833 $this->player->chat($packet->command);
844 if($packet->skin->getFullSkinId() === $this->lastRequestedFullSkinId){
847 $this->session->getLogger()->debug(
"Refused duplicate skin change request");
850 $this->lastRequestedFullSkinId = $packet->skin->getFullSkinId();
852 $this->session->getLogger()->debug(
"Processing skin change request");
854 $skin = $this->session->getTypeConverter()->getSkinAdapter()->fromSkinData($packet->skin);
856 throw PacketHandlingException::wrap($e,
"Invalid skin in PlayerSkinPacket");
858 return $this->player->changeSkin($skin, $packet->newSkinName, $packet->oldSkinName);
868 private function checkBookText(
string $string,
string $fieldName,
int $softLimit,
int $hardLimit,
bool &$cancel) :
string{
869 if(strlen($string) > $hardLimit){
870 throw new PacketHandlingException(sprintf(
"Book %s must be at most %d bytes, but have %d bytes", $fieldName, $hardLimit, strlen($string)));
873 $result = TextFormat::clean($string,
false);
875 if(strlen($result) > $softLimit * 4 || mb_strlen($result,
'UTF-8') > $softLimit){
877 $this->session->getLogger()->debug(
"Cancelled book edit due to $fieldName exceeded soft limit of $softLimit chars");
884 $inventory = $this->player->getInventory();
885 if(!$inventory->slotExists($packet->inventorySlot)){
889 $oldBook = $inventory->getItem($packet->inventorySlot);
894 $newBook = clone $oldBook;
897 switch($packet->type){
898 case BookEditPacket::TYPE_REPLACE_PAGE:
899 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
900 $newBook->setPageText($packet->pageNumber, $text);
901 $modifiedPages[] = $packet->pageNumber;
903 case BookEditPacket::TYPE_ADD_PAGE:
904 if(!$newBook->pageExists($packet->pageNumber)){
909 $text = self::checkBookText($packet->text,
"page text", 256, WritableBookPage::PAGE_LENGTH_HARD_LIMIT_BYTES, $cancel);
910 $newBook->insertPage($packet->pageNumber, $text);
911 $modifiedPages[] = $packet->pageNumber;
913 case BookEditPacket::TYPE_DELETE_PAGE:
914 if(!$newBook->pageExists($packet->pageNumber)){
917 $newBook->deletePage($packet->pageNumber);
918 $modifiedPages[] = $packet->pageNumber;
920 case BookEditPacket::TYPE_SWAP_PAGES:
921 if(!$newBook->pageExists($packet->pageNumber) || !$newBook->pageExists($packet->secondaryPageNumber)){
923 $newBook->addPage(max($packet->pageNumber, $packet->secondaryPageNumber));
925 $newBook->swapPages($packet->pageNumber, $packet->secondaryPageNumber);
926 $modifiedPages = [$packet->pageNumber, $packet->secondaryPageNumber];
928 case BookEditPacket::TYPE_SIGN_BOOK:
929 $title = self::checkBookText($packet->title,
"title", 16, Limits::INT16_MAX, $cancel);
931 $author = self::checkBookText($packet->author,
"author", 256, Limits::INT16_MAX, $cancel);
933 $newBook = VanillaItems::WRITTEN_BOOK()
934 ->setPages($oldBook->getPages())
937 ->setGeneration(WrittenBook::GENERATION_ORIGINAL);
944 $action = match($packet->type){
945 BookEditPacket::TYPE_REPLACE_PAGE => PlayerEditBookEvent::ACTION_REPLACE_PAGE,
946 BookEditPacket::TYPE_ADD_PAGE => PlayerEditBookEvent::ACTION_ADD_PAGE,
947 BookEditPacket::TYPE_DELETE_PAGE => PlayerEditBookEvent::ACTION_DELETE_PAGE,
948 BookEditPacket::TYPE_SWAP_PAGES => PlayerEditBookEvent::ACTION_SWAP_PAGES,
949 BookEditPacket::TYPE_SIGN_BOOK => PlayerEditBookEvent::ACTION_SIGN_BOOK,
957 $oldPageCount = count($oldBook->getPages());
958 $newPageCount = count($newBook->getPages());
959 if(($newPageCount > $oldPageCount && $newPageCount > 50)){
960 $this->session->getLogger()->debug(
"Cancelled book edit due to adding too many pages (new page count would be $newPageCount)");
964 $event =
new PlayerEditBookEvent($this->player, $oldBook, $newBook, $action, $modifiedPages);
970 if($event->isCancelled()){
974 $this->player->getInventory()->setItem($packet->inventorySlot, $event->getNewBook());
980 if($packet->cancelReason !==
null){
982 return $this->player->onFormSubmit($packet->formId,
null);
983 }elseif($packet->formData !==
null){
985 $responseData = json_decode($packet->formData,
true, self::MAX_FORM_RESPONSE_DEPTH, JSON_THROW_ON_ERROR);
986 }
catch(\JsonException $e){
987 throw PacketHandlingException::wrap($e,
"Failed to decode form response data");
989 return $this->player->onFormSubmit($packet->formId, $responseData);
991 throw new PacketHandlingException(
"Expected either formData or cancelReason to be set in ModalFormResponsePacket");
1004 $pos = $packet->blockPosition;
1005 $chunkX = $pos->getX() >> Chunk::COORD_BIT_SIZE;
1006 $chunkZ = $pos->getZ() >> Chunk::COORD_BIT_SIZE;
1007 $world = $this->player->getWorld();
1008 if(!$world->isChunkLoaded($chunkX, $chunkZ) || $world->isChunkLocked($chunkX, $chunkZ)){
1012 $lectern = $world->getBlockAt($pos->getX(), $pos->getY(), $pos->getZ());
1013 if($lectern instanceof
Lectern && $this->player->canInteract($lectern->getPosition(), 15)){
1014 if(!$lectern->onPageTurn($packet->page)){
1015 $this->syncBlocksNearby($lectern->getPosition(),
null);
1037 public function handleEmote(
EmotePacket $packet) :
bool{
1038 $this->player->emote($packet->getEmoteId());