summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityPlayer.java
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-01-30 20:34:38 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2011-01-30 20:35:08 +0000
commit1bc9c54233275b7bf79d73954aae8e86f876da41 (patch)
treee400a3b3ba4492f6c9b94eb208fe2b163b64cfca /src/main/java/net/minecraft/server/EntityPlayer.java
parent35aac122356b7237e461c8e1faf0c7b49e308aef (diff)
downloadcraftbukkit-1bc9c54233275b7bf79d73954aae8e86f876da41.tar
craftbukkit-1bc9c54233275b7bf79d73954aae8e86f876da41.tar.gz
craftbukkit-1bc9c54233275b7bf79d73954aae8e86f876da41.tar.lz
craftbukkit-1bc9c54233275b7bf79d73954aae8e86f876da41.tar.xz
craftbukkit-1bc9c54233275b7bf79d73954aae8e86f876da41.zip
Implemented ENTITY_DEATH for players
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityPlayer.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index b0256067..86a298fe 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -1,9 +1,17 @@
package net.minecraft.server;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import org.bukkit.Server;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.Event;
+import org.bukkit.event.entity.EntityDeathEvent;
public class EntityPlayer extends EntityHuman implements ICrafting {
@@ -69,7 +77,31 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
public void f(Entity entity) {
- this.inventory.h();
+ // Craftbukkit start
+ List<org.bukkit.inventory.ItemStack> loot = new ArrayList<org.bukkit.inventory.ItemStack>();
+
+ for (int i = 0; i < inventory.a.length; ++i) {
+ if (inventory.a[i] != null) {
+ loot.add(new CraftItemStack(inventory.a[i]));
+ }
+ }
+
+ for (int i = 0; i < inventory.b.length; ++i) {
+ if (inventory.b[i] != null) {
+ loot.add(new CraftItemStack(inventory.b[i]));
+ }
+ }
+
+ CraftEntity ent = (CraftEntity)getBukkitEntity();
+ EntityDeathEvent event = new EntityDeathEvent(Event.Type.ENTITY_DEATH, ent, 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(ent.getLocation(), stack);
+ }
+ // Craftbukkit end
}
public boolean a(Entity entity, int i) {