Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +01:00
Handle keepalives better (Closes #965)
Bedrock cuts off the last 3 digits consistently every time, meaning that the keepalive returned from bedrock is never fully accurate. However, if we multiply the value by 1000, then divide by 1000 when sending back to java, the proper value is returned.
Dieser Commit ist enthalten in:
Ursprung
a60ab4e80e
Commit
70031c65e7
@ -196,12 +196,6 @@ public class GeyserSession implements CommandSender {
|
|||||||
@Setter
|
@Setter
|
||||||
private long lastWindowCloseTime = 0;
|
private long lastWindowCloseTime = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the timestamp of the last keep alive packet
|
|
||||||
*/
|
|
||||||
@Setter
|
|
||||||
private long lastKeepAliveTimestamp = 0;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private VillagerTrade[] villagerTrades;
|
private VillagerTrade[] villagerTrades;
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -39,8 +39,6 @@ public class BedrockNetworkStackLatencyTranslator extends PacketTranslator<Netwo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(NetworkStackLatencyPacket packet, GeyserSession session) {
|
public void translate(NetworkStackLatencyPacket packet, GeyserSession session) {
|
||||||
// The client sends a timestamp back but it's rounded and therefore unreliable when we need the exact number
|
session.sendDownstreamPacket(new ClientKeepAlivePacket(packet.getTimestamp() / 1000));
|
||||||
ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(session.getLastKeepAliveTimestamp());
|
|
||||||
session.sendDownstreamPacket(keepAlivePacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,10 +39,9 @@ public class JavaKeepAliveTranslator extends PacketTranslator<ServerKeepAlivePac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerKeepAlivePacket packet, GeyserSession session) {
|
public void translate(ServerKeepAlivePacket packet, GeyserSession session) {
|
||||||
session.setLastKeepAliveTimestamp(packet.getPingId());
|
|
||||||
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
||||||
latencyPacket.setFromServer(true);
|
latencyPacket.setFromServer(true);
|
||||||
latencyPacket.setTimestamp(packet.getPingId());
|
latencyPacket.setTimestamp(packet.getPingId() * 1000);
|
||||||
session.sendUpstreamPacket(latencyPacket);
|
session.sendUpstreamPacket(latencyPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren