Jump to content

Adding Potions to Player without GUI display


Recommended Posts

Hello all,

In my mod I have it so that when pressing a key under special circumstances the player gets a potion effect, or rather a lot of effects.


I've been searching for methods to add Potion Effects without the annoying GUI-Display (which shifts your Inventory over to the right) for quite a long time, but I haven't found anything good yet.


I tried removing the effects as soon as you open the Inventory, but it has a tiny very annoying delay, I tried doing it with ".performEffect", which doesn't work for all potions, and I tried replicating the effects of the potions, but there are some (like Night-vision) that are pretty hard to do.


I know where the Inventory Render gets called (InventoryEffectRenderer.displayDebuffEffects), but I can't hinder minecraft from doing it…


Now my question, is there any good way to add potion effects without the display in the Inventory?




Link to comment
Share on other sites

  • 7 months later...

I am trying to do the same thing. So far I have realized that the EntityLiving class has an updatePotionEffects method which takes the hashmap( a hashmap is sort of like an array, but each cell of the array has several attributes) of potioneffects curerntly on the living entity and displays them. There are no parameters to the method, so we cannot modify the way the potioneffects are rendered. However, there are several other ways to achieve our goal:


  1. Mimic the commands of instantiating a potioneffect on the living entity in a food item, armor, or such class without adding it to the living entity's potioneffect hashmap( I tried this on a custom food item, still trying to get it to work)


  2. Creating a custom class that extends EntityLiving and rewriting the updatePotionEffects method. One would have to change the instance of the player that the potioneffect is suppose to be affecting from a EntityLivingBase to a XXXX class that extends EntityLivingBase


Try the first option and I will try the second option. This way we can collaborate on our mutual dilemma. =)

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.

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.

  • Create New...

Important Information

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