From 9f9d05d3c6cef96db48690e5836755d319df61c5 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 6 Aug 2020 20:23:22 +0200 Subject: [PATCH] 1.16.2-pre3 --- .../packets/BlockItemPackets1_16_2.java | 2 ++ .../packets/EntityPackets1_16_2.java | 34 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java index 89de467f..41e7b864 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/BlockItemPackets1_16_2.java @@ -90,6 +90,8 @@ public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters. handler(wrapper -> { wrapper.cancel(); long chunkPosition = wrapper.read(Type.LONG); + wrapper.read(Type.BOOLEAN); // Ignore old light data + int chunkX = (int) (chunkPosition >> 42); int chunkY = (int) (chunkPosition << 44 >> 44); int chunkZ = (int) (chunkPosition << 22 >> 42); diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java index aea82dc7..7b053172 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_16_1to1_16_2/packets/EntityPackets1_16_2.java @@ -16,6 +16,8 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets.EntityPackets; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.viaversion.libs.gson.JsonElement; +import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag; +import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag; public class EntityPackets1_16_2 extends EntityRewriter { @@ -51,8 +53,10 @@ public class EntityPackets1_16_2 extends EntityRewriter // Just screw the registry and write the defaults for 1.16 and 1.16.1 clients wrapper.read(Type.NBT); wrapper.write(Type.NBT, EntityPackets.DIMENSIONS_TAG); + + CompoundTag dimensionData = wrapper.read(Type.NBT); + wrapper.write(Type.STRING, dimensionFromData(dimensionData)); }); - map(Type.STRING); // Dimension Type map(Type.STRING); // Dimension map(Type.LONG); // Seed handler(wrapper -> { @@ -68,6 +72,34 @@ public class EntityPackets1_16_2 extends EntityRewriter }); } }); + + protocol.registerOutgoing(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() { + @Override + public void registerMap() { + handler(wrapper -> { + CompoundTag dimensionData = wrapper.read(Type.NBT); + wrapper.write(Type.STRING, dimensionFromData(dimensionData)); + }); + } + }); + } + + private String dimensionFromData(CompoundTag dimensionData) { + StringTag infiniburn = dimensionData.get("infiniburn"); + if (infiniburn == null) return "minecraft:overworld"; + + // Not much we can do aside from guessing, since the data doesn't actually contain the dimension key + switch (infiniburn.getValue()) { + case "minecraft:infiniburn_nether": + return "minecraft:the_nether"; + + case "minecraft:infiniburn_end": + return "minecraft:the_end"; + + case "minecraft:infiniburn_overworld": + default: + return "minecraft:overworld"; + } } @Override