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.

Featured Replies

Posted

Hey guys

 

I have created a gui handler to add my gui objects to the ingame gui..

 

However, only my items show, and the hunger bars etc... don't show up, and is just blue things on the screen...

 

Here is my code:

 

package net.madcrazydrumma;

import java.util.Calendar;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.event.EventPriority;
import net.minecraftforge.event.ForgeSubscribe;

import org.lwjgl.Sys;
import org.lwjgl.opengl.GL11;

public class GuiHandler extends Gui
{
private Minecraft mc = Minecraft.getMinecraft();

public GuiHandler() {
}
    
    public void drawBRect(int x1, int y1, int x2, int y2, int clr){
        drawHorizontalLine(x1, x2, y1, 0x00ff);
        drawHorizontalLine(x1, x2, y2, 0x00ff);
        drawVerticalLine(x1, y1, y2, 0x00ff);
        drawVerticalLine(x2, y1, y2, 0x00ff);
        drawRect(x1 + 1, y1 + 1, x2, y2, clr);
    }
    
    @ForgeSubscribe(priority = EventPriority.NORMAL)
    public void renderIngameGUI(RenderGameOverlayEvent event) {
    	
    	//Skill Icons
    	GL11.glPushMatrix();
    	
    	ResourceLocation icons = new ResourceLocation("minecraft", "overhaul/textures/gui/icons.png");
    	
    	drawBRect(20, 20, 30, 30, 0x00ffff);
    	
    	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    	mc.renderEngine.func_110577_a(icons);
        drawTexturedModalRect(380, 60, 0, 0, 16, 16); //swords
        drawTexturedModalRect(380, 80, 16, 0, 16, 16); //bow
        drawTexturedModalRect(380, 100, 33, 0, 16, 16); //woodcutting
        drawTexturedModalRect(380, 120, 48, 0, 16, 16); //farming
        
        drawCenteredString(mc.fontRenderer, "" + mc.thePlayer.getExtendedProperties("skills"), 410, 64, 0xfffff);
        drawCenteredString(mc.fontRenderer, "" + mc.thePlayer.getExtendedProperties("skills"), 410, 84, 0xfffff);
        drawCenteredString(mc.fontRenderer, "" + mc.thePlayer.getExtendedProperties("skills"), 410, 104, 0xfffff);
        drawCenteredString(mc.fontRenderer, "" + mc.thePlayer.getExtendedProperties("skills"), 410, 124, 0xfffff);
    	GL11.glPopMatrix();
    	//Skill Icons End
    	
    	// Clock --> //drawString(mc.fontRenderer, "" + Calendar.getInstance().getTime(), 2, 12, 0x00ffff);
    }
}

Use RenderGameOverlayEvent.Pre or RenderGameOverlayEvent.Post.

Reset the texture after you have done your work.

Default Gui texture is in Gui class as an obfuscated field.

Use mc.renderEngine.func_110577_a(Gui.field_xxx);

  • Author

Also,

 

Why isn't my rectangle being drawn?

 

drawBorderedRect(width / 2 - 16, 0, width / 2 + 8, 20, 2, 0xffffff, 0x000000);

 

Im using this method:

 

public void drawBorderedRect(int x, int y, int x1, int y1, int size, int borderC, int insideC) {
        drawVerticalLine(x, y, y1 -1, borderC);
        drawVerticalLine(x1 - 1, y, y1 - 1, borderC);
        drawHorizontalLine(x, x1 - 1, y, borderC);
        drawHorizontalLine(x, x1 - 1, y1 -1, borderC);
        drawRect(x + size, y + size, x1 - size, y1 - size, insideC);
    }

It would be better to have:

public final static ResourceLocation icons = new ResourceLocation("overhaul","textures/gui/icons.png");

 

Isn't size argument a bit too small to spot ?

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.