Fix crash when hovering stacks in the trait dex

This commit is contained in:
Sollace 2024-10-06 19:30:47 +01:00
parent e9728ec0f7
commit fad0e207a0
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -25,8 +25,12 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
public class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
private static final List<Text> EMPTY_LINES = List.of(ScreenTexts.EMPTY);
private static final Tooltip EMPTY_TOOLTIP = Tooltip.of(EMPTY_LINES);
private final List<IngredientTree.Entry> entries = new ArrayList<>();
private Optional<IngredientTree.Entry> result = Optional.empty();
@ -188,7 +192,7 @@ public class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
@Override
public Tooltip getTooltip() {
return List::of;
return EMPTY_TOOLTIP;
}
};
@ -251,7 +255,7 @@ public class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
public Tooltip getTooltip() {
return () -> {
if (stack.isEmpty()) {
return List.of();
return EMPTY_LINES;
}
return stack.getTooltip(Item.TooltipContext.create(MinecraftClient.getInstance().world), MinecraftClient.getInstance().player, TooltipType.BASIC);
};
@ -301,7 +305,7 @@ public class IngredientTree implements SpellbookRecipe.CraftingTreeBuilder {
@Override
public Tooltip getTooltip() {
return List::of;
return EMPTY_TOOLTIP;
}
}