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

Hi everyone,

 

I want to change the HUD inventory Rendering by replacing the gui temporarily to simulate swapping of inventories. If your ead my other post I successfully manipulated the vanilla hud inventory to essentially be a different inventory that is triggered based on a condition. I was wondering about the HUD rendering, how would I replace the GUI of the inventory HUD with my own custom one based on a condition that is set in my players IEEP class.

 

if condition is true -> render my custom HUD inventory

if condition is false -> render default vanilla inventory hud

  • Author

Ive been looking for the code and I have no idea where the vanilla HUD inventory renders

  • Author

Hi everyone, So I figured out how to get it to show up.

 

But there is a problem, whenever I resize the window the gui doesnt stay in the spot I place it. Not sure why.

protected void renderHotbar(int width, int height, float partialTicks)
    {
        
        mc.mcProfiler.startSection("actionBar");
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        mc.renderEngine.bindTexture(itemHUDTexture);

        InventoryPlayer inv = mc.thePlayer.inventory;
        drawTexturedModalRect(width/2 + 140, height/2 + 200, 0, 0, 182, 22); <--- draws the custom hotbar I made
        drawTexturedModalRect(width/2 +140 +inv.currentItem * 20, height/2 + 200, 0, 22, 24, 22); <--- draws the gui overlay  that shows which item is selected

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        RenderHelper.enableGUIStandardItemLighting();

        for (int i = 0; i < 9; ++i)
        {
            int x = width / 2 + i * 20 + 2;
            int z = height;
            renderInventorySlot(i, x, z, partialTicks);
        }

        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        mc.mcProfiler.endSection();
       
    }

But whenever I resize the window the gui jumps around. Any idea why?

 

I call this method in the

 

public void RenderBattleGUI(RenderGameOverlayEvent.Post event)

 

if(myCondition){
int width = event.resolution.getScaledWidth();
int height = event.resolution.getScaledHeight();
renderHotbar(width, height, 1);
}

You need to create a ScaledResolution (look at the source code using your IDE) object and get the scaled width / height from there. After that, divide both the width and height by 2 (getting the exact center of the screen based on its resolution) and then add / subtract from there. Pure math.

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

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.