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..4b56b6b74 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); @@ -52,13 +63,24 @@ public class HideTooltipModifier implements ItemDataModifier { if (components.isEmpty()) { this.applier = new DummyApplier<>(); } else if (components.size() == 1) { - this.applier = new SemiModernApplier<>(components.getFirst()); + if (COMPONENTS.contains(components.getFirst())) { + this.applier = new SemiModernApplier<>(components.getFirst()); + } else { + this.applier = new DummyApplier<>(); + } } else { List> appliers = new ArrayList<>(); for (Key key : components) { + if (!COMPONENTS.contains(key)) continue; appliers.add(new SemiModernApplier<>(key)); } - this.applier = new CompoundApplier<>(appliers); + if (appliers.isEmpty()) { + this.applier = new DummyApplier<>(); + } else if (appliers.size() == 1) { + this.applier = appliers.getFirst(); + } else { + this.applier = new CompoundApplier<>(appliers); + } } } else { this.applier = new LegacyApplier<>(components); @@ -134,10 +156,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); } } }