diff options
author | Jake Potrebic <[email protected]> | 2023-12-10 10:33:36 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-12-10 10:33:36 -0800 |
commit | dd16335e40dc13843e8ae7c681ca0a166d2e54a0 (patch) | |
tree | 3aa9658bc261b02079d21cdcaf654f816f66e476 | |
parent | 3434a6fc66cba92bc38760b1be37e47e0b644484 (diff) | |
download | Paper-dd16335e40dc13843e8ae7c681ca0a166d2e54a0.tar.gz Paper-dd16335e40dc13843e8ae7c681ca0a166d2e54a0.zip |
fix NPE when iterating over default drops (#10017)
-rw-r--r-- | patches/server/1048-Restore-vanilla-entity-drops-behavior.patch | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/patches/server/1048-Restore-vanilla-entity-drops-behavior.patch b/patches/server/1048-Restore-vanilla-entity-drops-behavior.patch index 0c2b0b055b..648946920d 100644 --- a/patches/server/1048-Restore-vanilla-entity-drops-behavior.patch +++ b/patches/server/1048-Restore-vanilla-entity-drops-behavior.patch @@ -154,7 +154,7 @@ index ab708b256183fc54fe8e13f341d8a38acf611739..1e86e86b0a100a5d14aee10b60e70c32 } } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 916b29914f77bed0dbfdcd5eae8a6ef22948b9b0..e0f80414e01852b6f48c173dc2343ec928147e2f 100644 +index 916b29914f77bed0dbfdcd5eae8a6ef22948b9b0..f5a5ae30dfba21d5cf3990c046cfe41547e8a87a 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -942,17 +942,21 @@ public class CraftEventFactory { @@ -183,17 +183,17 @@ index 916b29914f77bed0dbfdcd5eae8a6ef22948b9b0..e0f80414e01852b6f48c173dc2343ec9 populateFields(victim, event); // Paper - make cancellable CraftWorld world = (CraftWorld) entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); -@@ -966,19 +970,22 @@ public class CraftEventFactory { +@@ -966,19 +970,23 @@ public class CraftEventFactory { victim.expToDrop = event.getDroppedExp(); 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 @@ -211,17 +211,17 @@ index 916b29914f77bed0dbfdcd5eae8a6ef22948b9b0..e0f80414e01852b6f48c173dc2343ec9 event.setKeepInventory(keepInventory); event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel populateFields(victim, event); // Paper - make cancellable -@@ -997,10 +1004,13 @@ public class CraftEventFactory { +@@ -997,10 +1005,14 @@ public class CraftEventFactory { victim.expToDrop = event.getDroppedExp(); 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 |