[Bleeding] Include equipment in EntityDeathEvent loot. Fixes BUKKIT-5566

This commit is contained in:
GJ 2014-04-28 12:00:25 -04:00 committed by Nate Mortensen
parent 76e6277175
commit 5195513866
2 changed files with 23 additions and 4 deletions

View file

@ -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() {

View file

@ -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()) {