Skip to content

Commit be88e05

Browse files
authored
Fix crash with unknown tooltip components (Meteor Compat) (#297)
# Fix crash with unknown tooltip components (Meteor Compat) Fixes the crash reported in [this thread](https://discord.com/channels/834570721070022687/1508546671624065164/1508547813511004371) in the Lambda support Discord. When Lambda encounters an unknown instance of TooltipData it mimics the vanilla logic of throwing an IllegalArgumentException. This is unnecessary and causes crashes when paired with mods like Meteor that create their own classes which implement the TooltipData interface. This PR fixes that by ignoring unknown implementers instead of throwing on them, allowing the other mods' mixins to handle their implementers properly and avoiding crashes altogether. ### Issue Link https://discord.com/channels/834570721070022687/1508546671624065164/1508547813511004371
1 parent b34c92e commit be88e05

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/com/lambda/mixin/render/TooltipComponentMixin.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ private static void of(TooltipData tooltipData, CallbackInfoReturnable<TooltipCo
3838
return;
3939
}
4040

41-
if (MapPreview.INSTANCE.isEnabled()) cir.setReturnValue((switch (tooltipData) {
42-
case MapPreview.MapComponent mapComponent -> mapComponent;
43-
case BundleTooltipData bundleTooltipData -> new BundleTooltipComponent(bundleTooltipData.contents());
44-
case ProfilesTooltipComponent.ProfilesData profilesData -> new ProfilesTooltipComponent(profilesData);
45-
default -> throw new IllegalArgumentException("Unknown TooltipComponent");
46-
}));
41+
if (MapPreview.INSTANCE.isEnabled()) switch (tooltipData) {
42+
case MapPreview.MapComponent mapComponent -> cir.setReturnValue(mapComponent);
43+
case BundleTooltipData bundleTooltipData -> cir.setReturnValue(new BundleTooltipComponent(bundleTooltipData.contents()));
44+
case ProfilesTooltipComponent.ProfilesData profilesData -> cir.setReturnValue(new ProfilesTooltipComponent(profilesData));
45+
default -> {} // ignore
46+
}
4747
}
4848
}

0 commit comments

Comments
 (0)