From 748ebae550002da7a0a6a611fcc737f57495f289 Mon Sep 17 00:00:00 2001 From: feildmaster Date: Sun, 15 Apr 2012 09:16:43 -0500 Subject: [PATCH] Properly call EntityDeathEvent for mobs. Fixes BUKKIT-1519 --- .../java/net/minecraft/server/EntityLiving.java | 13 ++++++++++++- .../java/net/minecraft/server/EntityOcelot.java | 4 ++-- .../bukkit/craftbukkit/event/CraftEventFactory.java | 5 +++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 726e5d5180..8c279ec7ab 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -779,7 +779,18 @@ public abstract class EntityLiving extends Entity { if (!this.isBaby()) { 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 } } diff --git a/src/main/java/net/minecraft/server/EntityOcelot.java b/src/main/java/net/minecraft/server/EntityOcelot.java index fefd2b639b..4df09bc46c 100644 --- a/src/main/java/net/minecraft/server/EntityOcelot.java +++ b/src/main/java/net/minecraft/server/EntityOcelot.java @@ -89,7 +89,7 @@ public class EntityOcelot extends EntityTameableAnimal { } protected int getLootId() { - return 0; // CraftBukkit - Item.LEATHER.id -> 0 + return Item.LEATHER.id; } public boolean a(Entity entity) { @@ -102,7 +102,7 @@ public class EntityOcelot extends EntityTameableAnimal { } 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) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index c1bb8b3689..75fdd3f65a 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.event; import java.net.InetAddress; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -287,6 +288,10 @@ public class CraftEventFactory { return event; } + public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim) { + return callEntityDeathEvent(victim, new ArrayList(0)); + } + public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List drops) { CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());