From ebff5e2f4d5d97e4565eb7e6bdbd9a33289eaf8b Mon Sep 17 00:00:00 2001 From: KennyTV Date: Fri, 3 Apr 2020 19:57:07 +0200 Subject: [PATCH] Adapt tagdata loading --- .../Protocol1_15To1_14_4.java | 17 ++++++++------ .../Protocol1_16To1_15_2.java | 23 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java index b6be3ce3d..88078cd08 100644 --- a/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java +++ b/common/src/main/java/us/myles/ViaVersion/protocols/protocol1_15to1_14_4/Protocol1_15To1_14_4.java @@ -21,6 +21,8 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; public class Protocol1_15To1_14_4 extends Protocol { + private TagRewriter tagRewriter; + public Protocol1_15To1_14_4() { super(true); } @@ -118,13 +120,7 @@ public class Protocol1_15To1_14_4 extends Protocol { }); // Tags - TagRewriter tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId); - int[] shulkerBoxes = new int[17]; - int shulkerBoxOffset = 501; - for (int i = 0; i < 17; i++) { - shulkerBoxes[i] = shulkerBoxOffset + i; - } - tagRewriter.addTag(TagType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes); + tagRewriter = new TagRewriter(this, Protocol1_15To1_14_4::getNewBlockId, InventoryPackets::getNewItemId, EntityPackets::getNewEntityId); tagRewriter.register(0x5B, 0x5C); registerOutgoing(State.PLAY, 0x08, 0x09); @@ -209,6 +205,13 @@ public class Protocol1_15To1_14_4 extends Protocol { @Override protected void loadMappingData() { MappingData.init(); + + int[] shulkerBoxes = new int[17]; + int shulkerBoxOffset = 501; + for (int i = 0; i < 17; i++) { + shulkerBoxes[i] = shulkerBoxOffset + i; + } + tagRewriter.addTag(TagType.BLOCK, "minecraft:shulker_boxes", shulkerBoxes); } public static int getNewBlockStateId(int id) { 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 772a0d4be..29efabbaf 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 @@ -20,6 +20,8 @@ import java.util.UUID; public class Protocol1_16To1_15_2 extends Protocol { + private TagRewriter tagRewriter; + public Protocol1_16To1_15_2() { super(true); } @@ -32,16 +34,7 @@ public class Protocol1_16To1_15_2 extends Protocol { WorldPackets.register(this); InventoryPackets.register(this); - TagRewriter tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId); - tagRewriter.addTag(TagType.BLOCK, "minecraft:beacon_base_blocks", 133, 134, 148, 265); - tagRewriter.addTag(TagType.BLOCK, "minecraft:climbable", 160, 241, 658); - tagRewriter.addTag(TagType.BLOCK, "minecraft:fire", 142); - tagRewriter.addTag(TagType.ITEM, "minecraft:beacon_payment_items", 529, 530, 531, 760); - // The client crashes if we don't send all tags it may use - tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:soul_speed_blocks"); - tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:soul_fire_base_blocks"); - tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:non_flammable_wood"); - tagRewriter.addEmptyTag(TagType.ITEM, "minecraft:non_flammable_wood"); + tagRewriter = new TagRewriter(this, Protocol1_16To1_15_2::getNewBlockId, InventoryPackets::getNewItemId, metadataRewriter::getNewEntityId); tagRewriter.register(0x5C, 0x5C); // Login Success @@ -138,6 +131,16 @@ public class Protocol1_16To1_15_2 extends Protocol { @Override protected void loadMappingData() { MappingData.init(); + + tagRewriter.addTag(TagType.BLOCK, "minecraft:beacon_base_blocks", 133, 134, 148, 265); + tagRewriter.addTag(TagType.BLOCK, "minecraft:climbable", 160, 241, 658); + tagRewriter.addTag(TagType.BLOCK, "minecraft:fire", 142); + tagRewriter.addTag(TagType.ITEM, "minecraft:beacon_payment_items", 529, 530, 531, 760); + // The client crashes if we don't send all tags it may use + tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:soul_speed_blocks"); + tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:soul_fire_base_blocks"); + tagRewriter.addEmptyTag(TagType.BLOCK, "minecraft:non_flammable_wood"); + tagRewriter.addEmptyTag(TagType.ITEM, "minecraft:non_flammable_wood"); } public static int getNewBlockStateId(int id) {