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 21761b29a..9dad42ff4 100644 Binary files a/common/src/main/resources/assets/viaversion/data/mappings-1.19.4to1.20.nbt and b/common/src/main/resources/assets/viaversion/data/mappings-1.19.4to1.20.nbt differ diff --git a/gradle.properties b/gradle.properties index 7ade6f25d..eb0b15e48 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project properties - we put these here so they can be modified without causing a recompile of the build scripts -projectVersion=4.7.0-23w16a-SNAPSHOT +projectVersion=4.7.0-23w17a-SNAPSHOT # Gradle properties org.gradle.daemon=true