mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-02 22:07:49 +01:00
Don't swap teleport accept and move packets for 1.21.4 clients
They changed it again. Probably missing the same swap in 1.21.4<->1.21.2 now
This commit is contained in:
parent
cfa20ba418
commit
d3f92ce9b8
@ -172,7 +172,8 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
|
|||||||
registerClientbound(ClientboundPackets1_21.BUNDLE_DELIMITER, wrapper -> wrapper.user().get(BundleStateTracker.class).toggleBundling());
|
registerClientbound(ClientboundPackets1_21.BUNDLE_DELIMITER, wrapper -> wrapper.user().get(BundleStateTracker.class).toggleBundling());
|
||||||
registerServerbound(ServerboundPackets1_21_2.PONG, wrapper -> {
|
registerServerbound(ServerboundPackets1_21_2.PONG, wrapper -> {
|
||||||
final int id = wrapper.passthrough(Types.INT); // id
|
final int id = wrapper.passthrough(Types.INT); // id
|
||||||
if (wrapper.user().get(PlayerPositionStorage.class).checkPong(id)) {
|
final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
||||||
|
if (playerPositionStorage != null && playerPositionStorage.checkPong(id)) {
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -234,13 +235,17 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
|
|||||||
public void init(final UserConnection connection) {
|
public void init(final UserConnection connection) {
|
||||||
addEntityTracker(connection, new EntityTracker1_21_2(connection));
|
addEntityTracker(connection, new EntityTracker1_21_2(connection));
|
||||||
connection.put(new BundleStateTracker());
|
connection.put(new BundleStateTracker());
|
||||||
connection.put(new PlayerPositionStorage());
|
|
||||||
connection.put(new GroundFlagTracker());
|
connection.put(new GroundFlagTracker());
|
||||||
|
|
||||||
|
final ProtocolVersion protocolVersion = connection.getProtocolInfo().protocolVersion();
|
||||||
|
if (protocolVersion.olderThan(ProtocolVersion.v1_21_4)) { // Only needed for 1.21.2/1.21.3
|
||||||
|
connection.put(new PlayerPositionStorage());
|
||||||
|
}
|
||||||
|
|
||||||
// <= 1.21.1 clients allowed loaded chunks to get replaced with new data without unloading them first.
|
// <= 1.21.1 clients allowed loaded chunks to get replaced with new data without unloading them first.
|
||||||
// 1.21.2 introduced a graphical bug where it doesn't properly render the new data unless the chunk is unloaded beforehand.
|
// 1.21.2 introduced a graphical bug where it doesn't properly render the new data unless the chunk is unloaded beforehand.
|
||||||
// 1.21.4 fixed this bug, so the workaround is no longer needed.
|
// 1.21.4 fixed this bug, so the workaround is no longer needed.
|
||||||
if (connection.getProtocolInfo().protocolVersion().equals(ProtocolVersion.v1_21_2)) {
|
if (protocolVersion.equals(ProtocolVersion.v1_21_2)) {
|
||||||
connection.put(new ChunkLoadTracker());
|
connection.put(new ChunkLoadTracker());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,6 +200,11 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
|||||||
final int teleportId = wrapper.read(Types.VAR_INT);
|
final int teleportId = wrapper.read(Types.VAR_INT);
|
||||||
wrapper.set(Types.VAR_INT, 0, teleportId);
|
wrapper.set(Types.VAR_INT, 0, teleportId);
|
||||||
|
|
||||||
|
final PlayerPositionStorage positionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
||||||
|
if (positionStorage == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Accept teleportation and player position were swapped.
|
// Accept teleportation and player position were swapped.
|
||||||
// Send a ping first to then capture and send the player position the accept teleportation
|
// Send a ping first to then capture and send the player position the accept teleportation
|
||||||
final boolean isBundling = wrapper.user().get(BundleStateTracker.class).isBundling();
|
final boolean isBundling = wrapper.user().get(BundleStateTracker.class).isBundling();
|
||||||
@ -209,7 +214,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
|||||||
}
|
}
|
||||||
|
|
||||||
final int pingId = ThreadLocalRandom.current().nextInt();
|
final int pingId = ThreadLocalRandom.current().nextInt();
|
||||||
wrapper.user().get(PlayerPositionStorage.class).addPendingPong(pingId);
|
positionStorage.addPendingPong(pingId);
|
||||||
final PacketWrapper ping = wrapper.create(ClientboundPackets1_21_2.PING);
|
final PacketWrapper ping = wrapper.create(ClientboundPackets1_21_2.PING);
|
||||||
ping.write(Types.INT, pingId); // id
|
ping.write(Types.INT, pingId); // id
|
||||||
ping.send(Protocol1_21To1_21_2.class);
|
ping.send(Protocol1_21To1_21_2.class);
|
||||||
@ -330,7 +335,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
|||||||
handleOnGround(wrapper);
|
handleOnGround(wrapper);
|
||||||
|
|
||||||
final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
||||||
if (playerPositionStorage.checkCaptureNextPlayerPositionPacket()) {
|
if (playerPositionStorage != null && playerPositionStorage.checkCaptureNextPlayerPositionPacket()) {
|
||||||
// Capture this packet and send it after accept teleportation
|
// Capture this packet and send it after accept teleportation
|
||||||
final boolean onGround = wrapper.get(Types.BOOLEAN, 0);
|
final boolean onGround = wrapper.get(Types.BOOLEAN, 0);
|
||||||
playerPositionStorage.setPlayerPosition(new PlayerPositionStorage.PlayerPosition(x, y, z, yaw, pitch, onGround));
|
playerPositionStorage.setPlayerPosition(new PlayerPositionStorage.PlayerPosition(x, y, z, yaw, pitch, onGround));
|
||||||
@ -355,7 +360,7 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
|||||||
});
|
});
|
||||||
protocol.registerServerbound(ServerboundPackets1_21_2.ACCEPT_TELEPORTATION, wrapper -> {
|
protocol.registerServerbound(ServerboundPackets1_21_2.ACCEPT_TELEPORTATION, wrapper -> {
|
||||||
final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
final PlayerPositionStorage playerPositionStorage = wrapper.user().get(PlayerPositionStorage.class);
|
||||||
if (playerPositionStorage.checkHasPlayerPosition()) {
|
if (playerPositionStorage != null && playerPositionStorage.checkHasPlayerPosition()) {
|
||||||
// Send move player after accept teleportation
|
// Send move player after accept teleportation
|
||||||
wrapper.sendToServer(Protocol1_21To1_21_2.class);
|
wrapper.sendToServer(Protocol1_21To1_21_2.class);
|
||||||
wrapper.cancel();
|
wrapper.cancel();
|
||||||
|
Loading…
Reference in New Issue
Block a user