Renderer/src/main/java/electrosphere/net/client/protocol/PlayerProtocol.java
austin 0a74bed5d6
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
network entity id translation fixes
2024-08-28 12:20:30 -04:00

37 lines
1.3 KiB
Java

package electrosphere.net.client.protocol;
import org.joml.Vector3i;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.parser.net.message.PlayerMessage;
import electrosphere.net.server.player.Player;
import electrosphere.net.template.ClientProtocolTemplate;
/**
* The client protocol for handling player messages
*/
public class PlayerProtocol implements ClientProtocolTemplate<PlayerMessage> {
@Override
public PlayerMessage handleAsyncMessage(PlayerMessage message) {
return message;
}
@Override
public void handleSyncMessage(PlayerMessage message) {
Globals.profiler.beginCpuSample("PlayerProtocol.handlePlayerMessage");
switch(message.getMessageSubtype()){
case SET_ID:
Globals.clientPlayer = new Player(message.getplayerID());
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Player ID is " + Globals.clientPlayer.getId());
break;
case SETINITIALDISCRETEPOSITION:
Globals.clientPlayerData.setWorldPos(new Vector3i(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY(), message.getinitialDiscretePositionZ()));
break;
}
Globals.profiler.endCpuSample();
}
}