From 5195513866dda421bcd79adf14eaf991ae627ffd Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 28 Apr 2014 12:00:25 -0400 Subject: [Bleeding] Include equipment in EntityDeathEvent loot. Fixes BUKKIT-5566 --- .../java/net/minecraft/server/EntityInsentient.java | 21 ++++++++++++++++++--- .../java/net/minecraft/server/EntityLiving.java | 6 +++++- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java index 7079ed7d..11450ac5 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -6,6 +6,7 @@ import java.util.UUID; // CraftBukkit start import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityUnleashEvent; import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; // CraftBukkit end @@ -194,11 +195,18 @@ public abstract class EntityInsentient extends EntityLiving { if (k < 5) { ItemStack itemstack = this.getRareDrop(k <= 0 ? 1 : 0); if (itemstack != null) { - loot.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); + loot.add(CraftItemStack.asCraftMirror(itemstack)); } } } + // Include equipment + for (ItemStack stack : this.dropEquipment(this.lastDamageByPlayerTime > 0, i)) { + if (stack != null) { + loot.add(CraftItemStack.asCraftMirror(stack)); + } + } + CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot // CraftBukkit end } @@ -565,7 +573,10 @@ public abstract class EntityInsentient extends EntityLiving { return this.equipment; } - protected void dropEquipment(boolean flag, int i) { + // CraftBukkit start - return array of dropped items + protected ItemStack[] dropEquipment(boolean flag, int i) { + ItemStack[] dropped = new ItemStack[this.equipment.length]; + // CraftBukkit end for (int j = 0; j < this.getEquipment().length; ++j) { ItemStack itemstack = this.getEquipment(j); boolean flag1 = this.dropChances[j] > 1.0F; @@ -586,9 +597,13 @@ public abstract class EntityInsentient extends EntityLiving { itemstack.setData(l); } - this.a(itemstack, 0.0F); + // CraftBukkit start + // this.a(itemstack, 0.0F); + dropped[j] = itemstack; + // CraftBukkit end } } + return dropped; // CraftBukkit } protected void bC() { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index f90e2a31..60db3063 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -798,7 +798,11 @@ public abstract class EntityLiving extends Entity { this.world.broadcastEntityEffect(this, (byte) 3); } - protected void dropEquipment(boolean flag, int i) {} + // CraftBukkit start - return dropped equipment for EntityDeathEvent processing + protected ItemStack[] dropEquipment(boolean flag, int i) { + return new ItemStack[this.getEquipment().length]; + } + // CraftBukkit end public void a(Entity entity, float f, double d0, double d1) { if (this.random.nextDouble() >= this.getAttributeInstance(GenericAttributes.c).getValue()) { -- cgit v1.2.3