summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-01-07 12:00:44 -0800
committersk89q <the.sk89q@gmail.com>2011-01-07 12:07:16 -0800
commit4de1915f6ae201ed691395a27684e3db5d607f56 (patch)
treed7eac03e54dbda059a67395dcf388202ec9ccde0
parent65de896c15b32fd939a1c6741454beea5ab7bbb9 (diff)
downloadcraftbukkit-4de1915f6ae201ed691395a27684e3db5d607f56.tar
craftbukkit-4de1915f6ae201ed691395a27684e3db5d607f56.tar.gz
craftbukkit-4de1915f6ae201ed691395a27684e3db5d607f56.tar.lz
craftbukkit-4de1915f6ae201ed691395a27684e3db5d607f56.tar.xz
craftbukkit-4de1915f6ae201ed691395a27684e3db5d607f56.zip
Added World.toCraftEntity() to convert Minecraft entities to CraftBukkit entities.
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 74c49a9e..b236c2ca 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -6,9 +6,15 @@ import java.util.Map;
import net.minecraft.server.EntityMinecart;
import java.util.Random;
+
+import net.minecraft.server.EntityEgg;
+import net.minecraft.server.EntityLiving;
+import net.minecraft.server.EntityPlayerMP;
+import net.minecraft.server.EntitySnowball;
+import net.minecraft.server.EntityArrow;
+import net.minecraft.server.EntityPlayer;
import net.minecraft.server.WorldGenBigTree;
import net.minecraft.server.WorldServer;
-import net.minecraft.server.EntityArrow;
import net.minecraft.server.WorldGenTrees;
import org.bukkit.Arrow;
import org.bukkit.Block;
@@ -149,6 +155,32 @@ public class CraftWorld implements World {
return treeGen.a(world, rand,
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
+
+ public CraftEntity toCraftEntity(net.minecraft.server.Entity entity) {
+ if (entity instanceof EntityArrow) {
+ return new CraftArrow(world.getServer(), (EntityArrow)entity);
+ } else if (entity instanceof EntityEgg) {
+ return new CraftEgg(world.getServer(), (EntityEgg)entity);
+ } else if (entity instanceof EntityPlayerMP) {
+ return new CraftPlayer(world.getServer(), (EntityPlayerMP)entity);
+ } else if (entity instanceof EntitySnowball) {
+ return new CraftSnowball(world.getServer(), (EntitySnowball)entity);
+ } else if (entity instanceof EntityMinecart) {
+ EntityMinecart minecart = (EntityMinecart)entity;
+ if (minecart.minecart != null) {
+ return minecart.minecart;
+ }
+
+ return CraftMinecart.getCraftMinecart(world.getServer(),
+ (EntityMinecart)entity);
+ } else if (entity instanceof EntityPlayer) {
+ return new CraftHumanEntity(world.getServer(), (EntityPlayer)entity);
+ } else if (entity instanceof EntityLiving) {
+ return new CraftLivingEntity(world.getServer(), (EntityLiving)entity);
+ } else {
+ return null;
+ }
+ }
@Override
public String toString() {