Track world ticks

This commit is contained in:
AJ Ferguson 2024-05-17 02:58:31 -04:00
parent 967d0a9fdd
commit b25087448c
3 changed files with 12 additions and 0 deletions

View file

@ -551,6 +551,14 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
*/
private int ticks;
/**
* The world time in ticks according to the server
* <p>
* Note: The TickingStatePacket is currently ignored.
*/
@Setter
private long worldTicks;
/**
* Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslator
*/
@ -1247,6 +1255,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
}
ticks++;
worldTicks++;
}
public void setAuthenticationData(AuthData authData) {

View file

@ -100,6 +100,7 @@ public class JavaRespawnTranslator extends PacketTranslator<ClientboundRespawnPa
DimensionUtils.switchDimension(session, fakeDim);
}
session.setWorldName(spawnInfo.getWorldName());
session.setWorldTicks(0);
DimensionUtils.switchDimension(session, newDimension);
ChunkUtils.loadDimension(session);

View file

@ -36,6 +36,8 @@ public class JavaSetTimeTranslator extends PacketTranslator<ClientboundSetTimePa
@Override
public void translate(GeyserSession session, ClientboundSetTimePacket packet) {
session.setWorldTicks(packet.getWorldAge());
// Bedrock sends a GameRulesChangedPacket if there is no daylight cycle
// Java just sends a negative long if there is no daylight cycle
long time = packet.getTime();