Properly call EntityDeathEvent for mobs. Fixes BUKKIT-1519

Dieser Commit ist enthalten in:
feildmaster 2012-04-15 09:16:43 -05:00
Ursprung 6307efd2d1
Commit 748ebae550
3 geänderte Dateien mit 19 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -779,7 +779,18 @@ public abstract class EntityLiving extends Entity {
if (!this.isBaby()) { if (!this.isBaby()) {
this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i); this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
// CraftBukkit - move rare item drop call to dropDeathLoot /* CraftBukkit start - move rare item drop call to dropDeathLoot
if (this.lastDamageByPlayerTime > 0) {
int j = this.random.nextInt(200) - i;
if (j < 5) {
this.b(j <= 0 ? 1 : 0);
}
}
// */
} else {
CraftEventFactory.callEntityDeathEvent(this);
// CraftBukkit end
} }
} }

Datei anzeigen

@ -89,7 +89,7 @@ public class EntityOcelot extends EntityTameableAnimal {
} }
protected int getLootId() { protected int getLootId() {
return 0; // CraftBukkit - Item.LEATHER.id -> 0 return Item.LEATHER.id;
} }
public boolean a(Entity entity) { public boolean a(Entity entity) {
@ -102,7 +102,7 @@ public class EntityOcelot extends EntityTameableAnimal {
} }
protected void dropDeathLoot(boolean flag, int i) { protected void dropDeathLoot(boolean flag, int i) {
super.dropDeathLoot(flag, i); // CraftBukkit - Calls EntityDeathEvent org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this); // CraftBukkit - Call EntityDeathEvent
} }
public boolean b(EntityHuman entityhuman) { public boolean b(EntityHuman entityhuman) {

Datei anzeigen

@ -1,6 +1,7 @@
package org.bukkit.craftbukkit.event; package org.bukkit.craftbukkit.event;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -287,6 +288,10 @@ public class CraftEventFactory {
return event; return event;
} }
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim) {
return callEntityDeathEvent(victim, new ArrayList<org.bukkit.inventory.ItemStack>(0));
}
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) { public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward()); EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());