Skip to content

Commit

Permalink
Make querying tooltips fault-tolerant to report the mod the issue ori…
Browse files Browse the repository at this point in the history
…ginates from (#8004)

Fixes #7985
  • Loading branch information
shartte authored Jul 1, 2024
1 parent dcdbea4 commit e67cb11
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/appeng/init/client/InitStackRenderHandlers.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import com.mojang.blaze3d.vertex.PoseStack;

import org.joml.Matrix4f;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariantAttributes;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
Expand All @@ -47,6 +50,8 @@
import appeng.util.Platform;

public class InitStackRenderHandlers {
private static final Logger LOG = LoggerFactory.getLogger(InitStackRenderHandlers.class);

private InitStackRenderHandlers() {
}

Expand Down Expand Up @@ -94,9 +99,17 @@ public Component getDisplayName(AEItemKey stack) {

@Override
public List<Component> getTooltip(AEItemKey stack) {
return stack.toStack().getTooltipLines(Minecraft.getInstance().player,
Minecraft.getInstance().options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED
: TooltipFlag.Default.NORMAL);
try {
return stack.toStack().getTooltipLines(Minecraft.getInstance().player,
Minecraft.getInstance().options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED
: TooltipFlag.Default.NORMAL);
} catch (Exception e) {
LOG.error("Getting the tooltip of item {} crashed!", stack.getId(), e);
return List.of(
stack.getDisplayName(),
Component.literal(stack.getId().toString()),
Component.literal("GETTING TOOLTIP CRASHED").withStyle(ChatFormatting.RED));
}
}
}

Expand Down

0 comments on commit e67cb11

Please sign in to comment.