From 8314f6c1dbb8b57987c919962a7888fcab9a7e0f Mon Sep 17 00:00:00 2001 From: KennyTV Date: Fri, 3 Apr 2020 00:03:21 +0200 Subject: [PATCH] Send empty non_flammable_wood itemtag as well --- .../ViaVersion/api/rewriters/TagRewriter.java | 25 ++++++++++++++----- .../Protocol1_16To1_15_2.java | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) 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 2a2f87754..23b81e735 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 @@ -16,7 +16,8 @@ public class TagRewriter { private final IdRewriteFunction itemRewriter; private final IdRewriteFunction entityRewriter; private final List newBlockTags = new ArrayList<>(); - // add item, fluid, or entity tag lists if needed at some point + private final List newItemTags = new ArrayList<>(); + // add fluid or entity tag lists if needed at some point public TagRewriter(Protocol protocol, IdRewriteFunction blockRewriter, IdRewriteFunction itemRewriter, IdRewriteFunction entityRewriter) { this.protocol = protocol; @@ -29,12 +30,24 @@ public class TagRewriter { newBlockTags.add(new TagData(id, EMPTY_ARRAY)); } + public void addEmptyItemTag(String id) { + newItemTags.add(new TagData(id, EMPTY_ARRAY)); + } + public void addBlockTag(String id, int... oldBlockIds) { - for (int i = 0; i < oldBlockIds.length; i++) { - int oldBlockId = oldBlockIds[i]; - oldBlockIds[i] = blockRewriter.rewrite(oldBlockId); + addTag(newBlockTags, blockRewriter, id, oldBlockIds); + } + + public void addItemTag(String id, int... oldItemIds) { + addTag(newItemTags, itemRewriter, id, oldItemIds); + } + + private void addTag(List list, IdRewriteFunction rewriteFunction, String id, int... oldIds) { + for (int i = 0; i < oldIds.length; i++) { + int oldId = oldIds[i]; + oldIds[i] = rewriteFunction.rewrite(oldId); } - newBlockTags.add(new TagData(id, oldBlockIds)); + list.add(new TagData(id, oldIds)); } public void register(int oldId, int newId) { @@ -43,7 +56,7 @@ public class TagRewriter { public void registerMap() { handler(wrapper -> { handle(wrapper, blockRewriter, newBlockTags); - handle(wrapper, itemRewriter, null); + handle(wrapper, itemRewriter, newItemTags); if (entityRewriter == null) return; 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 0457c8a68..fa9c17240 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 @@ -37,6 +37,7 @@ public class Protocol1_16To1_15_2 extends Protocol { tagRewriter.addEmptyBlockTag("minecraft:fire"); tagRewriter.addEmptyBlockTag("minecraft:beacon_payment_items"); tagRewriter.addEmptyBlockTag("minecraft:non_flammable_wood"); + tagRewriter.addEmptyItemTag("minecraft:non_flammable_wood"); tagRewriter.register(0x5C, 0x5C); // Login Success