lovetwice1012 / BigBrother-1

Allows the connection of Minecraft: Java Edtion clients to PocketMine-MP servers. Made for PocketMine-MP
GNU Lesser General Public License v3.0
9 stars 6 forks source link

(some) Packet IDs are Incorrect #10

Open KingRainbow44 opened 3 years ago

KingRainbow44 commented 3 years ago

EDIT

The title is not related to this initial issue. It is related to everything that happens after.

Issue description

UpdateViewPositionPacket::UPDATE_VIEW_POSITION_PACKET is undefined. This is caused by the ProtocolTranslator. I got the message after changing the catch block to send the exception message. $data = chr(ServerManager::PACKET_SEND_PACKET) . Binary::writeInt($target) . $packet->write();

Prerequisite

BigBrother, Clean PMMP server, PHP 8.0.

How to reproduce

Connect to the server on 1.16.5.

Server log(crash dump)

Undefined constant shoghicp\BigBrother\network\protocol\Play\Server\UpdateViewPositionPacket::UPDATE_VIEW_POSITION_PACKET
[17:22:26] [Server thread/CRITICAL]: ErrorException: "Undefined variable $data" (EXCEPTION) in "plugins/BigBrother.phar/src/shoghicp/BigBrother/network/ProtocolInterface" at line 194
[17:22:26] [Server thread/CRITICAL]: #0 plugins/BigBrother.phar/src/shoghicp/BigBrother/network/ProtocolInterface(194): pocketmine\utils\Utils::errorExceptionHandler(integer 2, string[24] Undefined variable $data, string[100] phar:///home/container/plugins/BigBrother.phar/src/shoghicp/BigBrother/network/P, integer 194)
[17:22:26] [Server thread/CRITICAL]: #1 plugins/BigBrother.phar/src/shoghicp/BigBrother/network/ProtocolInterface(251): shoghicp\BigBrother\network\ProtocolInterface->sendPacket(integer 1, object shoghicp\BigBrother\network\protocol\Play\Server\UpdateViewPositionPacket)
[17:22:26] [Server thread/CRITICAL]: #2 pmsrc/src/pocketmine/Player(3369): shoghicp\BigBrother\network\ProtocolInterface->putPacket(object shoghicp\BigBrother\DesktopPlayer, object shoghicp\BigBrother\network\protocol\Play\Server\UpdateViewPositionPacket, boolean , boolean )
[17:22:26] [Server thread/CRITICAL]: #3 pmsrc/src/pocketmine/Player(3386): pocketmine\Player->sendDataPacket(object pocketmine\network\mcpe\protocol\StartGamePacket, boolean , boolean )
[17:22:26] [Server thread/CRITICAL]: #4 pmsrc/src/pocketmine/Player(2280): pocketmine\Player->dataPacket(object pocketmine\network\mcpe\protocol\StartGamePacket)
[17:22:26] [Server thread/CRITICAL]: #5 pmsrc/src/pocketmine/Player(2215): pocketmine\Player->completeLoginSequence()
[17:22:26] [Server thread/CRITICAL]: #6 pmsrc/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(125): pocketmine\Player->handleResourcePackClientResponse(object pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket)
[17:22:26] [Server thread/CRITICAL]: #7 pmsrc/src/pocketmine/network/mcpe/protocol/ResourcePackClientResponsePacket(62): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleResourcePackClientResponse(object pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket)
[17:22:26] [Server thread/CRITICAL]: #8 plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer(800): pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
[17:22:26] [Server thread/CRITICAL]: #9 plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer(416): shoghicp\BigBrother\DesktopPlayer->handleDataPacket(object pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket)
[17:22:26] [Server thread/CRITICAL]: #10 pmsrc/src/pocketmine/Player(2026): shoghicp\BigBrother\DesktopPlayer->onVerifyCompleted(object pocketmine\network\mcpe\protocol\LoginPacket, NULL , boolean 1)
[17:22:26] [Server thread/CRITICAL]: #11 pmsrc/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(117): pocketmine\Player->handleLogin(object pocketmine\network\mcpe\protocol\LoginPacket)
[17:22:26] [Server thread/CRITICAL]: #12 pmsrc/src/pocketmine/network/mcpe/protocol/LoginPacket(145): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleLogin(object pocketmine\network\mcpe\protocol\LoginPacket)
[17:22:26] [Server thread/CRITICAL]: #13 plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer(800): pocketmine\network\mcpe\protocol\LoginPacket->handle(object pocketmine\network\mcpe\PlayerNetworkSessionAdapter)
[17:22:26] [Server thread/CRITICAL]: #14 plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer(572): shoghicp\BigBrother\DesktopPlayer->handleDataPacket(object pocketmine\network\mcpe\protocol\LoginPacket)
[17:22:26] [Server thread/CRITICAL]: #15 plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer(661): shoghicp\BigBrother\DesktopPlayer->bigBrother_authenticate(string[32] ccdbcd67ea3643cc8a4dbceef8b175a3, array[1])
[17:22:26] [Server thread/CRITICAL]: #16 pmsrc/src/pocketmine/scheduler/AsyncPool(319): pocketmine\scheduler\AsyncTask@anonymousphar:///home/container/plugins/BigBrother.phar/src/shoghicp/BigBrother/DesktopPlayer.php:604$b7->onCompletion(object pocketmine\Server)
[17:22:26] [Server thread/CRITICAL]: #17 pmsrc/src/pocketmine/Server(2393): pocketmine\scheduler\AsyncPool->collectTasks()
[17:22:26] [Server thread/CRITICAL]: #18 pmsrc/src/pocketmine/Server(2152): pocketmine\Server->tick()
[17:22:26] [Server thread/CRITICAL]: #19 pmsrc/src/pocketmine/Server(1992): pocketmine\Server->tickProcessor()
[17:22:26] [Server thread/CRITICAL]: #20 pmsrc/src/pocketmine/Server(1586): pocketmine\Server->start()
[17:22:26] [Server thread/CRITICAL]: #21 pmsrc/src/pocketmine/PocketMine(314): pocketmine\Server->__construct(object BaseClassLoader, object pocketmine\utils\MainLogger, string[16] /home/container/, string[24] /home/container/plugins/)
[17:22:26] [Server thread/CRITICAL]: #22 pmsrc/src/pocketmine/PocketMine(344): pocketmine\server()
[17:22:26] [Server thread/CRITICAL]: #23 pmsrc(11): require(string[71] phar:///home/container/PocketMine-MP.phar/src/pocketmine/PocketMine.php)
KingRainbow44 commented 3 years ago

cant really debug this either because of the indirect reference. edit: forgot about logging the file from exceptions. file: phar:///home/container/plugins/BigBrother.phar/src/shoghicp/BigBrother/network/protocol/Play/Server/UpdateViewPositionPacket.php

KingRainbow44 commented 3 years ago

update: OutboundPacket ids might be outdated. UPDATE_VIEW_POSITION_PACKET belongs to 0x40 which was taken by SET_EXPERIENCE_PACKET which is actually 0x48 edit: 100% the ids are outdated. another error from:

phar:///home/container/plugins/BigBrother.phar/src/shoghicp/BigBrother/network/protocol/Play/Server/UpdateHealthPacket.php
Undefined constant shoghicp\BigBrother\network\protocol\Play\Server\UpdateHealthPacket::UPDATE_HEALTH_PACKET

edit 2: that error above was my doing (I commented out the update_health_packet line). ig ill take some time to refactor the packets class

KingRainbow44 commented 3 years ago

update: it seems like the OutboundPacket class actually contains Client Bound Packets and InboundPacket actually contains Server Bound Packets its either this or my source is wrong. edit: i have refactored the classes to the opposite of each other. will be trying to implement the missing packets shortly edit 2: this was not the smartest of decisions as now every packet class extends the "wrong" class (by name) but it will work for debugging purposes for now edit 3: ill have to revert my changes but yes, most of the packets are messed up

KingRainbow44 commented 3 years ago

update: i will begin refactoring packet ids. im using this to get the ids. edit: just want to note that only SOME ids are incorrect. not all. edit 2: finished updating InboundPacket ids. edit 3: finished updating OutboundPacket ids. edit 4: packets are STILL messed up because of the naming scheme. inboundpacket contains outbound and vice versa. i wont fix this issue but someone else can after cherry-picking commits from my fork

KingRainbow44 commented 3 years ago

update: packet ids have been updated, im now going to test and pray this works! edit 1: the refactor does work but now there's a few other issues. will continue bug fixing. edit 2: the player can now connect, but is immediately disconnected because of a buffer issue

lovetwice1012 commented 3 years ago

We thank you for your cooperation. To tell the truth, I don't have a Java version of Minecraft and I worked with my friends. So I knew that the java version of Minecraft version 1.16.5 couldn't connect and the packet was the cause, but I couldn't fix the program because I didn't know where to fix it. bottom. I'm sorry I can't do anything. Would you please send me a pull request when you're done? Again, thank you for your cooperation.

KingRainbow44 commented 3 years ago

as long as you have a pc or an android phone you can connect using offline mode using a separate launcher like TLauncher. and for sure I will send a pull request when I get a working version