From e080bafa58c52dc5debf1e6da5ba1c4b5f017795 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Mon, 26 May 2014 02:17:53 -0500 Subject: Rework mob item dropping on death. Fixes BUKKIT-5625 After the changes in d611cff2 we started including a mob's equipment when calling EntityDeathEvent so plugins can access this data. However, the changes to enable this triggered a bug that makes skeletons and pig zombies no longer drop equipment because they handle this differently than the rest. On top of this we don't handle dropping equipment for mobs that cannot pick up items in vanilla even though vanilla does drop equipment for them if you summon them with it. We also do not include a horse's inventory in the event so they drop their saddle, armor, chest, and chest contents with no way for a plugin to control this. To solve this issues we revert mob item dropping back to vanilla logic and instead just capture all their drops in the method they all call to spawn them into the world. We also move horse inventory dropping so it happens at a time when we're capturing these drops. With these changes all items mobs drop on death should now be included in the event and we have less diff to worry about for future updates. --- .../java/net/minecraft/server/EntitySpider.java | 24 +++------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/main/java/net/minecraft/server/EntitySpider.java') diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index 67a23f65..8d5bff2c 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -1,9 +1,6 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.craftbukkit.util.CraftMagicNumbers; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkti end +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public class EntitySpider extends EntityMonster { @@ -97,25 +94,10 @@ public class EntitySpider extends EntityMonster { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - Whole method; adapted from super.dropDeathLoot. - java.util.List loot = new java.util.ArrayList(); - - int k = this.random.nextInt(3); - - if (i > 0) { - k += this.random.nextInt(i + 1); - } - - if (k > 0) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.STRING), k)); - } - + super.dropDeathLoot(flag, i); if (flag && (this.random.nextInt(3) == 0 || this.random.nextInt(1 + i) > 0)) { - loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.SPIDER_EYE), 1)); + this.a(Items.SPIDER_EYE, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot - // CraftBukkit end } public boolean h_() { -- cgit v1.2.3