Make client net handling run on main thread
This commit is contained in:
1 parent
a50a0d7328
commit
059fda49a4
4 files changed
+34
-58
No files matched your search
@@ -12,7 +12,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public class CarpetClient
|
||||
{
|
||||
public static final Object sync = new Object();
|
||||
public static final int HI = 69;
|
||||
public static final int HELLO = 420;
|
||||
public static final int DATA = 1;
|
||||
@@ -25,14 +24,7 @@ public class CarpetClient
|
||||
|
||||
public static void gameJoined(LocalPlayer player)
|
||||
{
|
||||
synchronized (sync)
|
||||
{
|
||||
clientPlayer = player;
|
||||
// client didn't say hi back yet
|
||||
if (isServerCarpet)
|
||||
ClientNetworkHandler.respondHello();
|
||||
|
||||
}
|
||||
clientPlayer = player;
|
||||
}
|
||||
|
||||
public static void disconnect()
|
||||
|
||||
@@ -87,6 +87,7 @@ public class ClientNetworkHandler
|
||||
});
|
||||
};
|
||||
|
||||
// Ran on the Main Minecraft Thread
|
||||
public static void handleData(FriendlyByteBuf data, LocalPlayer player)
|
||||
{
|
||||
if (data != null)
|
||||
@@ -101,22 +102,19 @@ public class ClientNetworkHandler
|
||||
|
||||
private static void onHi(FriendlyByteBuf data)
|
||||
{
|
||||
synchronized (CarpetClient.sync)
|
||||
CarpetClient.setCarpet();
|
||||
CarpetClient.serverCarpetVersion = data.readUtf(64);
|
||||
if (CarpetSettings.carpetVersion.equals(CarpetClient.serverCarpetVersion))
|
||||
{
|
||||
CarpetClient.setCarpet();
|
||||
CarpetClient.serverCarpetVersion = data.readUtf(64);
|
||||
if (CarpetSettings.carpetVersion.equals(CarpetClient.serverCarpetVersion))
|
||||
{
|
||||
CarpetSettings.LOG.info("Joined carpet server with matching carpet version");
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetSettings.LOG.warn("Joined carpet server with another carpet version: "+CarpetClient.serverCarpetVersion);
|
||||
}
|
||||
if (CarpetClient.getPlayer() != null)
|
||||
respondHello();
|
||||
|
||||
CarpetSettings.LOG.info("Joined carpet server with matching carpet version");
|
||||
}
|
||||
else
|
||||
{
|
||||
CarpetSettings.LOG.warn("Joined carpet server with another carpet version: "+CarpetClient.serverCarpetVersion);
|
||||
}
|
||||
// We can ensure that this packet is
|
||||
// processed AFTER the player has joined
|
||||
respondHello();
|
||||
}
|
||||
|
||||
public static void respondHello()
|
||||
|
||||
Reference in new issue
Block a user