mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-02 22:07:49 +01:00
Only apply chunk loading fix for 1.21.2 clients (#14)
This commit is contained in:
parent
0acec719b1
commit
e539375143
@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.packet.State;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.rewriter.ComponentRewriter;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
|
||||
@ -234,8 +235,14 @@ public final class Protocol1_21To1_21_2 extends AbstractProtocol<ClientboundPack
|
||||
addEntityTracker(connection, new EntityTracker1_21_2(connection));
|
||||
connection.put(new BundleStateTracker());
|
||||
connection.put(new PlayerPositionStorage());
|
||||
connection.put(new ChunkLoadTracker());
|
||||
connection.put(new GroundFlagTracker());
|
||||
|
||||
// <= 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.4 fixed this bug, so the workaround is no longer needed.
|
||||
if (connection.getProtocolInfo().protocolVersion().equals(ProtocolVersion.v1_21_2)) {
|
||||
connection.put(new ChunkLoadTracker());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -376,6 +376,10 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
|
||||
}
|
||||
|
||||
final ChunkLoadTracker chunkLoadTracker = wrapper.user().get(ChunkLoadTracker.class);
|
||||
if (chunkLoadTracker == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunkLoadTracker.isChunkLoaded(chunk.getX(), chunk.getZ())) {
|
||||
// Unload the old chunk, so the new one can be loaded without graphical glitches
|
||||
// Bundling it prevents the client from falling through the world during the chunk swap
|
||||
@ -401,7 +405,11 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_21.FORGET_LEVEL_CHUNK, wrapper -> {
|
||||
final ChunkPosition chunkPosition = wrapper.passthrough(Types.CHUNK_POSITION);
|
||||
wrapper.user().get(ChunkLoadTracker.class).removeChunk(chunkPosition.chunkX(), chunkPosition.chunkZ());
|
||||
|
||||
final ChunkLoadTracker chunkLoadTracker = wrapper.user().get(ChunkLoadTracker.class);
|
||||
if (chunkLoadTracker != null) {
|
||||
chunkLoadTracker.removeChunk(chunkPosition.chunkX(), chunkPosition.chunkZ());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,10 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter<Clientbound
|
||||
|
||||
final EntityTracker entityTracker = tracker(wrapper.user());
|
||||
if (entityTracker.currentWorld() != null && !entityTracker.currentWorld().equals(world)) {
|
||||
wrapper.user().get(ChunkLoadTracker.class).clear();
|
||||
final ChunkLoadTracker chunkLoadTracker = wrapper.user().get(ChunkLoadTracker.class);
|
||||
if (chunkLoadTracker != null) {
|
||||
chunkLoadTracker.clear();
|
||||
}
|
||||
}
|
||||
|
||||
trackWorldDataByKey1_20_5(wrapper.user(), dimensionId, world);
|
||||
|
Loading…
Reference in New Issue
Block a user