UberAffe Posted April 1, 2016 Share Posted April 1, 2016 I have a some mana bars that get rendered on to the screen, the catch is that it only works when I have a stack of 2 feathers in my hotbar and I have no idea why or how that could possibly effect it. My CustomHud public class CustomHud{ private static LuxinBarRenderer[] bar_Lux; public CustomHud(){ Minecraft mc = Minecraft.getMinecraft(); Collection<ILuxin> luxin = LuxinReg.RegisteredLuxin.values(); bar_Lux = new LuxinBarRenderer[luxin.size()]; int index = 0; for(ILuxin lux : luxin) { LogHelper.info("rendering " + lux.GetName()); bar_Lux[index] = new LuxinBarRenderer(lux.GetName(), mc, index, lux.GetColor()); index++; } } @SubscribeEvent()//receiveCanceled=false) public void onEvent(RenderGameOverlayEvent.Post event) { if(event.getType() == ElementType.ALL) renderHud(); } public void renderHud() { for( LuxinBarRenderer rend : bar_Lux) rend.RenderLuxinBar(); } } The Bar that gets rendered public class LuxinBarRenderer { private final static int BAR_WIDTH = 81; private final static int BAR_HEIGHT = 9; private final static int BAR_SPACING = 3; private String lux; private Minecraft mc; private int iteration; private int[] RGB; public LuxinBarRenderer(String lux, Minecraft mc, int iteration, int[] RGB) { this.lux = lux; this.mc = mc; this.iteration = iteration; this.RGB = RGB; } public void RenderLuxinBar() { EntityPlayerSP player = mc.thePlayer; if(player == null) return; IDrafter drafter = DraftingProvider.get(player); if( drafter == null && !(drafter instanceof DefaultDrafter)) return; DefaultDrafter prop = (DefaultDrafter) drafter; float avail = prop.GetAvailableLuxin().get(lux); float cap = prop.GetMaxLuxin().get(lux); LogHelper.info("Rendering " + RGB[0] + " " + RGB[1] + " " + RGB[2]); float percent = cap / avail; GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushMatrix(); GL11.glColor4f((float)RGB[0]/255, (float)RGB[1]/255, (float)RGB[2]/255, .5f); int top = BAR_SPACING + (iteration * (BAR_SPACING + BAR_HEIGHT)); int left = BAR_SPACING; GL11.glBegin(GL11.GL_LINE_LOOP); { GL11.glVertex2i(left, top); GL11.glVertex2i(left + BAR_WIDTH, top); GL11.glVertex2i(left + BAR_WIDTH, top + BAR_HEIGHT); GL11.glVertex2i(left, top + BAR_HEIGHT); } GL11.glEnd(); GL11.glColor4f((float)RGB[0]/255f, (float)RGB[1]/255f, (float)RGB[2]/255f, 1f); GL11.glBegin(GL11.GL_QUADS); { int right = left + (int)(new Float(BAR_WIDTH) / percent); GL11.glVertex2i(left, top); GL11.glVertex2i(left, top + BAR_HEIGHT); GL11.glVertex2i(right, top + BAR_HEIGHT); GL11.glVertex2i(right, top); } GL11.glEnd(); GL11.glPopMatrix(); GL11.glPopAttrib(); } } The log helper you see in the Bar renderer prints out the correct color values regardless of if the bar actually renders. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
coolAlias Posted April 1, 2016 Share Posted April 1, 2016 Is it only with exactly 2 feathers, or can it be 2+ of any item? If it's the latter, it could be a bug with Forge / Minecraft as the extra layer that renders for the stack size might be doing something funky (it's happened before), or you may want to try using a different ElementType such as EXPERIENCE_BAR during the RenderGameOverlayEvent.Post. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
UberAffe Posted April 1, 2016 Author Share Posted April 1, 2016 Ok, so something must be wrong with ElementType or maybe its just a case of not being able to use ==, but I removed the if test and it works just fine now. Is there a downside to not checking the element type? Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
coolAlias Posted April 1, 2016 Share Posted April 1, 2016 The downside is that it renders lots of times, at least 1.8 and earlier that's how it worked. For my own HUD elements, I always render for the ElementType.EXPERIENCE type and it works great. Might want to try that one. Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
UberAffe Posted April 1, 2016 Author Share Posted April 1, 2016 I tried that one and a bunch of other but they all had the same problem. Well at least its just a few boxes and lines, that's not too bad to render multiple times. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
UberAffe Posted April 1, 2016 Author Share Posted April 1, 2016 Ok ... new problem. With nothing in my hotbar the Bars render properly. when I have one of my items(with a custom model loader) the colors of the bars change. when my item is not selected the bars turn black. having a stack of 2 of any other item makes the Bars render correctly regardless of selected item. Edit: If I look around really fast it will occasionally show the correct colors for a moment. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
coolAlias Posted April 3, 2016 Share Posted April 3, 2016 That sounds very reminiscent of a (vanilla?) lighting bug that used to exist but was fixed by Forge - perhaps it's back? Quote http://i.imgur.com/NdrFdld.png[/img] Link to comment Share on other sites More sharing options...
UberAffe Posted April 3, 2016 Author Share Posted April 3, 2016 I made a branch of my project that builds and has the bug happening for anyone that wants to take a look at it. Project Edit: The base command is /lidr and the default keybinding for creating one of my items is f. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
Recommended Posts
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.