--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
@@ -18,35 +18,30 @@
 import net.minecraft.world.item.enchantment.LevelBasedValue;
 import net.minecraft.world.phys.Vec3;
 
-public record ApplyMobEffect(
-    HolderSet<MobEffect> toApply, LevelBasedValue minDuration, LevelBasedValue maxDuration, LevelBasedValue minAmplifier, LevelBasedValue maxAmplifier
-) implements EnchantmentEntityEffect {
-    public static final MapCodec<ApplyMobEffect> CODEC = RecordCodecBuilder.mapCodec(
-        instance -> instance.group(
-                    RegistryCodecs.homogeneousList(Registries.MOB_EFFECT).fieldOf("to_apply").forGetter(ApplyMobEffect::toApply),
-                    LevelBasedValue.CODEC.fieldOf("min_duration").forGetter(ApplyMobEffect::minDuration),
-                    LevelBasedValue.CODEC.fieldOf("max_duration").forGetter(ApplyMobEffect::maxDuration),
-                    LevelBasedValue.CODEC.fieldOf("min_amplifier").forGetter(ApplyMobEffect::minAmplifier),
-                    LevelBasedValue.CODEC.fieldOf("max_amplifier").forGetter(ApplyMobEffect::maxAmplifier)
-                )
-                .apply(instance, ApplyMobEffect::new)
-    );
+public record ApplyMobEffect(HolderSet<MobEffect> toApply, LevelBasedValue minDuration, LevelBasedValue maxDuration, LevelBasedValue minAmplifier, LevelBasedValue maxAmplifier) implements EnchantmentEntityEffect {
+
+    public static final MapCodec<ApplyMobEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+        return instance.group(RegistryCodecs.homogeneousList(Registries.MOB_EFFECT).fieldOf("to_apply").forGetter(ApplyMobEffect::toApply), LevelBasedValue.CODEC.fieldOf("min_duration").forGetter(ApplyMobEffect::minDuration), LevelBasedValue.CODEC.fieldOf("max_duration").forGetter(ApplyMobEffect::maxDuration), LevelBasedValue.CODEC.fieldOf("min_amplifier").forGetter(ApplyMobEffect::minAmplifier), LevelBasedValue.CODEC.fieldOf("max_amplifier").forGetter(ApplyMobEffect::maxAmplifier)).apply(instance, ApplyMobEffect::new);
+    });
 
     @Override
     public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity user, Vec3 pos) {
-        if (user instanceof LivingEntity livingEntity) {
-            RandomSource randomSource = livingEntity.getRandom();
-            Optional<Holder<MobEffect>> optional = this.toApply.getRandomElement(randomSource);
+        if (user instanceof LivingEntity entityliving) {
+            RandomSource randomsource = entityliving.getRandom();
+            Optional<Holder<MobEffect>> optional = this.toApply.getRandomElement(randomsource);
+
             if (optional.isPresent()) {
-                int i = Math.round(Mth.randomBetween(randomSource, this.minDuration.calculate(level), this.maxDuration.calculate(level)) * 20.0F);
-                int j = Math.max(0, Math.round(Mth.randomBetween(randomSource, this.minAmplifier.calculate(level), this.maxAmplifier.calculate(level))));
-                livingEntity.addEffect(new MobEffectInstance(optional.get(), i, j));
+                int j = Math.round(Mth.randomBetween(randomsource, this.minDuration.calculate(level), this.maxDuration.calculate(level)) * 20.0F);
+                int k = Math.max(0, Math.round(Mth.randomBetween(randomsource, this.minAmplifier.calculate(level), this.maxAmplifier.calculate(level))));
+
+                entityliving.addEffect(new MobEffectInstance((Holder) optional.get(), j, k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
             }
         }
+
     }
 
     @Override
     public MapCodec<ApplyMobEffect> codec() {
-        return CODEC;
+        return ApplyMobEffect.CODEC;
     }
 }
