Enchantment Damage to Entity Tag

Started by RamenNoods on

Topic category: Help with modding (Java Edition)

Last seen on 20:41, 7. Jun 2024
Joined Feb 2024

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Enchantment Damage to Entity Tag

I am trying to make an enchantment that deals more damage to fire/ender mobs called Moisture.
I copied another script exactly(replacing enchantment and tag of course), but it still does not deal extra damage. Tried several other scripts to no avail.

(I swear if it's some stupid mistake :/ ...)

Script here:

package net.mcreator.persona.procedures;

/* imports omitted */

public class MoistureDamageProcedure {
	public static void onEntityAttacked(LivingHurtEvent event) {
		if (event != null && event.getEntity() != null) {
			execute(event, event.getSource(), event.getEntity(), event.getSource().getEntity());

	public static void execute(DamageSource damagesource, Entity entity, Entity sourceentity) {
		execute(null, damagesource, entity, sourceentity);

	private static void execute(@Nullable Event event, DamageSource damagesource, Entity entity, Entity sourceentity) {
		if (damagesource == null || entity == null || sourceentity == null)
		if (EnchantmentHelper.getItemEnchantmentLevel(PersonaModEnchantments.MOISTURE.get(), (sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY)) != 0
				&& entity.getType().is(TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation("persona:firemobs")))) {
			entity.hurt(damagesource, (sourceentity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getEnchantmentLevel(PersonaModEnchantments.MOISTURE.get()));