How can I check if an entity has a status effect?

Started by Tiny Desk Engineer on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 year ago
Joined Jan 2023
Points:
253

User statistics:

  • Modifications: 0
  • Forum topics: 3
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 0
How can I check if an entity has a status effect?

I'm trying to create a potion effect that prevent any entity that has it from taking any damage whatsoever, until the effect runs out. Like a really high level of Resistance. I think canceling any "Before entity is hurt" events on any entity with the effect would do what I want it to do, but I can't figure out how to check if the entity actually has the effect.

Active 1 day ago
Joined May 2022
Points:
1203

User statistics:

  • Modifications: 14
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1141
Just use an if bracket, and…
Wed, 12/27/2023 - 06:47

Just use an if bracket, and the 'does entity have potion effect' logic function. It's in the entity data tab. You could also use the 'remaining ticks of potion effect' number function. Canceling the 'before entity is hurt' event should work.