summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorsk89q <the.sk89q@gmail.com>2011-01-07 14:01:37 -0800
committersk89q <the.sk89q@gmail.com>2011-01-07 14:01:37 -0800
commit6d6668aaeb785b204e53e67d68261207e66c9230 (patch)
treecf9a9716bd4bf2832a6f998394e2ff6c67ceefa1 /src/main/java/org/bukkit
parenteb2cc2da4a435052d4053c7102081cf702e88c22 (diff)
downloadcraftbukkit-6d6668aaeb785b204e53e67d68261207e66c9230.tar
craftbukkit-6d6668aaeb785b204e53e67d68261207e66c9230.tar.gz
craftbukkit-6d6668aaeb785b204e53e67d68261207e66c9230.tar.lz
craftbukkit-6d6668aaeb785b204e53e67d68261207e66c9230.tar.xz
craftbukkit-6d6668aaeb785b204e53e67d68261207e66c9230.zip
Implemented World.spawnBoat(), added CraftMappable interface that defines a method to get an org.bukkit.craftbukkit.CraftEntity from implementing net.minecart.server.Entity entities, changed CraftWorld.toCraftEntity() to use this new interface for boats and minecarts.
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftMappable.java16
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java19
2 files changed, 27 insertions, 8 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftMappable.java b/src/main/java/org/bukkit/craftbukkit/CraftMappable.java
new file mode 100644
index 00000000..9bcc4b99
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/CraftMappable.java
@@ -0,0 +1,16 @@
+package org.bukkit.craftbukkit;
+
+/**
+ * Indicates that an object has a method to get its CraftBukkit-equivalent
+ * CraftEntity object from its Minecraft net.minecraft.server.Entity object.
+ *
+ * @author sk89q
+ */
+public interface CraftMappable {
+ /**
+ * Gets the CraftEntity version.
+ *
+ * @return
+ */
+ public CraftEntity getCraftEntity();
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index b236c2ca..fb6d67f6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -7,6 +7,7 @@ import java.util.Map;
import net.minecraft.server.EntityMinecart;
import java.util.Random;
+import net.minecraft.server.EntityBoat;
import net.minecraft.server.EntityEgg;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityPlayerMP;
@@ -18,6 +19,7 @@ import net.minecraft.server.WorldServer;
import net.minecraft.server.WorldGenTrees;
import org.bukkit.Arrow;
import org.bukkit.Block;
+import org.bukkit.Boat;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Minecart;
@@ -144,6 +146,13 @@ public class CraftWorld implements World {
return new CraftPoweredMinecart(world.getServer(), minecart);
}
+ public Boat spawnBoat(Location loc) {
+ EntityBoat boat =
+ new EntityBoat(world, loc.getX(), loc.getY(), loc.getZ());
+ world.a(boat);
+ return new CraftBoat(world.getServer(), boat);
+ }
+
public boolean generateTree(Location loc) {
WorldGenTrees treeGen = new WorldGenTrees();
return treeGen.a(world, rand,
@@ -165,18 +174,12 @@ public class CraftWorld implements World {
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 if (entity instanceof CraftMappable) {
+ return ((CraftMappable)entity).getCraftEntity();
} else {
return null;
}