Баг с чанками и как он фиксится

Заметил баг с чанками и тайлами на pmmp 4.7.0

Ошибка
2022-08-09 [22:12:58.766] [Server thread/CRITICAL]: TypeError: "pocketmine\world\format\Chunk::blockHash(): Argument #1 ($x) must be of type int, float given, called in phar://C:/Users/User/OneDrive/Рабочий стол/pmmp/PocketMine-MP.phar/src/world/format/Chunk.php on line 207" (EXCEPTION) in "pmsrc/src/world/format/Chunk" at line 339
--- Stack trace ---
  #0 pmsrc/src/world/format/Chunk(207): pocketmine\world\format\Chunk::blockHash(float 256, float 71, float 255.5683)
  #1 pmsrc/src/world/World(2397): pocketmine\world\format\Chunk->removeTile(object pocketmine\block\tile\Chest#100173)
  #2 pmsrc/src/block/tile/Tile(135): pocketmine\world\World->removeTile(object pocketmine\block\tile\Chest#100173)
  #3 pmsrc/src/block/tile/Chest(110): pocketmine\block\tile\Tile->close()
  #4 pmsrc/src/block/tile/Tile(112): pocketmine\block\tile\Chest->close()
  #5 pmsrc/src/event/RegisteredListener(60): pocketmine\block\tile\Tile->__destruct()
  #6 pmsrc/src/event/Event(62): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\player\PlayerJoinEvent#100169)
  #7 pmsrc/src/player/Player(834): pocketmine\event\Event->call()
  #8 pmsrc/src/network/mcpe/NetworkSession(710): pocketmine\player\Player->doFirstSpawn()
  #9 pmsrc/src/network/mcpe/NetworkSession(703): pocketmine\network\mcpe\NetworkSession->onClientSpawnResponse()
  #10 pmsrc/src/network/mcpe/handler/SpawnResponsePacketHandler(35): pocketmine\network\mcpe\NetworkSession->pocketmine\network\mcpe\{closure}()
  #11 pmsrc/vendor/pocketmine/bedrock-protocol/src/SetLocalPlayerAsInitializedPacket(42): pocketmine\network\mcpe\handler\SpawnResponsePacketHandler->handleSetLocalPlayerAsInitialized(object pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket#100179)
  #12 pmsrc/src/network/mcpe/NetworkSession(394): pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket->handle(object pocketmine\network\mcpe\handler\SpawnResponsePacketHandler#106706)
  #13 pmsrc/src/network/mcpe/NetworkSession(357): pocketmine\network\mcpe\NetworkSession->handleDataPacket(object pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket#100179, string[2] q.)
  #14 pmsrc/src/network/mcpe/raklib/RakLibInterface(182): pocketmine\network\mcpe\NetworkSession->handleEncoded(string[47] c*d4.........3048..Nt..X.... .....&&&k._o... ..)
  #15 pmsrc/vendor/pocketmine/raklib-ipc/src/RakLibToUserThreadMessageReceiver(42): pocketmine\network\mcpe\raklib\RakLibInterface->onPacketReceive(int 0, string[56] .....)%.....18.E)...VV.R2&.Lwa......;(.nG....'..qz......)
  #16 pmsrc/src/network/mcpe/raklib/RakLibInterface(112): raklib\server\ipc\RakLibToUserThreadMessageReceiver->handle(object pocketmine\network\mcpe\raklib\RakLibInterface#28433)
  #17 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\raklib\RakLibInterface->pocketmine\network\mcpe\raklib\{closure}()
  #18 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications()
  #19 pmsrc/src/Server(1703): pocketmine\snooze\SleeperHandler->sleepUntil(float 1660075978.7512)
  #20 pmsrc/src/Server(1063): pocketmine\Server->tickProcessor()
  #21 pmsrc/src/PocketMine(304): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#3, string[52] C:\Users\User\OneDrive\.............. ........\pmmp\, string[60] C:\Users\User\OneDrive\.............. ........\pmmp\plugins\)
  #22 pmsrc/src/PocketMine(327): pocketmine\server()
  #23 pmsrc(11): require(string[96] phar://C:/Users/User/OneDrive/.............. ......../pmmp/PocketMine-MP.phar/sr)
--- End of exception information ---

Фиксится данным образом:

  • Находим Chunk.php по пути world\format
  • Видоизменяем строку 207 на:
unset($this->tiles[Chunk::blockHash((int)$pos->x, (int)$pos->y, (int)$pos->z)]); 

1 симпатия

чанк норрис

помогите переписать говнокодную сборку, которую я писал пол года назад


помогите найти говнокод

помоги создать тайл честа и открыть игроку на пм4

pm4?

1 симпатия

у тя есть пример?

$position = $player->getPosition();
$tile = new \pocketmine\block\tile\Chest($position>getWorld(), $position->asVector3());
$position->getWorld()->addTile($tile);
$player->setCurrentWindow($tile->getInventory());

1 симпатия

ессли не получится, то отправь просто фейковый сундук игроку, тайл сам создастся

не повезло новичкам, которые пришли кодить на пм4. я ща искал методы, сам потерялся. дилан упростил кодинг)))

1 симпатия

кстати вот ещё один баг:

[23:25:05.314] [Server thread/CRITICAL]: TypeError: "pocketmine\world\World::isInWorld(): Argument #1 ($x) must be of type int, float given, called in C:\Users\User\OneDrive\Рабочий стол\pmmp\PocketMine-MP\src\world\World.php on line 1166" (EXCEPTION) in "pmsrc/src/world/World" at line 1484
--- Stack trace ---
  #0 pmsrc/src/world/World(1166): pocketmine\world\World->isInWorld(float 256.4941, float 51, float 255.3)
  #1 pmsrc/src/world/World(2380): pocketmine\world\World->scheduleDelayedBlockUpdate(object pocketmine\math\Vector3#100108, int 1)
  #2 plugins/ItemsRoulette/src/ItemsRoulette/Layton/ItemsRoulette(36): pocketmine\world\World->addTile(object pocketmine\block\tile\Chest#100111)
  #3 pmsrc/src/event/RegisteredListener(60): ItemsRoulette\Layton\ItemsRoulette->onPlayerJoin(object pocketmine\event\player\PlayerJoinEvent#100140)
  #4 pmsrc/src/event/Event(62): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\player\PlayerJoinEvent#100140)
  #5 pmsrc/src/player/Player(834): pocketmine\event\Event->call()
  #6 pmsrc/src/network/mcpe/NetworkSession(710): pocketmine\player\Player->doFirstSpawn()
  #7 pmsrc/src/network/mcpe/NetworkSession(703): pocketmine\network\mcpe\NetworkSession->onClientSpawnResponse()
  #8 pmsrc/src/network/mcpe/handler/SpawnResponsePacketHandler(35): pocketmine\network\mcpe\NetworkSession->pocketmine\network\mcpe\{closure}()
  #9 pmsrc/vendor/pocketmine/bedrock-protocol/src/SetLocalPlayerAsInitializedPacket(42): pocketmine\network\mcpe\handler\SpawnResponsePacketHandler->handleSetLocalPlayerAsInitialized(object pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket#100138)
  #10 pmsrc/src/network/mcpe/NetworkSession(394): pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket->handle(object pocketmine\network\mcpe\handler\SpawnResponsePacketHandler#120428)
  #11 pmsrc/src/network/mcpe/NetworkSession(357): pocketmine\network\mcpe\NetworkSession->handleDataPacket(object pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket#100138, string[2] q.)
  #12 pmsrc/src/network/mcpe/raklib/RakLibInterface(182): pocketmine\network\mcpe\NetworkSession->handleEncoded(string[46] c*d4......&...op~R..t............LLL. ....{A4.)
  #13 pmsrc/vendor/pocketmine/raklib-ipc/src/RakLibToUserThreadMessageReceiver(42): pocketmine\network\mcpe\raklib\RakLibInterface->onPacketReceive(int 0, string[55] ..J.QB s....8+G..xM8.....(..h'.x._(...f....';...2...#..)
  #14 pmsrc/src/network/mcpe/raklib/RakLibInterface(112): raklib\server\ipc\RakLibToUserThreadMessageReceiver->handle(object pocketmine\network\mcpe\raklib\RakLibInterface#28433)
  #15 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\raklib\RakLibInterface->pocketmine\network\mcpe\raklib\{closure}()
  #16 pmsrc/vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications()
  #17 pmsrc/src/Server(1703): pocketmine\snooze\SleeperHandler->sleepUntil(float 1660080305.3388)
  #18 pmsrc/src/Server(1063): pocketmine\Server->tickProcessor()
  #19 pmsrc/src/PocketMine(291): pocketmine\Server->__construct(object BaseClassLoader#2, object pocketmine\utils\MainLogger#3, string[52] C:\Users\User\OneDrive\.............. ........\pmmp\, string[60] C:\Users\User\OneDrive\.............. ........\pmmp\plugins\)
  #20 pmsrc/src/PocketMine(314): pocketmine\server()
--- End of exception information ---

замените строку 1166 (файл в ошибке) на:

!$this->isInWorld((int)$pos->x, (int)$pos->y, (int)$pos->z) ||

вот допишу сервер на 1.1, возможно, открою сервер на ласт версии

странно, что дилан эти баги не заметил


я вот хз, логично ли это оставить или нет

гкодина

поч

разные функции делают одно и тоже, исполняют запрос к базе

1 симпатия

а да, АХХАААХ