From e5393751430b80662bb303c66d9d2be841edfd82 Mon Sep 17 00:00:00 2001 From: RK_01 <50594595+RaphiMC@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:43:27 +0100 Subject: [PATCH] Only apply chunk loading fix for 1.21.2 clients (#14) --- .../protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java | 9 ++++++++- .../rewriter/BlockItemPacketRewriter1_21_2.java | 10 +++++++++- .../rewriter/EntityPacketRewriter1_21_2.java | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java index 609a0e5f2..cef630da6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/Protocol1_21To1_21_2.java @@ -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 { 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()); + } }); } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java index aba23c3a8..5ed1ce96c 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_21to1_21_2/rewriter/EntityPacketRewriter1_21_2.java @@ -159,7 +159,10 @@ public final class EntityPacketRewriter1_21_2 extends EntityRewriter