How to convert strings to potion effects

Started by SnailsAttack on

Topic category: Help with MCreator software

Last seen on 01:05, 18. May 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to convert strings to potion effects
if (entity instanceof LivingEntity _entity && !_entity.level().isClientSide())
_entity.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 60, 1));

Is there a way to substitute the potion registry names (e.g. "REGENERATION") for a string variable using custom code snippets? I can't seem to figure out a way to do it myself.

Last seen on 01:05, 18. May 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found an answer to a…
Mon, 01/15/2024 - 12:58

I found an answer to a similar problem.

(entity instanceof LivingEntity _entity ? _entity.getActiveEffects():0)

You can put this in a custom code snippet to retrieve a string of all an entity's active effects.