aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Hilyard <anthony.hilyard@gmail.com>2022-01-06 09:00:23 -0800
committerAnthony Hilyard <anthony.hilyard@gmail.com>2022-01-06 09:00:23 -0800
commit2f42181876880c5a88de8b8fb29d9be84c3e0424 (patch)
tree8f00360424683557c88cacb4b82d5a9781a30657 /src
parentf8c05d3ed6f96393f34f4ab661e99d3083f893b6 (diff)
downloadIceberg-2f42181876880c5a88de8b8fb29d9be84c3e0424.tar.gz
Iceberg-2f42181876880c5a88de8b8fb29d9be84c3e0424.tar.bz2
Iceberg-2f42181876880c5a88de8b8fb29d9be84c3e0424.zip
Fixed crash issue with modded tooltip components that aren't added to
factory.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java12
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,