Jump to content

Recommended Posts

Posted

Hello!

When I draw a texture using RenderGameOverlayEvent, then with her drawn back white background, although it is transparent.

My code is:

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void cancelVanillaGUI(RenderGameOverlayEvent.Pre event){
	/* Cancel render vanilla hearts, food, air and armor */
	if(event.type == ElementType.HEALTH || event.type == ElementType.FOOD || event.type == ElementType.AIR || event.type == ElementType.ARMOR || event.type == ElementType.EXPERIENCE){
		event.setCanceled(true);

		Minecraft mc = Minecraft.getMinecraft();

		if(mc.theWorld == null || mc.thePlayer == null){
			return;
		}

		EntityClientPlayerMP player = mc.thePlayer;

		RPGPlayerInfo info = RPGPlayerInfo.forPlayer(player);

		if(player.capabilities.isCreativeMode){
			return;
		}

		ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

		int height = resolution.getScaledHeight();
		int width = resolution.getScaledWidth();

		GL11.glPushMatrix();
		GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
		//GL11.glDisable(GL11.GL_LIGHTING);

		mc.getTextureManager().bindTexture(new ResourceLocation(InMinecraftRpg.MOD_ID.toLowerCase(), "textures/gui/icons.png"));

		/* Draw border */
		mc.ingameGUI.drawTexturedModalRect(2, 2, 0, 0, 162, 60);

		int healthBarWidth = MathHelper.ceiling_float_int(((player.getHealth() / player.getMaxHealth()) * 108));

		/* Draw health bar */
		mc.ingameGUI.drawTexturedModalRect(52, 16, 0, 60, healthBarWidth, 10);

		int armorBarWidth = MathHelper.ceiling_float_int(((getArmorValue(player) / 100.0F) * 108));

		/* Draw armor bar */
		mc.ingameGUI.drawTexturedModalRect(52, 29, 0, 70, armorBarWidth, 10);

		if(mc.objectMouseOver != null){
			if(mc.objectMouseOver.typeOfHit == MovingObjectType.ENTITY && mc.objectMouseOver.entityHit instanceof EntityLivingBase){

				EntityLivingBase viewEntity = (EntityLivingBase)mc.objectMouseOver.entityHit;

				int viewEntityHealthBarWidth = MathHelper.ceiling_float_int((viewEntity.getHealth() / viewEntity.getMaxHealth()) * 86);

				/* Draw view entity health bar */
				mc.ingameGUI.drawTexturedModalRect(66, 53, 0, 80, viewEntityHealthBarWidth, 6);

				/* Draw view entity name */
				mc.ingameGUI.drawCenteredString(mc.fontRenderer, viewEntity.getCommandSenderName(), 112, 64, Color.CYAN.getRGB());

				if(viewEntity instanceof EntityPlayer){

					int healthArmor = MathHelper.floor_float(viewEntity.getMaxHealth() + getArmorValue((EntityPlayer)viewEntity));

					/* Draw view player health + armor */
					mc.ingameGUI.drawCenteredString(mc.fontRenderer, String.valueOf(healthArmor), 112, 55, Color.CYAN.getRGB());
				}
			}
		}

		mc.getTextureManager().bindTexture(Gui.icons);

		int max = info.experienceToNextLvl - RPGPlayerInfo.getXpToNextLvl(info.experienceLevel - 1);

		int current = info.experienceToNextLvl - info.experience;

		int concurrent = max - current;

		int experienceBarWidth = MathHelper.ceiling_float_int(((float)concurrent / (float)max) * 182);

		//GL11.glTranslated(-182, 0, 0);

		/* Draw experience border */
		mc.ingameGUI.drawTexturedModalRect(width / 2 - 91, height - 29, 0, 64, 182, 5);

		/* Draw experience bar */
		mc.ingameGUI.drawTexturedModalRect(width / 2 - 91, height - 29, 0, 69, experienceBarWidth, 5);

		/* Draw experience lvl value */
		drawStringWithShadow(String.valueOf(info.experienceLevel), 82, 40, 8453920);

		/* Draw health value */
		drawStringWithShadow(String.valueOf((int)player.getHealth()) + "/" + (int)player.getMaxHealth(), 218, 18, Color.WHITE.getRGB());

		/* Draw armor value */
		drawStringWithShadow(String.valueOf((int)getArmorValue(player)) + "/100", 218, 31, Color.WHITE.getRGB());

		/* Draw experience value */
		drawStringWithShadow(String.valueOf(info.experience) + "/" + String.valueOf(info.experienceToNextLvl), width, height - 45, 8453920);

		//GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glPopMatrix();
	}
}

 

Here drawn picture:

 

mc.getTextureManager().bindTexture(new ResourceLocation(InMinecraftRpg.MOD_ID.toLowerCase(), "textures/gui/icons.png"));
/* Draw border */
mc.ingameGUI.drawTexturedModalRect(2, 2, 0, 0, 162, 60);

 

Screenshot:

 

2cac9d721e991accc49ae2a6780cee7b.png

Posted

Em, i don't have it in my code(sniper that has zooming and crosshairs, used RenderGameOverlay), try without it, if you see errors(something is rendering wrongly) put it to the end. Also use glpushmatrix before the blendfunc, and popmatrix at the end.

Posted

Hi

 

The flag you are looking for is probably ALPHA_TEST, assuming you've set the background alpha properly.

 

      GL11.glPushMatrix();
      GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

.. do your rendering here

      GL11.glPopAttrib();
      GL11.glPopMatrix();

 

pushMatrix & popMatrix stops your glTranslate and glRotate from affecting anything drawn after you're done

pushAttrib and popAttrib prevents your changed rendering settings (eg ALPHA_TEST) from affecting vanilla renders after your render

 

-TGG

  • 2 weeks later...
Posted
  On 10/6/2014 at 3:33 PM, TheGreyGhost said:

Hi

 

The flag you are looking for is probably ALPHA_TEST, assuming you've set the background alpha properly.

 

      GL11.glPushMatrix();
      GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

.. do your rendering here

      GL11.glPopAttrib();
      GL11.glPopMatrix();

 

pushMatrix & popMatrix stops your glTranslate and glRotate from affecting anything drawn after you're done

pushAttrib and popAttrib prevents your changed rendering settings (eg ALPHA_TEST) from affecting vanilla renders after your render

 

-TGG

 

Not Transparency is working :(

GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F); //0.3F - alpha not work :(

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! also yes, I read the FAQ.
    • Please read the FAQ (link is orange banner at top of page), and post logs as described there, to an external site such as https://mclo.gs  
    • Hi! I've got a modpack with about 56 mods that has, up until now, been running pretty well. Starting today, any world i try to open causes minecraft to crash. It isn't the game itself- the main menu opens up fine.  I tried changing the ram allocated with both the minecraft launcher, and the forge launcher. No success with either. I tried deleting the JEI folder and letting it remake itself. No success. I tried turning off multiple mods. No success. I tried turning off JEI incase that was the issue. No dice. If you need to know specifically which mods I have installed, let me know, and I'll send them all to you. I've included the very first crash log. Please let me know if there's anything I can do! https://pastebin.com/Zfv6gWN7 -- Crash log on Pastebin (if this doesnt work, let me know)
    • I had this issue on ftb-stoneblock-3-1.11.5 (most recent version right now, installed through CurseForge), but my friend didn't get it when installing the same pack in the same way. I tried reinstalling the modpack several times, didn't help. I later finally solved it by updating REI Plugin Compatibilities (REIPC) in my StoneBlock client from version 8.0.69 to 8.0.89 (the most recent one as of now).
    • Delete the personality-client.toml file in your config folder and add this mod: https://www.curseforge.com/minecraft/mc-mods/night-config-fixes  
  • Topics

×
×
  • Create New...

Important Information

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