From b4720c723a326e80dea74e8041c028288ecc3e60 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 27 Sep 2023 14:35:20 +1000 Subject: [PATCH] Fix biome and chunk size preconditions --- .../viaversion/viaversion/data/entity/EntityTrackerBase.java | 2 +- .../protocols/protocol1_19to1_18_2/packets/WorldPackets.java | 4 ++-- .../com/viaversion/viaversion/rewriter/BlockRewriter.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/data/entity/EntityTrackerBase.java b/common/src/main/java/com/viaversion/viaversion/data/entity/EntityTrackerBase.java index f347f54dc..bc958ead5 100644 --- a/common/src/main/java/com/viaversion/viaversion/data/entity/EntityTrackerBase.java +++ b/common/src/main/java/com/viaversion/viaversion/data/entity/EntityTrackerBase.java @@ -37,7 +37,7 @@ public class EntityTrackerBase implements EntityTracker, ClientEntityIdChangeLis private final UserConnection connection; private final EntityType playerType; private int clientEntityId = -1; - private int currentWorldSectionHeight = 16; + private int currentWorldSectionHeight = -1; private int currentMinY; private String currentWorld; private int biomesSent = -1; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java index 457ed00e6..55aba7e9b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_19to1_18_2/packets/WorldPackets.java @@ -44,8 +44,8 @@ public final class WorldPackets { protocol.registerClientbound(ClientboundPackets1_18.CHUNK_DATA, wrapper -> { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); - Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set"); - Preconditions.checkArgument(tracker.currentWorldSectionHeight() != 0, "Section height not set"); + Preconditions.checkArgument(tracker.biomesSent() != -1, "Biome count not set"); + Preconditions.checkArgument(tracker.currentWorldSectionHeight() != -1, "Section height not set"); final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()), MathUtil.ceilLog2(tracker.biomesSent())); diff --git a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java index 53c8b0d95..72af536ef 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -172,8 +172,8 @@ public class BlockRewriter { public PacketHandler chunkDataHandler1_19(ChunkTypeSupplier chunkTypeSupplier, @Nullable Consumer blockEntityHandler) { return wrapper -> { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); - Preconditions.checkArgument(tracker.biomesSent() != 0, "Biome count not set"); - Preconditions.checkArgument(tracker.currentWorldSectionHeight() != 0, "Section height not set"); + Preconditions.checkArgument(tracker.biomesSent() != -1, "Biome count not set"); + Preconditions.checkArgument(tracker.currentWorldSectionHeight() != -1, "Section height not set"); final Type chunkType = chunkTypeSupplier.supply(tracker.currentWorldSectionHeight(), MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().mappedSize()), MathUtil.ceilLog2(tracker.biomesSent()));