Skip to content

Commit

Permalink
Tooltip Seems to work now.
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Dec 18, 2024
1 parent cf065c2 commit 454a20a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/fi/dy/masa/malilib/render/InventoryOverlay.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

import fi.dy.masa.malilib.MaLiLibReference;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.mixin.IMixinAbstractHorseEntity;
import fi.dy.masa.malilib.mixin.IMixinPiglinEntity;
Expand Down Expand Up @@ -1030,8 +1031,6 @@ public static void renderStackAt(ItemStack stack, float x, float y, float scale,
RenderUtils.color(1f, 1f, 1f, 1f);
matrixStack.pop();

System.out.printf("renderStackAt(): [%s]\n", stack.toNbt(WorldUtils.getBestWorld(GameWrap.getClient()).getRegistryManager()).toString());

if (mouseX >= x && mouseX < x + 16 * scale && mouseY >= y && mouseY < y + 16 * scale)
{
hoveredStack = stack.copy();
Expand Down Expand Up @@ -1114,7 +1113,10 @@ public static void renderStackToolTip(int x, int y, ItemStack stack, MinecraftCl
List<Text> list = stack.getTooltip(Item.TooltipContext.create(mc.world), mc.player, mc.options.advancedItemTooltips ? TooltipType.ADVANCED : TooltipType.BASIC);
List<String> lines = new ArrayList<>();

dumpStack(stack, list);
if (MaLiLibReference.DEBUG_MODE)
{
dumpStack(stack, list);
}
for (int i = 0; i < list.size(); ++i)
{
if (i == 0)
Expand Down Expand Up @@ -1143,8 +1145,14 @@ public static void renderStackToolTipStyled(int x, int y, ItemStack stack, Minec
{
if (stack.isEmpty() == false && mc.world != null && mc.player != null)
{
// Not sure why getBestWorld() is required here,
// it's also required when connected to a server;
// or else not be able to see Enchantment tooltips. (>.>)
List<Text> toolTips = stack.getTooltip(Item.TooltipContext.create(WorldUtils.getBestWorld(mc)), mc.player, mc.options.advancedItemTooltips ? TooltipType.ADVANCED : TooltipType.BASIC);
dumpStack(stack, toolTips);
if (MaLiLibReference.DEBUG_MODE)
{
dumpStack(stack, toolTips);
}
drawContext.drawTooltip(mc.textRenderer,
toolTips,
stack.getTooltipData(), // Bundle/Optional Data
Expand Down

0 comments on commit 454a20a

Please sign in to comment.