[Bug] No Food Info on REI Tooltip
MorningSage opened this issue ยท 9 comments
Describe the bug
When AppleSkin and REI are being used in a Forge Mod Pack, the food info does not display at all when hovering over the food item in REI. The info appears correctly in the inventory and creative menu, just not in the REI tooltip. The space for it, however, is there.
Steps to Reproduce
- Search for any food item in REI
- Hover over the food item to display the tooltip
- Observe that the tooltip is sized correctly to display the food stats, but nothing is rendered.
Screenshots
https://files.catbox.moe/tq8929.png
Environment:
- Minecraft (1.16.5)
- Forge (36.1.31)
- REI (6.0.0.232-alpha)
- Architectury (1.17.22)
- Cloth Config (4.11.26)
- AppleSkin (mc1.16.4-2.0.0)
Logs
https://gist.github.com/MorningSage/0421c0f55e2d786ad85178a2c1ad6d22
Chances are this is a Z level issue.
Related stuff:
- 4e6bfba (Forge branch commit that sets the Z level to 400)
- #84 (the issue that the above commit was intending to fix)
- b2ed069 (Fabric branch commit that stopped setting the Z level to 500 to fix this same issue in Fabric, more context: #89 (comment))
In JEI 0 level is too low
In REI 400 level is too high
Maybe we should keep it at 0 level and let JEI fix the problem
REI Forge and REI Fabric are some rendering method
public abstract class Screen {
...
// Forge hooked render event
protected void renderTooltip(MatrixStack matrixStack, ItemStack itemStack, int mouseX, int mouseY) {
FontRenderer font = itemStack.getItem().getFontRenderer(itemStack);
net.minecraftforge.fml.client.gui.GuiUtils.preItemToolTip(itemStack);
this.renderWrappedToolTip(matrixStack, this.getTooltipFromItem(itemStack), mouseX, mouseY, (font == null ? this.font : font));
net.minecraftforge.fml.client.gui.GuiUtils.postItemToolTip();
}
...
public void renderWrappedToolTip(MatrixStack matrixStack, List<? extends net.minecraft.util.text.ITextProperties> tooltips, int mouseX, int mouseY, FontRenderer font) {
net.minecraftforge.fml.client.gui.GuiUtils.drawHoveringText(matrixStack, tooltips, mouseX, mouseY, width, height, -1, font);
}
...
// REI called render event
public void renderTooltip(MatrixStack matrixStack, List<? extends IReorderingProcessor> tooltips, int mouseX, int mouseY) {
this.renderToolTip(matrixStack, tooltips, mouseX, mouseY, font);
}
...
}
Unfortunately forge does not hooking this rendering calls. so no RenderTooltipEvent
call, but have ItemTooltipEvent
call.
Solution:
- Replace REI with JEI
- REI replace to Screen.renderWrappedTooltip
- We minix Screen.renderTooltip
Ah, okay, yes, the problem is that REI's tooltips don't trigger Forge's RenderTooltipEvent.PostText
event because the renderTooltip
method they call bypasses Forge's hook.
I'd consider this an REI bug, and it probably should be fixed on their end rather than ours (since it will affect all mods that rely on RenderTooltipEvent
, not just AppleSkin).
Will file a bug in REI's issue tracker.
As for the Z level problem (if it actually is a problem once the RenderTooltipEvent is fixed), it might be possible to do something like this:
matrixStack.push();
- matrixStack.translate(0.0D, 0.0D, toolTipZ);
+ matrixStack.getLast().getMatrix().setTranslation(0.0F, 0.0F, toolTipZ);
That way it always sets it to the same Z level for rendering AppleSkin's stuff, regardless of what it was previously.
Or maybe something like:
Matrix4f identityMatrix = Matrix4f.makeTranslate(0.0F, 0.0F, 0.0F);
boolean shouldTranslate = matrixStack.getLast().getMatrix().equals(identityMatrix);
matrixStack.push();
if (shouldTranslate)
matrixStack.translate(0.0D, 0.0D, toolTipZ);
(both are untested)
I made a mistake, hardcode 400d written by the developer of forge, it has nothing to do with jei.
I did do some test:
- when z level is below 400d, the text does not display correctly (icon is normal) in vanilla tooltip and JEI
- when z level is 900d (400d + REI 500d) is normal, so we just need to wait for REI to fix to close this issue