Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Items using BEWLR might be rendered incorrectly in hotbar #1553

Open
lcy0x1 opened this issue Sep 19, 2024 · 0 comments · May be fixed by #1555
Open

Items using BEWLR might be rendered incorrectly in hotbar #1553

lcy0x1 opened this issue Sep 19, 2024 · 0 comments · May be fixed by #1555
Labels
triage Needs triaging and confirmation

Comments

@lcy0x1
Copy link
Contributor

lcy0x1 commented Sep 19, 2024

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:
Screenshot_2024-09-18_at_02 51 42
Screenshot_2024-09-18_at_02 51 56

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++;
		}
	}

@lcy0x1 lcy0x1 added the triage Needs triaging and confirmation label Sep 19, 2024
@neoforged neoforged deleted a comment Sep 19, 2024
lcy0x1 added a commit to Minecraft-LightLand/NeoForge that referenced this issue Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs triaging and confirmation
Projects
None yet
1 participant