Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.5] Getting the source of a Potion Effect


Recommended Posts

Is this for your potion effect or just any effect?

The source is only known to the PotionEntity class. And it only keeps track of throwing entities, not if it is thrown by a dispenser or something like that.

Link to post
Share on other sites

Subscribe to EntityJoinWorldEvent. Check if the entity is a PotionEntity.

This PotionEntity needs to then somehow convey this information into the EffectInstance. An EffectInstance cannot really store any custom data, however you can do something very hacky:

ItemStack dummyStack = new ItemStack(YourModItems.DUMMY_HIDDEN_ITEM);
dummyStack.setTag(<nbt data here>);
effectInstance.addCurativeItem(dummyStack);

You then need to cancel the join event and make your own PotionEntity spawn instead (you need to see how ForgeInternalHandler does it or you will cause a deadlock). Note that if you do this you must also create a custom AreaEffectCloudEntity, if that is applicable for your potion. These custom entities must then use something to the above effect so that you can later identify where the EffectInstance came from.

 

All in all this is very hacky.

Link to post
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.

Guest
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 Privacy Policy.