From deb11bf1a9bccd4fe0604213343a0b13ab9b7b24 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 16 Sep 2021 18:19:23 +0200 Subject: [PATCH] 21w37a works:tm: Co-authored-by: Gerrygames --- .../protocol1_17_1to1_18/Protocol1_17_1To1_18.java | 3 +++ .../packets/BlockItemPackets1_18.java | 8 ++++++-- .../protocol1_17_1to1_18/packets/EntityPackets1_18.java | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java index 900b3a6d..eb9652d6 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/Protocol1_17_1To1_18.java @@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types; import com.viaversion.viaversion.data.entity.EntityTrackerBase; import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1; import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17; +import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1; import com.viaversion.viaversion.rewriter.TagRewriter; public final class Protocol1_17_1To1_18 extends BackwardsProtocol { @@ -42,6 +43,8 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol { final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user()); - final Chunk oldChunk = wrapper.read(new Chunk1_18Type(tracker.currentWorldSectionHeight())); + final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(), + MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().size()), + MathUtil.ceilLog2(tracker.biomesSent())); + final Chunk oldChunk = wrapper.read(chunkType); final int[] biomeData = new int[oldChunk.getSections().length * 64]; final ChunkSection[] sections = oldChunk.getSections(); for (int i = 0; i < sections.length; i++) { @@ -127,7 +131,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter blockEntityTags = new ArrayList<>(oldChunk.blockEntities().size()); for (final BlockEntity blockEntity : oldChunk.blockEntities()) { - final CompoundTag tag = blockEntity.tag(); + final CompoundTag tag = blockEntity.tag() != null ? blockEntity.tag() : new CompoundTag(); final String id = protocol.getMappingData().blockEntities().get(blockEntity.typeId()); if (id == null) { // Shrug diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java index fcb7a3b6..086bb0bb 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_17_1to1_18/packets/EntityPackets1_18.java @@ -77,6 +77,9 @@ public final class EntityPackets1_18 extends EntityRewriter