From 75fddd0fb908d5d156ea66f64c93b0f29893e316 Mon Sep 17 00:00:00 2001 From: EnZaXD <60033407+FlorianMichael@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:32:13 +0100 Subject: [PATCH] Allow platforms to disable dummy enchantment in LegacyEnchantmentRewriter (#710) --- .../api/rewriters/LegacyEnchantmentRewriter.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java index aa682324..78a85b12 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/rewriters/LegacyEnchantmentRewriter.java @@ -36,10 +36,17 @@ public class LegacyEnchantmentRewriter { private final Map enchantmentMappings = new HashMap<>(); private final String nbtTagName; + private final boolean dummyEnchantment; + private Set hideLevelForEnchants; public LegacyEnchantmentRewriter(String nbtTagName) { + this(nbtTagName, true); + } + + public LegacyEnchantmentRewriter(String nbtTagName, boolean dummyEnchantment) { this.nbtTagName = nbtTagName; + this.dummyEnchantment = dummyEnchantment; } public void registerEnchantment(int id, String replacementLore) { @@ -94,12 +101,12 @@ public class LegacyEnchantmentRewriter { } } if (!lore.isEmpty()) { - if (!storedEnchant && enchantments.isEmpty()) { + if (this.dummyEnchantment && !storedEnchant && enchantments.isEmpty()) { CompoundTag dummyEnchantment = new CompoundTag(); dummyEnchantment.putShort("id", (short) 0); dummyEnchantment.putShort("lvl", (short) 0); - enchantments.add(dummyEnchantment); + enchantments.add(dummyEnchantment); tag.put(nbtTagName + "|dummyEnchant", new ByteTag()); NumberTag hideFlags = tag.getNumberTag("HideFlags");