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/EntityPigZombie.java | 38 +++++----------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'src/main/java/net/minecraft/server/EntityPigZombie.java') diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index ec268506..26fb4b94 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -3,10 +3,7 @@ package net.minecraft.server; import java.util.List; import java.util.UUID; -// CraftBukkit start -import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.event.entity.EntityTargetEvent; -// CraftBukkit end +import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit public class EntityPigZombie extends EntityZombie { @@ -128,45 +125,28 @@ public class EntityPigZombie extends EntityZombie { } protected void dropDeathLoot(boolean flag, int i) { - // CraftBukkit start - List loot = new java.util.ArrayList(); int j = this.random.nextInt(2 + i); - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.ROTTEN_FLESH, j)); - } - - j = this.random.nextInt(2 + i); + int k; - if (j > 0) { - loot.add(CraftItemStack.asNewCraftStack(Items.GOLD_NUGGET, j)); + for (k = 0; k < j; ++k) { + this.a(Items.ROTTEN_FLESH, 1); } - // Determine rare item drops and add them to the loot - if (this.lastDamageByPlayerTime > 0) { - int k = this.random.nextInt(200) - i; + j = this.random.nextInt(2 + i); - if (k < 5) { - ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0); - if (itemstack != null) { - loot.add(CraftItemStack.asCraftMirror(itemstack)); - } - } + for (k = 0; k < j; ++k) { + this.a(Items.GOLD_NUGGET, 1); } - - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot); - // CraftBukkit end } public boolean a(EntityHuman entityhuman) { return false; } - // CraftBukkit start - Return rare dropped item instead of dropping it - protected ItemStack getRareDrop(int i) { - return new ItemStack(Items.GOLD_INGOT, 1, 0); + protected void getRareDrop(int i) { + this.a(Items.GOLD_INGOT, 1); } - // CraftBukkit end protected void bC() { this.setEquipment(0, new ItemStack(Items.GOLD_SWORD)); -- cgit v1.2.3