carpet client synchronizations and protocols
This commit is contained in:
1 parent
2522884da3
commit
e540f9e238
19 files changed
+406
-173
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package carpet.network;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
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;
|
||||
|
||||
private static ClientPlayerEntity clientPlayer = null;
|
||||
private static boolean isServerCarpet = false;
|
||||
public static String serverCarpetVersion;
|
||||
public static final Identifier CARPET_CHANNEL = new Identifier("carpet:hello");
|
||||
|
||||
public static void gameJoined(ClientPlayerEntity player)
|
||||
{
|
||||
synchronized (sync)
|
||||
{
|
||||
clientPlayer = player;
|
||||
// client didn't say hi back yet
|
||||
if (isServerCarpet)
|
||||
ClientNetworkHandler.respondHello();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void disconnect()
|
||||
{
|
||||
isServerCarpet = false;
|
||||
clientPlayer = null;
|
||||
CarpetServer.disconnect();
|
||||
}
|
||||
|
||||
public static void setCarpet()
|
||||
{
|
||||
isServerCarpet = true;
|
||||
}
|
||||
|
||||
public static ClientPlayerEntity getPlayer()
|
||||
{
|
||||
return clientPlayer;
|
||||
}
|
||||
|
||||
public static boolean isCarpet()
|
||||
{
|
||||
return isServerCarpet;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user