Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.15.2] Render Overlay blit behaving weirdly (trying to create HUD UI)

Featured Replies

Posted

Hello! I'm trying to adventure myself into minecraft modding, and now my next goal is to render a HUD bar, like a new XP bar for the user.

 

This is the current code that renders something on screen:

 

package br.com.rotstudio.phantas.util;

import com.mojang.blaze3d.systems.RenderSystem;

import br.com.rotstudio.phantas.Phantas;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
import net.minecraftforge.eventbus.api.SubscribeEvent;

@OnlyIn(value = Dist.CLIENT)
public class RenderGUIHandler{
	
	Minecraft minecraft = Minecraft.getInstance();
	
    public ResourceLocation tex;

	
	public RenderGUIHandler() {
		tex = new ResourceLocation(Phantas.MOD_ID, "textures/hud/hud.png");
	}
	
	@SubscribeEvent
	public void renderOverlay(RenderGameOverlayEvent event) {
		
		if(event.getType() == ElementType.HEALTH) {
			RenderSystem.pushMatrix();
			
	
			int posY = 16;
	        int posX = 16;
	
	
	        RenderSystem.pushTextureAttributes();
	        
	        RenderSystem.enableAlphaTest();
	        RenderSystem.enableBlend();
	        RenderSystem.color4f(1F, 1F, 1F, 1F);
	        minecraft.getTextureManager().bindTexture(tex);
	        minecraft.ingameGUI.blit(posX, posY, 0, 0, 32, 32);
	        	        
	        
	        RenderSystem.popAttributes();
			
			RenderSystem.popMatrix();
		}
		
	}

}

 

 

But when in game, it renders weirdly:

 

2020-07-11_19_00_06.thumb.png.31101131fd82e381bf6fc206819c391a.png

 

And the HUD png image looks like this:

 

hud.png.34cec7babeb1191deb8ffb786bdcb7a8.png

 

It seems its rendering some other minecraft texture atlas on top of my texture, and i have no idea why it does this

 

does anyone has any clue on what could be happening?

 

Thank you!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.