From 56d772df340d5cca9f38e978ad8f5b4fe0f13acf Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 26 Apr 2023 18:46:52 +0200 Subject: [PATCH] 23w17a --- .../api/protocol/version/ProtocolVersion.java | 2 +- .../packets/InventoryPackets.java | 31 ++++++++++++++++-- .../viaversion/rewriter/BlockRewriter.java | 23 +++++++++++-- .../viaversion/data/mappings-1.19.4to1.20.nbt | Bin 729 -> 769 bytes gradle.properties | 2 +- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java index 533185137..17bd3fa7d 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java +++ b/api/src/main/java/com/viaversion/viaversion/api/protocol/version/ProtocolVersion.java @@ -83,7 +83,7 @@ public class ProtocolVersion { public static final ProtocolVersion v1_19_1 = register(760, "1.19.1/2", new VersionRange("1.19", 1, 2)); public static final ProtocolVersion v1_19_3 = register(761, "1.19.3"); public static final ProtocolVersion v1_19_4 = register(762, "1.19.4"); - public static final ProtocolVersion v1_20 = register(763, 131, "1.20"); + public static final ProtocolVersion v1_20 = register(763, 132, "1.20"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static ProtocolVersion register(int version, String name) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20to1_19_4/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20to1_19_4/packets/InventoryPackets.java index bb41a2989..e66207e95 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20to1_19_4/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_20to1_19_4/packets/InventoryPackets.java @@ -21,7 +21,9 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.Tag; +import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type; @@ -45,9 +47,7 @@ public final class InventoryPackets extends ItemRewriter blockRewriter = new BlockRewriter<>(protocol, Type.POSITION1_14); blockRewriter.registerBlockAction(ClientboundPackets1_19_4.BLOCK_ACTION); blockRewriter.registerBlockChange(ClientboundPackets1_19_4.BLOCK_CHANGE); - blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19_4.MULTI_BLOCK_CHANGE); blockRewriter.registerEffect(ClientboundPackets1_19_4.EFFECT, 1010, 2001); - blockRewriter.registerChunkData1_19(ClientboundPackets1_19_4.CHUNK_DATA, Chunk1_18Type::new, this::handleBlockEntity); blockRewriter.registerBlockEntityData(ClientboundPackets1_19_4.BLOCK_ENTITY_DATA, this::handleBlockEntity); registerOpenWindow(ClientboundPackets1_19_4.OPEN_WINDOW); @@ -74,6 +74,33 @@ public final class InventoryPackets extends ItemRewriter { + wrapper.passthrough(Type.VAR_INT); // X + wrapper.passthrough(Type.VAR_INT); // Y + wrapper.read(Type.BOOLEAN); // Trust edges + }); + + protocol.registerClientbound(ClientboundPackets1_19_4.MULTI_BLOCK_CHANGE, new PacketHandlers() { + @Override + public void register() { + map(Type.LONG); // Chunk position + read(Type.BOOLEAN); // Suppress light updates + handler(wrapper -> { + for (final BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { + record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); + } + }); + } + }); + final RecipeRewriter recipeRewriter = new RecipeRewriter1_19_4<>(protocol); protocol.registerClientbound(ClientboundPackets1_19_4.DECLARE_RECIPES, wrapper -> { final int size = wrapper.passthrough(Type.VAR_INT); 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 bf9e1724a..77b1fa331 100644 --- a/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/rewriter/BlockRewriter.java @@ -31,6 +31,7 @@ import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; +import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.util.MathUtil; @@ -115,6 +116,20 @@ public class BlockRewriter { }); } + public void registerVarLongMultiBlockChange1_20(C packetType) { + protocol.registerClientbound(packetType, new PacketHandlers() { + @Override + public void register() { + map(Type.LONG); // Chunk position + handler(wrapper -> { + for (BlockChangeRecord record : wrapper.passthrough(Type.VAR_LONG_BLOCK_CHANGE_RECORD_ARRAY)) { + record.setBlockId(protocol.getMappingData().getNewBlockStateId(record.getBlockId())); + } + }); + } + }); + } + public void registerAcknowledgePlayerDigging(C packetType) { // Same exact handler registerBlockChange(packetType); @@ -145,7 +160,11 @@ public class BlockRewriter { } public void registerChunkData1_19(C packetType, ChunkTypeSupplier chunkTypeSupplier, @Nullable Consumer blockEntityHandler) { - protocol.registerClientbound(packetType, wrapper -> { + protocol.registerClientbound(packetType, chunkDataHandler1_19(chunkTypeSupplier, blockEntityHandler)); + } + + 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"); @@ -175,7 +194,7 @@ public class BlockRewriter { } } } - }); + }; } public void registerBlockEntityData(C packetType) { diff --git a/common/src/main/resources/assets/viaversion/data/mappings-1.19.4to1.20.nbt b/common/src/main/resources/assets/viaversion/data/mappings-1.19.4to1.20.nbt index 21761b29a617f61740eb2f13ad65b4dfa382f155..9dad42ff4bc8652a9518bef0eb0581d14e85b6ca 100644 GIT binary patch delta 229 zcmXxezYf7*6b10}^=mt{gRNn0SXqS4D;St1l6I(sHp*fVa|fjFfX5Jn_%jKHCSs6? zcOb$sxXEw2=iZz|8|jm$cuZfJp#dOI2S6!O1gKSN(T29PqrC~G=QH>_DA1ANGL5;c zQ$Q!W(V6Z{>Y?B7IH82mZU%wt)VzTUXe$B5bA*H%#*s*sOun;eMsr#K;tI$#WhqDO esIGb2`1dg5rLZh%e>mK;lB_V3Fw>1M;{65CS1hXl delta 176 zcmZoRE85kJ!fcPQ<1Ct35cQY`s_)pellu!l9=mYU(pr|