From e1b27022310f6338975c6a342343f31a582111f5 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Wed, 10 Jun 2020 19:34:22 +0200 Subject: [PATCH] 1.16 pre3 --- .../api/protocol/ProtocolVersion.java | 2 +- .../ViaVersion/api/rewriters/TagRewriter.java | 5 +- .../Protocol1_16To1_15_2.java | 26 ++++- .../packets/EntityPackets.java | 100 ++++++++++-------- .../packets/WorldPackets.java | 9 ++ 5 files changed, 97 insertions(+), 45 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java index 8108d663a..2ba3944fb 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolVersion.java @@ -80,7 +80,7 @@ public class ProtocolVersion { register(v1_15 = new ProtocolVersion(573, "1.15")); register(v1_15_1 = new ProtocolVersion(575, "1.15.1")); register(v1_15_2 = new ProtocolVersion(578, "1.15.2")); - register(v1_16 = new ProtocolVersion(722, "1.16")); + register(v1_16 = new ProtocolVersion(725, "1.16")); register(unknown = new ProtocolVersion(-1, "UNKNOWN")); } diff --git a/common/src/main/java/us/myles/ViaVersion/api/rewriters/TagRewriter.java b/common/src/main/java/us/myles/ViaVersion/api/rewriters/TagRewriter.java index 5b2edd47e..30faec23b 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/rewriters/TagRewriter.java +++ b/common/src/main/java/us/myles/ViaVersion/api/rewriters/TagRewriter.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.List; public class TagRewriter { - public static final int[] EMPTY_ARRAY = {}; + private static final int[] EMPTY_ARRAY = {-1}; private final Protocol protocol; private final IdRewriteFunction blockRewriter; private final IdRewriteFunction itemRewriter; @@ -26,6 +26,9 @@ public class TagRewriter { this.entityRewriter = entityRewriter; } + /** + * Adds an empty tag (since the client crashes if a checked tag is not registered.) + */ public void addEmptyTag(TagType tagType, String id) { getNewTags(tagType).add(new TagData(id, EMPTY_ARRAY)); } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java index 47f423259..a431a6d02 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/Protocol1_16To1_15_2.java @@ -104,6 +104,29 @@ public class Protocol1_16To1_15_2 extends Protocol { + wrapper.passthrough(Type.VAR_INT); // Entity Id + int action = wrapper.passthrough(Type.VAR_INT); + if (action == 0 || action == 2) { + if (action == 2) { + // Location + wrapper.passthrough(Type.FLOAT); + wrapper.passthrough(Type.FLOAT); + wrapper.passthrough(Type.FLOAT); + } + + wrapper.passthrough(Type.VAR_INT); // Hand + + // New boolean: Whether the client is sneaking/pressing shift + wrapper.read(Type.BOOLEAN); + } + }); + } + }); + cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW); cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK); } @@ -164,7 +187,8 @@ public class Protocol1_16To1_15_2 extends Protocol(Type.STRING_ARRAY) { // World list - only used for command completion - @Override - public String[] transform(PacketWrapper wrapper, Void input) throws Exception { - return WORLD_NAMES; - } - }); - map(Type.NOTHING, new ValueTransformer(Type.NBT) { // whatever this is - @Override - public CompoundTag transform(PacketWrapper wrapper, Void input) throws Exception { - return DIMENSIONS_TAG; - } + handler(wrapper -> { + wrapper.write(Type.STRING_ARRAY, WORLD_NAMES); // World list - only used for command completion + wrapper.write(Type.NBT, DIMENSIONS_TAG); // Dimension registry }); handler(DIMENSION_HANDLER); // Dimension map(Type.LONG); // Seed diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java index 27fe2f2de..8b8ca2aa8 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_16to1_15_2/packets/WorldPackets.java @@ -31,6 +31,15 @@ public class WorldPackets { blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING); + protocol.registerOutgoing(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() { + @Override + public void registerMap() { + map(Type.VAR_INT); // x + map(Type.VAR_INT); // y + handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well + } + }); + protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() { @Override public void registerMap() {