From 88a1a4262533724ae09ac60b658e1d0283884918 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Thu, 5 Nov 2020 17:22:39 +0100 Subject: [PATCH] Finish update Still unsure whether we also have to store block entity data and if/which respawn conditions have to be checked for biome uncaching --- .../api/protocol/ProtocolPipeline.java | 2 +- .../Protocol1_17To1_16_4.java | 9 ++- .../packets/WorldPackets.java | 28 ++++++++- .../storage/BiomeStorage.java | 34 ++++++++++ .../data/mappingdiff-1.16.2to1.17.json | 63 +++++++++++++++++-- 5 files changed, 125 insertions(+), 11 deletions(-) create mode 100644 common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/storage/BiomeStorage.java diff --git a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java index 01bf4286d..8e4473599 100644 --- a/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java +++ b/common/src/main/java/us/myles/ViaVersion/api/protocol/ProtocolPipeline.java @@ -75,7 +75,7 @@ public class ProtocolPipeline extends SimpleProtocol { packetWrapper.apply(direction, state, 0, protocolList, direction == Direction.OUTGOING); super.transform(direction, state, packetWrapper); - if (Via.getManager().isDebug()) { // 26 52 76 + if (Via.getManager().isDebug()) { logPacket(direction, state, packetWrapper, originalID); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java index 74e182362..25bc63aa9 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/Protocol1_17To1_16_4.java @@ -2,6 +2,7 @@ package us.myles.ViaVersion.protocols.protocol1_17to1_16_4; import org.jetbrains.annotations.Nullable; import us.myles.ViaVersion.api.data.MappingData; +import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.rewriters.RegistryType; @@ -13,10 +14,11 @@ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_ import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.InventoryPackets; import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.packets.WorldPackets; +import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage.BiomeStorage; public class Protocol1_17To1_16_4 extends Protocol { - public static final MappingData MAPPINGS = new MappingData("1.16.2", "1.17"); + public static final MappingData MAPPINGS = new MappingData("1.16.2", "1.17", true); private TagRewriter tagRewriter; public Protocol1_17To1_16_4() { @@ -56,6 +58,11 @@ public class Protocol1_17To1_16_4 extends Protocol { + int x = wrapper.passthrough(Type.INT); + int z = wrapper.passthrough(Type.INT); + wrapper.user().get(BiomeStorage.class).clearBiomes(x, z); + }); + } + }); + blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001); } } diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/storage/BiomeStorage.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/storage/BiomeStorage.java new file mode 100644 index 000000000..2ce38a8c4 --- /dev/null +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_17to1_16_4/storage/BiomeStorage.java @@ -0,0 +1,34 @@ +package us.myles.ViaVersion.protocols.protocol1_17to1_16_4.storage; + +import org.jetbrains.annotations.Nullable; +import us.myles.ViaVersion.api.data.StoredObject; +import us.myles.ViaVersion.api.data.UserConnection; + +import java.util.HashMap; +import java.util.Map; + +public class BiomeStorage extends StoredObject { + + private final Map chunkBiomes = new HashMap<>(); + + public BiomeStorage(UserConnection user) { + super(user); + } + + @Nullable + public int[] getBiomes(int x, int z) { + return chunkBiomes.get(getChunkSectionIndex(x, z)); + } + + public void setBiomes(int x, int z, int[] biomes) { + chunkBiomes.put(getChunkSectionIndex(x, z), biomes); + } + + public void clearBiomes(int x, int z) { + chunkBiomes.remove(getChunkSectionIndex(x, z)); + } + + private long getChunkSectionIndex(int x, int z) { + return ((x & 0x3FFFFFFL) << 38) | (z & 0x3FFFFFFL); + } +} diff --git a/common/src/main/resources/assets/viaversion/data/mappingdiff-1.16.2to1.17.json b/common/src/main/resources/assets/viaversion/data/mappingdiff-1.16.2to1.17.json index ae013c97b..fd030bf58 100644 --- a/common/src/main/resources/assets/viaversion/data/mappingdiff-1.16.2to1.17.json +++ b/common/src/main/resources/assets/viaversion/data/mappingdiff-1.16.2to1.17.json @@ -1,10 +1,61 @@ { + "blocks": { + "498": "dirt_path" + }, "blockstates": { - "4729": "minecraft:chain[axis=y,waterlogged=true]", - "4730": "minecraft:chain[axis=y,waterlogged=false]", - "14886": "minecraft:lantern[hanging=true,waterlogged=false]", - "14887": "minecraft:lantern[hanging=false,waterlogged=false]", - "14888": "minecraft:soul_lantern[hanging=true,waterlogged=false]", - "14889": "minecraft:soul_lantern[hanging=false,waterlogged=false]" + "1305": "minecraft:powered_rail[powered=true,shape=north_south,waterlogged=false]", + "1306": "minecraft:powered_rail[powered=true,shape=east_west,waterlogged=false]", + "1307": "minecraft:powered_rail[powered=true,shape=ascending_east,waterlogged=false]", + "1308": "minecraft:powered_rail[powered=true,shape=ascending_west,waterlogged=false]", + "1309": "minecraft:powered_rail[powered=true,shape=ascending_north,waterlogged=false]", + "1310": "minecraft:powered_rail[powered=true,shape=ascending_south,waterlogged=false]", + "1311": "minecraft:powered_rail[powered=false,shape=north_south,waterlogged=false]", + "1312": "minecraft:powered_rail[powered=false,shape=east_west,waterlogged=false]", + "1313": "minecraft:powered_rail[powered=false,shape=ascending_east,waterlogged=false]", + "1314": "minecraft:powered_rail[powered=false,shape=ascending_west,waterlogged=false]", + "1315": "minecraft:powered_rail[powered=false,shape=ascending_north,waterlogged=false]", + "1316": "minecraft:powered_rail[powered=false,shape=ascending_south,waterlogged=false]", + "1317": "minecraft:detector_rail[powered=true,shape=north_south,waterlogged=false]", + "1318": "minecraft:detector_rail[powered=true,shape=east_west,waterlogged=false]", + "1319": "minecraft:detector_rail[powered=true,shape=ascending_east,waterlogged=false]", + "1320": "minecraft:detector_rail[powered=true,shape=ascending_west,waterlogged=false]", + "1321": "minecraft:detector_rail[powered=true,shape=ascending_north,waterlogged=false]", + "1322": "minecraft:detector_rail[powered=true,shape=ascending_south,waterlogged=false]", + "1323": "minecraft:detector_rail[powered=false,shape=north_south,waterlogged=false]", + "1324": "minecraft:detector_rail[powered=false,shape=east_west,waterlogged=false]", + "1325": "minecraft:detector_rail[powered=false,shape=ascending_east,waterlogged=false]", + "1326": "minecraft:detector_rail[powered=false,shape=ascending_west,waterlogged=false]", + "1327": "minecraft:detector_rail[powered=false,shape=ascending_north,waterlogged=false]", + "1328": "minecraft:detector_rail[powered=false,shape=ascending_south,waterlogged=false]", + "3645": "minecraft:rail[shape=north_south,waterlogged=false]", + "3646": "minecraft:rail[shape=east_west,waterlogged=false]", + "3647": "minecraft:rail[shape=ascending_east,waterlogged=false]", + "3648": "minecraft:rail[shape=ascending_west,waterlogged=false]", + "3649": "minecraft:rail[shape=ascending_north,waterlogged=false]", + "3650": "minecraft:rail[shape=ascending_south,waterlogged=false]", + "3651": "minecraft:rail[shape=south_east,waterlogged=false]", + "3652": "minecraft:rail[shape=south_west,waterlogged=false]", + "3653": "minecraft:rail[shape=north_west,waterlogged=false]", + "3654": "minecraft:rail[shape=north_east,waterlogged=false]", + "6827": "minecraft:activator_rail[powered=true,shape=north_south,waterlogged=false]", + "6828": "minecraft:activator_rail[powered=true,shape=east_west,waterlogged=false]", + "6829": "minecraft:activator_rail[powered=true,shape=ascending_east,waterlogged=false]", + "6830": "minecraft:activator_rail[powered=true,shape=ascending_west,waterlogged=false]", + "6831": "minecraft:activator_rail[powered=true,shape=ascending_north,waterlogged=false]", + "6832": "minecraft:activator_rail[powered=true,shape=ascending_south,waterlogged=false]", + "6833": "minecraft:activator_rail[powered=false,shape=north_south,waterlogged=false]", + "6834": "minecraft:activator_rail[powered=false,shape=east_west,waterlogged=false]", + "6835": "minecraft:activator_rail[powered=false,shape=ascending_east,waterlogged=false]", + "6836": "minecraft:activator_rail[powered=false,shape=ascending_west,waterlogged=false]", + "6837": "minecraft:activator_rail[powered=false,shape=ascending_north,waterlogged=false]", + "6838": "minecraft:activator_rail[powered=false,shape=ascending_south,waterlogged=false]", + "5145": "minecraft:cauldron", + "5146": "minecraft:water_cauldron[level=1]", + "5147": "minecraft:water_cauldron[level=2]", + "5148": "minecraft:water_cauldron[level=3]", + "9227": "minecraft:dirt_path" + }, + "items": { + "372": "minecraft:dirt_path" } } \ No newline at end of file