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,

 

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

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.

  • Author

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

  • Author

Realized that what I said about widget transparency might sound a bit confusing; here's a screenshot to try and clear it up:

 

52fd5379987fa.jpg

 

The solid white squares should have alpha transparency. You can see the health bar through it, but you can't see the game world.

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

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.