From 2f42181876880c5a88de8b8fb29d9be84c3e0424 Mon Sep 17 00:00:00 2001 From: Anthony Hilyard Date: Thu, 6 Jan 2022 09:00:23 -0800 Subject: Fixed crash issue with modded tooltip components that aren't added to factory. --- CHANGELOG.md | 3 +++ gradle.properties | 2 +- src/main/java/com/anthonyhilyard/iceberg/util/Tooltips.java | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe4906c..f72768f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 1.0.36 +- Fixed a crash issue with modded tooltip components that are not properly added to tooltip component factory. + ### 1.0.35 - Fixed an issue that could cause dependent client-side mods to crash when run on a dedicated server. - Fixed various warnings in latest.log file. diff --git a/gradle.properties b/gradle.properties index a657a8b..bf52eb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=false name=${rootProject.name} group=com.anthonyhilyard.${name.toLowerCase()} author=anthonyhilyard -version=1.0.35 +version=1.0.36 mcVersion=1.18.1 fabricVersion=0.45.0+1.18 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 components, -- cgit