BlockHorizons / BlockSniper

An advanced (brush) world editing plugin for PocketMine-MP
https://poggit.pmmp.io/p/BlockSniper/
Apache License 2.0
76 stars 41 forks source link

fix an error that happened when trying to use melt or smooth #139

Closed AndreasHGK closed 2 years ago

AndreasHGK commented 4 years ago

Tested: yes

There would be an error when trying to uses brushes like melt or smooth, or any other ones that use this function. Now it should be fixed.

Sandertv commented 4 years ago

I don't see how this would work. I added the ChunkManager->getSide specifically because none of the blocks have a world instance when this is called async, so Block->getSide() would fail.

dktapps commented 4 years ago

"there would be an error" wow, very description

AndreasHGK commented 4 years ago
2020-06-13 [16:44:25.399] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\world\World::getSide()" (EXCEPTION) in "plugins/BlockSniper/src/BlockHorizons/BlockSniper/brush/Type" at line 195
2020-06-13 [16:44:25.399] [Server thread/DEBUG]: #0 plugins/BlockSniper/src/BlockHorizons/BlockSniper/brush/type/SmoothType(38): BlockHorizons\BlockSniper\brush\Type->side(object pocketmine\world\Position, integer 0)
2020-06-13 [16:44:25.400] [Server thread/DEBUG]: #1 plugins/BlockSniper/src/BlockHorizons/BlockSniper/brush/Brush(99): BlockHorizons\BlockSniper\brush\type\SmoothType->fill()
2020-06-13 [16:44:25.401] [Server thread/DEBUG]: #2 plugins/BlockSniper/src/BlockHorizons/BlockSniper/listener/BrushListener(116): BlockHorizons\BlockSniper\brush\Brush->execute(object BlockHorizons\BlockSniper\session\PlayerSession, object pocketmine\world\Position, array[0], NULL )
2020-06-13 [16:44:25.401] [Server thread/DEBUG]: #3 plugins/BlockSniper/src/BlockHorizons/BlockSniper/listener/BrushListener(84): BlockHorizons\BlockSniper\listener\BrushListener->useBrush(object BlockHorizons\BlockSniper\session\PlayerSession, object BlockHorizons\BlockSniper\brush\Brush, object pocketmine\player\Player)
2020-06-13 [16:44:25.401] [Server thread/DEBUG]: #4 src/event/RegisteredListener(75): BlockHorizons\BlockSniper\listener\BrushListener->brush(object pocketmine\event\player\PlayerItemUseEvent)
2020-06-13 [16:44:25.402] [Server thread/DEBUG]: #5 src/event/Event(62): pocketmine\event\RegisteredListener->callEvent(object pocketmine\event\player\PlayerItemUseEvent)
2020-06-13 [16:44:25.402] [Server thread/DEBUG]: #6 src/player/Player(1421): pocketmine\event\Event->call()
2020-06-13 [16:44:25.403] [Server thread/DEBUG]: #7 src/network/mcpe/handler/InGamePacketHandler(325): pocketmine\player\Player->useHeldItem()
2020-06-13 [16:44:25.403] [Server thread/DEBUG]: #8 src/network/mcpe/handler/InGamePacketHandler(188): pocketmine\network\mcpe\handler\InGamePacketHandler->handleUseItemTransaction(object pocketmine\network\mcpe\protocol\types\inventory\UseItemTransactionData)
2020-06-13 [16:44:25.403] [Server thread/DEBUG]: #9 src/network/mcpe/protocol/InventoryTransactionPacket(85): pocketmine\network\mcpe\handler\InGamePacketHandler->handleInventoryTransaction(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket)
2020-06-13 [16:44:25.404] [Server thread/DEBUG]: #10 src/network/mcpe/NetworkSession(338): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(object pocketmine\network\mcpe\handler\InGamePacketHandler)
2020-06-13 [16:44:25.404] [Server thread/DEBUG]: #11 src/network/mcpe/NetworkSession(305): pocketmine\network\mcpe\NetworkSession->handleDataPacket(object pocketmine\network\mcpe\protocol\InventoryTransactionPacket)
2020-06-13 [16:44:25.405] [Server thread/DEBUG]: #12 src/network/mcpe/raklib/RakLibInterface(152): pocketmine\network\mcpe\NetworkSession->handleEncoded(string[40] x...cb`d``...5....b.....[_..]B.........@)
2020-06-13 [16:44:25.405] [Server thread/DEBUG]: #13 vendor/pocketmine/raklib/src/server/ServerHandler(102): pocketmine\network\mcpe\raklib\RakLibInterface->handleEncapsulated(integer 0, object raklib\protocol\EncapsulatedPacket, integer 0)
2020-06-13 [16:44:25.405] [Server thread/DEBUG]: #14 src/network/mcpe/raklib/RakLibInterface(96): raklib\server\ServerHandler->handlePacket()
2020-06-13 [16:44:25.406] [Server thread/DEBUG]: #15 vendor/pocketmine/snooze/src/SleeperHandler(123): pocketmine\network\mcpe\raklib\RakLibInterface->pocketmine\network\mcpe\raklib\{closure}()
2020-06-13 [16:44:25.406] [Server thread/DEBUG]: #16 vendor/pocketmine/snooze/src/SleeperHandler(85): pocketmine\snooze\SleeperHandler->processNotifications()
2020-06-13 [16:44:25.406] [Server thread/DEBUG]: #17 src/Server(1560): pocketmine\snooze\SleeperHandler->sleepUntil(double 1592063065.418)
2020-06-13 [16:44:25.407] [Server thread/DEBUG]: #18 src/Server(1133): pocketmine\Server->tickProcessor()
2020-06-13 [16:44:25.407] [Server thread/DEBUG]: #19 src/PocketMine(265): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[33] C:\Users\Andreas\Desktop\prisons\, string[41] C:\Users\Andreas\Desktop\prisons\plugins\)
2020-06-13 [16:44:25.407] [Server thread/DEBUG]: #20 src/PocketMine(288): pocketmine\server()
2020-06-13 [16:44:25.408] [Server thread/DEBUG]: #21 (11): require(string[77] phar://C:/Users/Andreas/Desktop/prisons/PocketMine-MP.phar/src/PocketMine.php)

I got this error when trying to use the brushes and with these changes it no longer occurs and the brushes do work

Sandertv commented 4 years ago

This isn't the solution to that. Brushing asynchronously will break completely with this commit.