summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-01-26 12:03:54 -0800
committersk89q <the.sk89q@gmail.com>2011-01-26 12:48:37 -0800
commit7a898bdba8257a5f98ebdae99fa38b4429ca5828 (patch)
treeb61d025ee8bcf3f5ac22536da4ac9b15db30487e
parentc07e32c1de57898d5f7ad2fbfa0800d65fc20f5a (diff)
downloadcraftbukkit-7a898bdba8257a5f98ebdae99fa38b4429ca5828.tar
craftbukkit-7a898bdba8257a5f98ebdae99fa38b4429ca5828.tar.gz
craftbukkit-7a898bdba8257a5f98ebdae99fa38b4429ca5828.tar.lz
craftbukkit-7a898bdba8257a5f98ebdae99fa38b4429ca5828.tar.xz
craftbukkit-7a898bdba8257a5f98ebdae99fa38b4429ca5828.zip
Added methods to get a list of entities to World. This replies on net.minecraft.server.Entity.bukkitEntity not being null (otherwise it won't be returned).
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index e4989c4e..ce456411 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -3,8 +3,11 @@ package org.bukkit.craftbukkit;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.*;
import org.bukkit.entity.*;
+import org.bukkit.entity.Entity;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.server.*;
@@ -316,4 +319,46 @@ public class CraftWorld implements World {
return hash;
}
}
+
+ @Override
+ public List<Entity> getEntities() {
+ List<Entity> list = new ArrayList<Entity>();
+
+ for (Object o : world.b) {
+ if (o instanceof net.minecraft.server.Entity) {
+ net.minecraft.server.Entity mcEnt
+ = (net.minecraft.server.Entity)o;
+
+ Entity bukkitEntity = mcEnt.getBukkitEntity();
+
+ // Assuming that bukkitEntity isn't null
+ if (bukkitEntity != null) {
+ list.add(bukkitEntity);
+ }
+ }
+ }
+
+ return list;
+ }
+
+ @Override
+ public List<LivingEntity> getLivingEntities() {
+ List<LivingEntity> list = new ArrayList<LivingEntity>();
+
+ for (Object o : world.b) {
+ if (o instanceof net.minecraft.server.Entity) {
+ net.minecraft.server.Entity mcEnt
+ = (net.minecraft.server.Entity)o;
+
+ Entity bukkitEntity = mcEnt.getBukkitEntity();
+
+ // Assuming that bukkitEntity isn't null
+ if (bukkitEntity != null && bukkitEntity instanceof LivingEntity) {
+ list.add((LivingEntity)bukkitEntity);
+ }
+ }
+ }
+
+ return list;
+ }
}