How to convert strings to potion effects

Started by SnailsAttack on

Topic category: Help with MCreator software

Active 4 months ago
Joined Oct 2020
Points:
803

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 1
  • Comments: 93
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.

Active 4 months ago
Joined Oct 2020
Points:
803

User statistics:

  • Modifications: 0
  • Forum topics: 25
  • Wiki pages: 0
  • MCreator plugins: 1
  • Comments: 93
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.