From a3a40ecd2be50d6079d0cb082865ad3f1127186b Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 10 Dec 2023 10:33:36 -0800 Subject: [PATCH] fix NPE when iterating over default drops (#10017) --- .../server/Restore-vanilla-entity-drops-behavior.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/patches/server/Restore-vanilla-entity-drops-behavior.patch b/patches/server/Restore-vanilla-entity-drops-behavior.patch index 1d03521e16..f46317e957 100644 --- a/patches/server/Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/Restore-vanilla-entity-drops-behavior.patch @@ -188,12 +188,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 lootCheck.run(); // Paper - advancement triggers before destroying items - for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { -- if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; + // Paper start + for (Entity.DefaultDrop drop : drops) { ++ if (drop == null) continue;; + final org.bukkit.inventory.ItemStack stack = drop.stack(); -+ if (drop == null || stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; + // Paper end + if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; - world.dropItem(entity.getLocation(), stack); // Paper - note: dropItem already clones due to this being bukkit -> NMS + drop.runConsumer(world, entity.getLocation()); // Paper @@ -216,12 +216,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 victim.newExp = event.getNewExp(); - for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { -- if (stack == null || stack.getType() == Material.AIR) continue; + // Paper start + for (Entity.DefaultDrop drop : drops) { ++ if (drop == null) continue; + final org.bukkit.inventory.ItemStack stack = drop.stack(); -+ if (drop == null || stack == null || stack.getType() == Material.AIR) continue; + // Paper end + if (stack == null || stack.getType() == Material.AIR) continue; - world.dropItem(entity.getLocation(), stack); + drop.runConsumer(world, entity.getLocation()); // Paper