Update latency translator for 1.20.10 (#3993)

This commit is contained in:
Konicai 2023-07-17 14:45:45 -04:00 committed by GitHub
parent c1d8009b40
commit 396f4e4900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -87,6 +87,10 @@ public final class GameProtocol {
return session.getUpstream().getProtocolVersion() < Bedrock_v589.CODEC.getProtocolVersion(); return session.getUpstream().getProtocolVersion() < Bedrock_v589.CODEC.getProtocolVersion();
} }
public static boolean isPre1_20_10(GeyserSession session) {
return session.getUpstream().getProtocolVersion() < Bedrock_v594.CODEC.getProtocolVersion();
}
/** /**
* Gets the {@link PacketCodec} for Minecraft: Java Edition. * Gets the {@link PacketCodec} for Minecraft: Java Edition.
* *

View file

@ -31,6 +31,7 @@ import org.cloudburstmc.protocol.bedrock.packet.NetworkStackLatencyPacket;
import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket; import org.cloudburstmc.protocol.bedrock.packet.UpdateAttributesPacket;
import org.geysermc.floodgate.util.DeviceOs; import org.geysermc.floodgate.util.DeviceOs;
import org.geysermc.geyser.entity.attribute.GeyserAttributeType; import org.geysermc.geyser.entity.attribute.GeyserAttributeType;
import org.geysermc.geyser.network.GameProtocol;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
@ -50,10 +51,15 @@ public class BedrockNetworkStackLatencyTranslator extends PacketTranslator<Netwo
// so apparently, as of 1.16.200 // so apparently, as of 1.16.200
// PS4 divides the network stack latency timestamp FOR US!!! // PS4 divides the network stack latency timestamp FOR US!!!
// WTF // WTF
if (session.getClientData().getDeviceOs().equals(DeviceOs.PS4)) { if (GameProtocol.isPre1_20_10(session)) {
pingId = packet.getTimestamp(); if (session.getClientData().getDeviceOs().equals(DeviceOs.PS4)) {
pingId = packet.getTimestamp();
} else {
pingId = packet.getTimestamp() / 1000;
}
} else { } else {
pingId = packet.getTimestamp() / 1000; // changed in 1.20.10 todo: is ps4 still different?
pingId = packet.getTimestamp() / (1000 * 1000 * 1000);
} }
// negative timestamps are used as hack to fix the url image loading bug // negative timestamps are used as hack to fix the url image loading bug