--- a/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
+++ b/net/minecraft/world/level/storage/loot/functions/LootingEnchantFunction.java
@@ -19,17 +19,15 @@
 import net.minecraft.world.level.storage.loot.providers.number.NumberProviders;
 
 public class LootingEnchantFunction extends LootItemConditionalFunction {
+
     public static final int NO_LIMIT = 0;
-    public static final MapCodec<LootingEnchantFunction> CODEC = RecordCodecBuilder.mapCodec(
-        instance -> commonFields(instance)
-                .and(
-                    instance.group(
-                        NumberProviders.CODEC.fieldOf("count").forGetter(function -> function.value),
-                        Codec.INT.optionalFieldOf("limit", Integer.valueOf(0)).forGetter(function -> function.limit)
-                    )
-                )
-                .apply(instance, LootingEnchantFunction::new)
-    );
+    public static final MapCodec<LootingEnchantFunction> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+        return commonFields(instance).and(instance.group(NumberProviders.CODEC.fieldOf("count").forGetter((lootenchantfunction) -> {
+            return lootenchantfunction.value;
+        }), Codec.INT.optionalFieldOf("limit", 0).forGetter((lootenchantfunction) -> {
+            return lootenchantfunction.limit;
+        }))).apply(instance, LootingEnchantFunction::new);
+    });
     private final NumberProvider value;
     private final int limit;
 
@@ -55,14 +53,22 @@
 
     @Override
     public ItemStack run(ItemStack stack, LootContext context) {
-        Entity entity = context.getParamOrNull(LootContextParams.KILLER_ENTITY);
+        Entity entity = (Entity) context.getParamOrNull(LootContextParams.KILLER_ENTITY);
+
         if (entity instanceof LivingEntity) {
-            int i = EnchantmentHelper.getMobLooting((LivingEntity)entity);
-            if (i == 0) {
+            int i = EnchantmentHelper.getMobLooting((LivingEntity) entity);
+            // CraftBukkit start - use lootingModifier if set by plugin
+            if (context.hasParam(LootContextParams.LOOTING_MOD)) {
+                i = context.getParamOrNull(LootContextParams.LOOTING_MOD);
+            }
+            // CraftBukkit end
+
+            if (i <= 0) { // CraftBukkit - account for possible negative looting values from Bukkit
                 return stack;
             }
 
-            float f = (float)i * this.value.getFloat(context);
+            float f = (float) i * this.value.getFloat(context);
+
             stack.grow(Math.round(f));
             if (this.hasLimit()) {
                 stack.limitSize(this.limit);
@@ -77,6 +83,7 @@
     }
 
     public static class Builder extends LootItemConditionalFunction.Builder<LootingEnchantFunction.Builder> {
+
         private final NumberProvider count;
         private int limit = 0;
 
