theishiopian Posted August 2, 2019 Posted August 2, 2019 (edited) 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 Edited August 2, 2019 by theishiopian Resolved Quote
theishiopian Posted August 2, 2019 Author Posted August 2, 2019 Ah, my mistake, I was just following an example. How exactly do I render an icon? I've never done any rendering before Quote
theishiopian Posted August 2, 2019 Author Posted August 2, 2019 I've been looking at it, and I kinda figured that was the correct approach. Quote
theishiopian Posted August 2, 2019 Author Posted August 2, 2019 So, the deobfusticated vanilla potion class just has an empty method for renderInventoryEffect. is there another place I should be looking? Quote
theishiopian Posted August 2, 2019 Author Posted August 2, 2019 (edited) 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. Edited August 2, 2019 by theishiopian bugs Quote
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.