From a53875f331a8f9064ce3202acec4f7615670bfb1 Mon Sep 17 00:00:00 2001 From: jhqwqmc <2110242767@qq.com> Date: Mon, 21 Jul 2025 20:30:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(core):=20=E4=BC=98=E5=8C=96=E7=89=A9?= =?UTF-8?q?=E5=93=81=E9=9A=90=E8=97=8F=E5=B1=9E=E6=80=A7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../item/modifier/HideTooltipModifier.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/net/momirealms/craftengine/core/item/modifier/HideTooltipModifier.java b/core/src/main/java/net/momirealms/craftengine/core/item/modifier/HideTooltipModifier.java index 20c2bab7c..2748c84ad 100644 --- a/core/src/main/java/net/momirealms/craftengine/core/item/modifier/HideTooltipModifier.java +++ b/core/src/main/java/net/momirealms/craftengine/core/item/modifier/HideTooltipModifier.java @@ -20,6 +20,17 @@ import java.util.stream.Stream; public class HideTooltipModifier implements ItemDataModifier { public static final Map TO_LEGACY; + public static final List COMPONENTS = List.of( + ComponentKeys.UNBREAKABLE, + ComponentKeys.ENCHANTMENTS, + ComponentKeys.STORED_ENCHANTMENTS, + ComponentKeys.CAN_PLACE_ON, + ComponentKeys.CAN_BREAK, + ComponentKeys.ATTRIBUTE_MODIFIERS, + ComponentKeys.DYED_COLOR, + ComponentKeys.TRIM, + ComponentKeys.JUKEBOX_PLAYABLE + ); static { ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put(ComponentKeys.ENCHANTMENTS, 1); @@ -51,11 +62,12 @@ public class HideTooltipModifier implements ItemDataModifier { } else if (VersionHelper.isOrAbove1_20_5()) { if (components.isEmpty()) { this.applier = new DummyApplier<>(); - } else if (components.size() == 1) { + } else if (components.size() == 1 && COMPONENTS.contains(components.getFirst())) { this.applier = new SemiModernApplier<>(components.getFirst()); } else { List> appliers = new ArrayList<>(); for (Key key : components) { + if (!COMPONENTS.contains(key)) continue; appliers.add(new SemiModernApplier<>(key)); } this.applier = new CompoundApplier<>(appliers); @@ -134,10 +146,6 @@ public class HideTooltipModifier implements ItemDataModifier { if (previous instanceof CompoundTag compoundTag) { compoundTag.putBoolean("show_in_tooltip", false); item.setNBTComponent(this.component, compoundTag); - } else { - CompoundTag compoundTag = new CompoundTag(); - compoundTag.putBoolean("show_in_tooltip", false); - item.setNBTComponent(this.component, compoundTag); } } }