Posted October 6, 201410 yr 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:
October 6, 201410 yr I think you have to enable alpha in opengl(GL11.glEnable(GL11.GL_BLEND)), also you have the width and height parameters in the event.resolution.
October 6, 201410 yr 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.
October 6, 201410 yr 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
October 19, 201410 yr Author 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
October 19, 201410 yr GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); render GL11.glDisable(GL11.GL_BLEND);
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.