Jump to content

Potion Effect Icon not rendering properly [1.12.2] [Resolved]


theishiopian

Recommended Posts

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

potion_effects.png

Edited by theishiopian
Resolved
Link to comment
Share on other sites

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 by theishiopian
bugs
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.