[1.16.5 forge]: Mods that move effects icons mess with your rendering.
mysticdrew opened this issue ยท 8 comments
My suggestion to fix.
Your effect timer should be on the potion should be on the element RenderGameOverlayEvent.ElementType.POTION_ICONS.
However, the other icons and text should not be in my opinion as they are not related to potion effects. I would think HOTBAR would be ideal for that rendering.
I was able to fix the armor/gear rendering by setting my rendering to highest priority, but then the timer on the potion effect gets moved also.
These images are from an unreleased version of Journeymap, I switched from a coremod to using the OverlayEvent and one of my testers let me know about this issue. With how you handle the rendering there really is not a work around for this issue.
The way I handle moving the effects icons is by translate the matrixstack.
I did not test in 1.17.1 yet, but it likely has the same issue.
Yes, you're right about that. I already split the rendering into two parts in the Fabric version, not sure why I didn't for Forge. Splitting them obviously makes sense.
For 1.17, when made the Forge version of the mod (Forge 37.0.13), the only element types that where supported were ALL, LAYER, BOSSINFO, TEXT, CHAT, PLAYER_LIST, DEBUG
, so I moved the rendering to CHAT. Let's see if newer versions have POTION_EFFECTS and HOTBAR exist again.
Hm, something is very wrong here? The newest version for 1.17.1 seems to be 1.17.1 - 37.0.73 according to https://files.minecraftforge.net/net/minecraftforge/forge/. But that one has neither POTION_ICONS_ELEMENT nor HOTBAR_ELEMENT, and (to make sure I'm not using an older version), checking the jar (forge-1.17.1-37.0.73-universal.jar)
yields
net/minecraftforge/client/event/RenderGameOverlayEvent$BossInfo.class
net/minecraftforge/client/event/RenderGameOverlayEvent$Chat.class
net/minecraftforge/client/event/RenderGameOverlayEvent$ElementType.class
net/minecraftforge/client/event/RenderGameOverlayEvent$Post.class
net/minecraftforge/client/event/RenderGameOverlayEvent$PostLayer.class
net/minecraftforge/client/event/RenderGameOverlayEvent$Pre.class
net/minecraftforge/client/event/RenderGameOverlayEvent$PreLayer.class
net/minecraftforge/client/event/RenderGameOverlayEvent$Text.class
net/minecraftforge/client/event/RenderGameOverlayEvent.class
so where do you get those two events from?
RenderGameOverlayEvent.PreLayer
and RenderGameOverlayEvent.PostLayer
has getOverlay()
which is where those come from.
This is my class for modifying the potion effects.
public class HudOverlayHandler implements EventHandlerManager.EventHandler
{
private boolean shouldPop = false;
@SubscribeEvent(priority = EventPriority.LOWEST)
public void preOverlay(RenderGameOverlayEvent.PreLayer event)
{
if (event.getOverlay() == ForgeIngameGui.POTION_ICONS_ELEMENT && !Minecraft.getInstance().options.hideGui)
{
PoseStack stack = event.getMatrixStack();
int minimapWidth = UIManager.INSTANCE.getMiniMap().getDisplayVars().minimapWidth;
int marginX = UIManager.INSTANCE.getMiniMap().getDisplayVars().marginX;
stack.pushPose();
stack.translate(-(((minimapWidth / 4) + marginX) * 2), 0, 0);
shouldPop = true;
}
}
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void preOverlay(RenderGameOverlayEvent.Pre event)
{
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL)
{
shouldPop = false;
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void postOverlay(RenderGameOverlayEvent.PostLayer event)
{
if (event.getOverlay() == ForgeIngameGui.POTION_ICONS_ELEMENT
&& shouldPop
&& EventPriority.HIGHEST.equals(event.getPhase()))
{
event.getMatrixStack().popPose();
shouldPop = false;
}
}
}
Ah, so I need to move my .Post
events to .PostLayer
events, and use getOverlay()
instead of getType()
to find what's being rendered. Thanks, you saved me a lot of searching!
I just released a 1.10.1 version to github (https://github.com/gbl/DurabilityViewer/releases/tag/1.16.4-1.10.1). Could you do a quick check if that one works for you?
The corresponding commit is 40e4dcc on the forge_1_16_2 branch if you want to check it out.