-
Posts
150 -
Joined
-
Last visited
Everything posted by theishiopian
-
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
Wow, none of these fields are labeled very well at all. -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
Ah, that makes a lot of sense. I figured I would have to clean up after myself. Also, whats the best way to make my hearts jiggle when the player is on low health, along with the vanilla ones? EDIT: regarding translation, thats what I meant, yeah. EDIT2: rebinding the icon textures fixed the hunger bar. -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
Ok, progress! Im now seeing 6 dark red rectangles on the oposite side of the HUD from the health bar, that twitch occasionally. code used: public void renderStatusBar(int screenWidth, int screenHeight) { //System.out.println("called"); World world = mc.world; EntityPlayer player = mc.player; final int barHeight = 9; //final int barWidth = (int) (9*((Math.ceil(player.getMaxHealth()/5))/2)); final int barWidth = 18; final int expBarSpace = 3; mc.getTextureManager().bindTexture(overlay); final int vanillaExpLeftX = screenWidth / 2 - 91; // leftmost edge of the experience bar final int vanillaExpTopY = screenHeight - 32 + 3; // top of the experience bar //GL11.glTranslatef(vanillaExpLeftX, vanillaExpTopY - expBarSpace - barHeight, 0); //drawTexturedModalRect(0, 0, 0, 0, barWidth, barHeight); this.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 9, 9, 9, 9); } I should clarify that this is still not the desired effect, but at least its rendering now. EDIT: I just noticed the icons rendering at the top of the screen! Now i just gotta translate them to the right spot. And get rid of those artifacts on the HUD. -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
That did not help either. As a side note, I need to be able to vary the amount of hearts the bar covers since the effect is based on a percentage of your health, is there a better way to do that? -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
That makes sense, always better to use a getter instead of the field. Regardless, it did not fix the issue. -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
Removing the gl11.gltranslatef call did not seem to fix the issue. -
Rendering an overlay over the health bar [1.12.2]
theishiopian replied to theishiopian's topic in Modder Support
As I said in my post, I have confirmed the event is firing, and that the render code is being called. -
I have a mod called immortality that add a potion that keeps the player's health from dropping below 20%. The mod itself works just fine, but I want to add an overlay effect to the health bar to show the player how low their health can go, specifically by covering 20% of the health bar (usually 2 hearts) in custom hearts, kinda like how poison turns your hearts green. I have some rendering code, but its not rendering anything. Here's the event handler Im using, I've confirmed it works: private static Minecraft mc = Minecraft.getMinecraft(); private static final ImmortalityBarRenderer renderer = new ImmortalityBarRenderer(mc); @SubscribeEvent//render immortal hearts over player hearts public void onDrawBar(RenderGameOverlayEvent.Post event) { EntityPlayerSP entityPlayerSP = Minecraft.getMinecraft().player; if (entityPlayerSP == null) return; if(event.getType() == ElementType.HEALTH) { renderer.renderStatusBar(event.getResolution().getScaledWidth(), event.getResolution().getScaledHeight()); } } And here is my renderer class, I have confirmed that renderStatusBar is getting called, which means its something in my render code: public class ImmortalityBarRenderer extends Gui { private static final ResourceLocation overlay = new ResourceLocation(Immortality.MODID +":textures/gui/immortal_heart.png"); private Minecraft mc; public ImmortalityBarRenderer(Minecraft mc) { this.mc = mc; } public void renderStatusBar(int screenWidth, int screenHeight) { World world = mc.world; EntityPlayer player = mc.player; final int barHeight = 9; final int barWidth = (int) (9*((Math.ceil(player.getMaxHealth()/5))/2)); final int expBarSpace = 3; //push matrix GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.renderEngine.bindTexture(overlay); final int vanillaExpLeftX = screenWidth / 2 - 91; // leftmost edge of the experience bar final int vanillaExpTopY = screenHeight - 32 + 3; // top of the experience bar GL11.glTranslatef(vanillaExpLeftX, vanillaExpTopY - expBarSpace - barHeight, 0); drawTexturedModalRect(0, 0, 0, 0, barWidth, barHeight); GL11.glPopAttrib(); GL11.glPopMatrix(); } } I know next to nothing about rendering on the HUD, I've just been replicating examples I've seen. If I've done something obviously wrong, please point it out so I don't do it again.
-
I figured it out, a night's sleep really helps with coding apaprently. The setIconIndex is the culprit, removing it fixed it. Now I know what that does!
-
Its a ResourceLocation that points to a 16*16 png in my assets Here's the whole class for context: public static class ImmortalityEffect extends Potion { protected ImmortalityEffect() { super(false, 8331833); this.setPotionName("effect.immortality"); this.setIconIndex(0, 0); this.setRegistryName(Immortality.MODID + ":" + "immortality"); } ResourceLocation icon = new ResourceLocation(Immortality.MODID +":textures/gui/icon.png"); @Override @SideOnly(Side.CLIENT) public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) { mc.getTextureManager().bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 3, y + 3, 0, 0, 18, 18, 18, 18); } @Override @SideOnly(Side.CLIENT) public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { mc.getTextureManager().bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 6, y + 7, 0, 0, 18, 18, 18, 18); } }
-
I'm attempting to make a custom potion effect, and I'm very close! But theres one last issue that I can't seem to fix. The potion effect's icon has a speed icon behind it. I know very little about rendering, so any help getting rid of this bug would be appreciated, as well as an explanation as to why it happens. My rendering code, in the potion effect class: @Override @SideOnly(Side.CLIENT) public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) { mc.getTextureManager().bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 3, y + 3, 0, 0, 18, 18, 18, 18); } @Override @SideOnly(Side.CLIENT) public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { mc.getTextureManager().bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 6, y + 7, 0, 0, 18, 18, 18, 18); } A picture of the glitch, notice the second HUD icon: The glitch happens regardless of other active effects, the speed icon on top was just me testing.
-
Potion Effect Icon not rendering properly [1.12.2] [Resolved]
theishiopian replied to theishiopian's topic in Modder Support
Ok, I did it. I found an example on another mod's github. The main thing i needed was how big to set the icon and which overload to use. For anyone with a similar problem, this works just fine in 1.12.2 with a 16*16 icon: @Override @SideOnly(Side.CLIENT) public void renderHUDEffect(int x, int y, PotionEffect effect, Minecraft mc, float alpha) { mc.renderEngine.bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 3, y + 3, 0, 0, 18, 18, 18, 18); } @Override @SideOnly(Side.CLIENT) public void renderInventoryEffect(int x, int y, PotionEffect effect, Minecraft mc) { mc.renderEngine.bindTexture(icon); Gui.drawModalRectWithCustomSizedTexture(x + 6, y + 7, 0, 0, 18, 18, 18, 18); } Thanks for the help diesiben! EDIT: there seems to be a bug where the icon is rendered over a speed effect icon. -
Potion Effect Icon not rendering properly [1.12.2] [Resolved]
theishiopian replied to theishiopian's topic in Modder Support
So, the deobfusticated vanilla potion class just has an empty method for renderInventoryEffect. is there another place I should be looking? -
Potion Effect Icon not rendering properly [1.12.2] [Resolved]
theishiopian replied to theishiopian's topic in Modder Support
I've been looking at it, and I kinda figured that was the correct approach. -
Potion Effect Icon not rendering properly [1.12.2] [Resolved]
theishiopian replied to theishiopian's topic in Modder Support
Ah, my mistake, I was just following an example. How exactly do I render an icon? I've never done any rendering before -
I'm trying to make a custom potion effect, and I've got everything working except the icon. The effect icon renders as just a transparent square. I know its loading something, because its not the black missing texture thing, and no errors are thrown in the console. But its not loading my texture file because I tried filling the whole thing with color and nothing loaded. I set the icon index to (0,0). Potion effect: public static class ImmortalityEffect extends Potion { protected ImmortalityEffect() { super(false, 8331833); this.setPotionName("effect.immortality"); this.setIconIndex(0, 0); this.setRegistryName(Immortality.MODID + ":" + "immortality"); } @Override public boolean hasStatusIcon() { Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(Immortality.MODID + ":textures/gui/potion_effects.png")); return true; } } The texture I'm using is attached
-
Please don't put crashlogs in your post, use pastebin or similar. It looks like the mod is trying to call a method that doesnt exist. Make sure you are using the correct forge version, it might have gotten renamed.
-
Hey, another tip for you, since you are new. You only waited a few hours before jacking my thread for your issue. That is NOT enough time for someone to help you! next time, be patient. The helpful people on here can't always be around, they have lives outside the forum. I sometimes have to wait days for help with modding.
-
Given the lack of an alternative, I think that's what I'll go with. Thanks anyways for your help. If anyone chances upon this thread with a better solution, I'm all ears.
-
It turns out that this method was removed recently, if anyone else knows a solution, let me know.
-
I figured it was easy, thank you!
-
So I have an idea for a mod, but I'm unsure of the best approach for it, and I would like some guidance. I want to make a mod that allows you to collect netherrack with your fist, like punching trees to get wood.The way I would do it is make an event handler that checks for blocks being beroken, and if the block is netherrack, add drops. however, it seems wasteful to create a whole event handler for this one thing. Is there an easier way to do this? EDIT: Block.setHarvestLevel is unfortunately no longer an option in modern forge
-
That did the trick! Thanks a lot! For anyone who has this problem in the future, here's my final code: @EventHandler public static void postInit(FMLPostInitializationEvent event) { BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.SKULL, new BehaviorDefaultDispenseItem()); System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); } The println is just so i see it in the log.
-
You were right, its not being called at all. And I think I know why, I forgot the event handler annotation.