From 1e159ac83200f109c8c1052ffa7fb1d656ede5d7 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 3 Jan 2011 17:44:43 +0800 Subject: [PATCH] Added LivingEntity.throwEgg() and LivingEntity.throwSnowball(). By: sk89q --- .../java/org/bukkit/craftbukkit/CraftEgg.java | 15 +++++++++++++ .../bukkit/craftbukkit/CraftLivingEntity.java | 21 +++++++++++++++++++ .../org/bukkit/craftbukkit/CraftSnowball.java | 15 +++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftEgg.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/CraftSnowball.java diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEgg.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEgg.java new file mode 100644 index 0000000000..d0a5ee8979 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftEgg.java @@ -0,0 +1,15 @@ +package org.bukkit.craftbukkit; + +import net.minecraft.server.EntityEgg; +import org.bukkit.Egg; + +/** + * An egg. + * + * @author sk89q + */ +public class CraftEgg extends CraftEntity implements Egg { + public CraftEgg(CraftServer server, EntityEgg ent) { + super(server, ent); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLivingEntity.java index 9212bad9ce..b94af6bfe7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftLivingEntity.java @@ -2,8 +2,13 @@ package org.bukkit.craftbukkit; import net.minecraft.server.Entity; +import net.minecraft.server.EntityEgg; import net.minecraft.server.EntityLiving; +import net.minecraft.server.EntitySnowball; + +import org.bukkit.Egg; import org.bukkit.LivingEntity; +import org.bukkit.Snowball; public class CraftLivingEntity extends CraftEntity implements LivingEntity { private EntityLiving entity; @@ -39,4 +44,20 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { public String toString() { return "CraftLivingEntity{" + "id=" + getEntityID() + '}'; } + + @Override + public Egg throwEgg() { + net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle(); + EntityEgg egg = new EntityEgg(world, entity); + world.a(egg); + return new CraftEgg(server, egg); + } + + @Override + public Snowball throwSnowball() { + net.minecraft.server.World world = ((CraftWorld)getWorld()).getHandle(); + EntitySnowball snowball = new EntitySnowball(world, entity); + world.a(snowball); + return new CraftSnowball(server, snowball); + } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSnowball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSnowball.java new file mode 100644 index 0000000000..1cefa011a0 --- /dev/null +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftSnowball.java @@ -0,0 +1,15 @@ +package org.bukkit.craftbukkit; + +import net.minecraft.server.EntitySnowball; +import org.bukkit.Snowball; + +/** + * A snowball. + * + * @author sk89q + */ +public class CraftSnowball extends CraftEntity implements Snowball { + public CraftSnowball(CraftServer server, EntitySnowball ent) { + super(server, ent); + } +}