diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-01-30 20:21:24 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-01-30 20:22:09 +0000 |
commit | 914688e2a07dc99421a3c512c2df59b770ea3d17 (patch) | |
tree | 91e3a35c01b4f7fe87b5c48d5e4ebde1abb943de /src/main/java/net/minecraft/server | |
parent | 0bc5bd54bd8fc6167377a70c4d997b4e67b7fe90 (diff) | |
download | craftbukkit-914688e2a07dc99421a3c512c2df59b770ea3d17.tar craftbukkit-914688e2a07dc99421a3c512c2df59b770ea3d17.tar.gz craftbukkit-914688e2a07dc99421a3c512c2df59b770ea3d17.tar.lz craftbukkit-914688e2a07dc99421a3c512c2df59b770ea3d17.tar.xz craftbukkit-914688e2a07dc99421a3c512c2df59b770ea3d17.zip |
Implemented ENTITY_DEATH for monsters and animals
Diffstat (limited to 'src/main/java/net/minecraft/server')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityLiving.java | 30 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/EntitySkeleton.java | 30 |
2 files changed, 47 insertions, 13 deletions
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index e8f7f36d..2ac229f1 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -1,11 +1,19 @@ package net.minecraft.server; +import java.util.ArrayList; import java.util.List; // CraftBukkit start +import org.bukkit.Location; +import org.bukkit.Server; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.event.Event.Type; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityDeathEvent; // CraftBukkit end public abstract class EntityLiving extends Entity { @@ -435,15 +443,25 @@ public abstract class EntityLiving extends Entity { } protected void g_() { - int i = this.h(); + // Craftbukkit start - whole method + List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>(); + int drop = this.h(); + int count = random.nextInt(3); - if (i > 0) { - int j = this.random.nextInt(3); + if ((drop > 0) && (count > 0)) { + loot.add(new org.bukkit.inventory.ItemStack(drop, count)); + } - for (int k = 0; k < j; ++k) { - this.a(i, 1); - } + CraftEntity entity = (CraftEntity)getBukkitEntity(); + EntityDeathEvent event = new EntityDeathEvent(Type.ENTITY_DEATH, entity, loot); + CraftWorld cworld = ((WorldServer)world).getWorld(); + Server server = ((WorldServer)world).getServer(); + server.getPluginManager().callEvent(event); + + for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { + cworld.dropItemNaturally(entity.getLocation(), stack); } + // Craftbukkit end } protected int h() { diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index 827c40c2..9baca736 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -1,9 +1,15 @@ package net.minecraft.server; // CraftBukkit start +import java.util.ArrayList; +import java.util.List; +import org.bukkit.Server; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.event.Event.Type; import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.EntityDeathEvent; // CraftBukkit end public class EntitySkeleton extends EntityMonster { @@ -84,18 +90,28 @@ public class EntitySkeleton extends EntityMonster { } protected void g_() { - int i = this.random.nextInt(3); + // Craftbukkit start - whole method + List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>(); - int j; + int count = this.random.nextInt(3); + if (count > 0) { + loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.ARROW, count)); + } - for (j = 0; j < i; ++j) { - this.a(Item.ARROW.id, 1); + count = this.random.nextInt(3); + if (count > 0) { + loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count)); } - i = this.random.nextInt(3); + CraftEntity entity = (CraftEntity)getBukkitEntity(); + EntityDeathEvent event = new EntityDeathEvent(Type.ENTITY_DEATH, entity, loot); + CraftWorld cworld = ((WorldServer)world).getWorld(); + Server server = ((WorldServer)world).getServer(); + server.getPluginManager().callEvent(event); - for (j = 0; j < i; ++j) { - this.a(Item.BONE.id, 1); + for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { + cworld.dropItemNaturally(entity.getLocation(), stack); } + // Craftbukkit end } } |