diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java index 7143b25..277f5c4 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java +++ b/src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java @@ -254,7 +254,17 @@ public class Tooltips return eventResult.tooltipElements().stream().map(either -> either.map(text -> ClientTooltipComponent.create(text instanceof Component ? ((Component) text).getVisualOrderText() : Language.getInstance().getVisualOrder(text)), - ClientTooltipComponent::create)).toList(); + x -> { + // First try using the create method, for vanilla and properly-implemented tooltip components. + try { + return ClientTooltipComponent.create(x); + } + // If that fails, attempt just casting it. + catch (IllegalArgumentException e) + { + return (ClientTooltipComponent)x; + } + })).toList(); } public static Rect2i calculateRect(final ItemStack stack, PoseStack poseStack, List<ClientTooltipComponent> components, |