Jump to content

Recommended Posts

Posted

Hey guys,

 

This is (hopefully) my final GUI issue, and it's probably something simple.

 

Basically, in the vanilla hotbar you can see there is a transparancy alpha layer; you can see through the bar. In my custom hotbar, even when it's just a copy-paste of the vanilla hotbar render code, this alpha transparency doesn't work.

Anyone got any idea what might cause such a thing?

 

 

Also, while I'm on the subject; is it possible to animate GUI elements, in a similar way to how we animate normal textures? I know I could do it in a long-winded way, running a tick timer and changing the texture coordinates each tick, but that IS very long-winded; is there a shorter way?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Make sure you enable glBlend

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Make sure you enable glBlend

 

I have AFAIK- One of the snippets I snagged from the vanilla class.

 

What's interesting and worth noting that I just discovered via a misconfiguration; If my hotbar renders over another widget, the transparancy DOES affect that widget - it seems to only not work on the game itself.

 

Here's my render method:

    @ForgeSubscribe(priority = EventPriority.NORMAL)
public void renderHotbarHorizontal(RenderGameOverlayEvent event) {
    	if (config.hotbarEnabled) {

		double widthMultiplier = getResIncreaseMultiplier("x");
		double heightMultiplier = getResIncreaseMultiplier("y");

		int sizeX = 182;
		int sizeY = 22;

		if (!config.horizontalHotbar) {
			sizeX = 22;
			sizeY = 182;
		}

		int configX = 0;
		int configY = 0;

		if (config.hotbarAnchor == 0 || config.hotbarAnchor >  {
			configX = (int) Math.round(config.hotbarXPos * widthMultiplier);
			configY = (int) Math.round(config.hotbarYPos * heightMultiplier);
		} else {
			configX = calculateAnchorPointX(config.hotbarAnchor, sizeX);
			configY = calculateAnchorPointY(config.hotbarAnchor, sizeY);
		}

		int xPos = configX + config.hotbarXOffset;
		int yPos = configY + config.hotbarYOffset;

        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(guiStatsBar);
        
        if (config.horizontalHotbar) {
        	InventoryPlayer inv = mc.thePlayer.inventory;
            drawTexturedModalRect(xPos, yPos, 0, 168, sizeX, sizeY);
            drawTexturedModalRect(xPos - 1 + (inv.currentItem * 20), yPos - 1, 182, 168, 24, 24);

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

        	for (int i = 0; i < 9; ++i) {
                int x = xPos +  (i * 20) + 2;
                int z = yPos - 3;
        		renderInventorySlot(i, x, z, 1.0F);
        	}
        } else {
        	InventoryPlayer inv = mc.thePlayer.inventory;
	        drawTexturedModalRect(xPos, yPos, 234, 0, sizeX, sizeY);
	        drawTexturedModalRect(xPos - 1, yPos - 1 + (inv.currentItem * 20), 182, 168, 24, 24);

	        GL11.glDisable(GL11.GL_BLEND);
	        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
	        RenderHelper.enableGUIStandardItemLighting();
	        
            for (int i = 0; i < 9; ++i) {
                int x = xPos + 3;
                int z = yPos + (i * 20) + 2;
                renderInventorySlot(i, x, z, 1.0F);
            }
        }

        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    	}
}

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

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.