-
Notifications
You must be signed in to change notification settings - Fork 26
piece of thought: redundant code cause LAN mode failing #71
Description
Many modpacks using this mod, and it causes LAN servers failed to be connected.
Looks like caused by following codes:
SimpleLogin/src/main/java/top/seraphjack/simplelogin/client/ClientLoader.java
Lines 17 to 21 in afdda60
| public static void joinServer(ClientPlayerNetworkEvent.LoggingIn event) { | |
| if (event.getConnection().isMemoryConnection()) return; | |
| SimpleLogin.logger.debug("Sending login packet to the server..."); | |
| NetworkLoader.INSTANCE.sendToServer(new MessageLogin(PasswordHolder.instance().password())); | |
| } |
It might be unnecessary for client sending password at the very beginning,
since server sends a request login message while logging in:
SimpleLogin/src/main/java/top/seraphjack/simplelogin/server/ServerSideEventHandler.java
Line 30 in afdda60
| NetworkLoader.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) event.getEntity()), new MessageRequestLogin()); |
And the client seems handles it correctly:
SimpleLogin/src/main/java/top/seraphjack/simplelogin/network/MessageRequestLogin.java
Lines 23 to 28 in afdda60
| public static void handle(MessageRequestLogin message, Supplier<NetworkEvent.Context> ctx) { | |
| ctx.get().enqueueWork(() -> { | |
| NetworkLoader.INSTANCE.sendToServer(new MessageLogin(PasswordHolder.instance().password())); | |
| }); | |
| ctx.get().setPacketHandled(true); | |
| } |
It should be safe to remove those redundant codes in ClientLoader.