Jump to content

[1.7.10] Render HUD Inventory as custom -GUI Location/Coord ISSUE


Recommended Posts

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

Posted

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

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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