You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My mod has items that are rendered as entities. I found that if those entities have armors, their armor layer will be rendered incorrectly if the item is in hotbar, but it renders correctly when it's in inventory, hand, ground, or item frame.
I dig into it and confirmed that the problem happens on overlays only, and it only happens when the item is rendered at high Z value. I created a new overlay to test and it's reproducible. Then I try to translate pose stack -2000 in z axis and this indeed fix the issue. I suspect it's floating point underflow, but why underflow will happen around z=2000 is still unknown to me. The armor layer and the entity body are half a texture pixel apart, just like vanilla player/zombies.
My temporary fix is to translate the entire gui layer stack using code below, but I believe this is something NeoForge should address.
Demostration of the problem:
My temporary solution that fix the problem:
private static int shift = 0;
private static int count = 0;
private static boolean shifted = false, found = false;
@SubscribeEvent()
public static void onGuiRender(RenderGuiEvent.Pre event) {
count = 0;
found = false;
shifted = false;
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onGuiLayerRender(RenderGuiLayerEvent.Pre event) {
if (!shifted) {
event.getGuiGraphics().pose().translate(0, 0, -200 * shift);
shifted = true;
}
if (found) return;
if (event.getName().equals(VanillaGuiLayers.HOTBAR)) {
shift = count;
found = true;
} else {
count++;
}
}
The text was updated successfully, but these errors were encountered:
My mod has items that are rendered as entities. I found that if those entities have armors, their armor layer will be rendered incorrectly if the item is in hotbar, but it renders correctly when it's in inventory, hand, ground, or item frame.
I dig into it and confirmed that the problem happens on overlays only, and it only happens when the item is rendered at high Z value. I created a new overlay to test and it's reproducible. Then I try to translate pose stack -2000 in z axis and this indeed fix the issue. I suspect it's floating point underflow, but why underflow will happen around z=2000 is still unknown to me. The armor layer and the entity body are half a texture pixel apart, just like vanilla player/zombies.
My temporary fix is to translate the entire gui layer stack using code below, but I believe this is something NeoForge should address.
Demostration of the problem:
My temporary solution that fix the problem:
The text was updated successfully, but these errors were encountered: