Posted September 23, 20159 yr I have a custom GuiScreen that I open on the GuiOpenEvent. It replaces the GuiIventory Gui. The problem I have is that the new GUI that I render's texture is 100% alpha, with different levels of alpha. It all works by making GL calls to enable / disable the alpha and blend, but I have a weird problem for when the player hovers over the 2x2 crafting grid or the armor slots - the alpha level darkens for the slots. What is causing this? Why is the alpha changing when I hover over only the armor slots and crafting grid? Where are the armor slot icons (the icons displaying the different types of armors) rendered? If anyone can help me out I'd appreciate it. Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
September 23, 20159 yr Please show your code. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
September 24, 20159 yr Author Here you are: Replacing Vanilla GUI Inventory @SubscribeEvent public void onEvent(GuiOpenEvent event) { if(event.gui instanceof GuiInventory) { event.setCanceled(true); Minecraft.getMinecraft().displayGuiScreen(new GuiInventoryTextured(Minecraft.getMinecraft().thePlayer)); } } My Custom GUI Inventory @SideOnly(Side.CLIENT) public class GuiInventoryTextured extends InventoryEffectRenderer { private float oldMouseX; private float oldMouseY; public GuiInventoryTextured(EntityPlayer entityplayer) { super(entityplayer.inventoryContainer); this.allowUserInput = true; } @Override public void updateScreen() { if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } this.updateActivePotionEffects(); } @Override public void initGui() { this.buttonList.clear(); if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } else { super.initGui(); } } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { GlStateManager.pushMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); GlStateManager.popMatrix(); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); this.oldMouseX = (float)mouseX; this.oldMouseY = (float)mouseY; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.pushMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); this.mc.getTextureManager().bindTexture(new ResourceLocation(MainReference.ID + ":" + "textures/gui/inventory.png")); int k = this.guiLeft; int l = this.guiTop; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); drawEntityOnScreen(k + 51, l + 75, 30, (float)(k + 51) - this.oldMouseX, (float)(l + 75 - 50) - this.oldMouseY, this.mc.thePlayer); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); GlStateManager.popMatrix(); } public static void drawEntityOnScreen(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_) { GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate((float)p_147046_0_, (float)p_147046_1_, 50.0F); GlStateManager.scale((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); float f2 = p_147046_5_.renderYawOffset; float f3 = p_147046_5_.rotationYaw; float f4 = p_147046_5_.rotationPitch; float f5 = p_147046_5_.prevRotationYawHead; float f6 = p_147046_5_.rotationYawHead; GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F; p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F; p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F; p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw; p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw; GlStateManager.translate(0.0F, 0.0F, 0.0F); RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); rendermanager.setPlayerViewY(180.0F); rendermanager.setRenderShadow(false); rendermanager.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); rendermanager.setRenderShadow(true); p_147046_5_.renderYawOffset = f2; p_147046_5_.rotationYaw = f3; p_147046_5_.rotationPitch = f4; p_147046_5_.prevRotationYawHead = f5; p_147046_5_.rotationYawHead = f6; GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 0) { this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.getStatFileWriter())); } if (button.id == 1) { this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.getStatFileWriter())); } } } Only Modified Method In My Custom GUI Inventory (GUI code is copied from GuiInventory and this method is modified only) @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.pushMatrix(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); this.mc.getTextureManager().bindTexture(new ResourceLocation(MainReference.ID + ":" + "textures/gui/inventory.png")); int k = this.guiLeft; int l = this.guiTop; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); drawEntityOnScreen(k + 51, l + 75, 30, (float)(k + 51) - this.oldMouseX, (float)(l + 75 - 50) - this.oldMouseY, this.mc.thePlayer); GlStateManager.disableBlend(); GlStateManager.disableAlpha(); GlStateManager.popMatrix(); } I don't know where the slots for the armor are rendered - I'm pretty sure it is causing the issue since the alpha changes when I hover over the slots (also, same for the crafting grid). Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
September 24, 20159 yr Try setting GlStateManager.color to 1, 1, 1, 1. I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP) II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.
September 25, 20159 yr Author Try setting GlStateManager.color to 1, 1, 1, 1. That didn't do a thing. Again, I think its located where the armor slots are rendered, but I can't find any trace of where they are. Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
September 25, 20159 yr I think you need a GL.end() and GL.start() in there somewhere if you want to change certain properties, like alpha, and not retro-actively overwrite. I can't tell from here, though. 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.
September 25, 20159 yr Well, i can't see the method that draws the rectangle when you hoover over the slot. Where is it?
September 25, 20159 yr Author I fixed the problem. Solution - push the matrix, enable blend, bind the texture and draw the textured rect., disable blend, then finally pop the matrix. TIP - You can simply modify the GUI's by extending them and overriding their methods (then set the GUI field in the GUIOpenEvent to your GUI) rather than copying the whole GUI class and calling displayGuiScreen() like shown above, unless you need access to private methods / fields and don't want to use reflection; 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.