Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

  • Author

So, the deobfusticated vanilla potion class just has an empty method for renderInventoryEffect. is there another place I should be looking?

  • Author

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

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.