From f6dc6745edf97d76fff76740e9794c631799c939 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sun, 27 Nov 2011 04:22:24 +0000 Subject: [PATCH] Fixed EntityDeathEvent not throwing for Ghasts and Pig Zombies (fixes issue #13) --- .../java/net/minecraft/server/EntityGhast.java | 16 ++++++++++++---- .../net/minecraft/server/EntityPigZombie.java | 14 ++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index ff10ab4d55..9cead91661 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -1,7 +1,10 @@ package net.minecraft.server; // CraftBukkit start +import java.util.List; import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end @@ -196,19 +199,24 @@ public class EntityGhast extends EntityFlying implements IMonster { } protected void a(boolean flag, int i) { + // CraftBukkit start + List loot = new java.util.ArrayList(); int j = this.random.nextInt(2) + this.random.nextInt(1 + i); int k; - for (k = 0; k < j; ++k) { - this.b(Item.GHAST_TEAR.id, 1); + if (j > 0) { + loot.add(new CraftItemStack(Item.GHAST_TEAR.id, j)); } j = this.random.nextInt(3) + this.random.nextInt(1 + i); - for (k = 0; k < j; ++k) { - this.b(Item.SULPHUR.id, 1); + if (j > 0) { + loot.add(new CraftItemStack(Item.SULPHUR.id, j)); } + + CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end } protected float o() { diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index 84c42746f0..9493695109 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -4,6 +4,8 @@ import java.util.List; // CraftBukkit start import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit end @@ -110,19 +112,23 @@ public class EntityPigZombie extends EntityZombie { } protected void a(boolean flag, int i) { + // CraftBukkit start + List loot = new java.util.ArrayList(); int j = this.random.nextInt(2 + i); int k; - for (k = 0; k < j; ++k) { - this.b(Item.ROTTEN_FLESH.id, 1); + if (j > 0) { + loot.add(new CraftItemStack(Item.ROTTEN_FLESH.id, j)); } j = this.random.nextInt(2 + i); - for (k = 0; k < j; ++k) { - this.b(Item.GOLD_NUGGET.id, 1); + if (j > 0) { + loot.add(new CraftItemStack(Item.GOLD_NUGGET.id, j)); } + CraftEventFactory.callEntityDeathEvent(this, loot); + // CraftBukkit end } protected int e() {