diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java index 086980e76d..734f54891a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java @@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Ambient; import org.bukkit.entity.EntityType; -public class CraftAmbient extends CraftLivingEntity implements Ambient { +public class CraftAmbient extends CraftMob implements Ambient { public CraftAmbient(CraftServer server, EntityAmbient entity) { super(server, entity); } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java index 09d42141fb..73db6101bc 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java @@ -3,28 +3,12 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityCreature; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Creature; -import org.bukkit.entity.LivingEntity; -public class CraftCreature extends CraftLivingEntity implements Creature { +public class CraftCreature extends CraftMob implements Creature { public CraftCreature(CraftServer server, EntityCreature entity) { super(server, entity); } - public void setTarget(LivingEntity target) { - EntityCreature entity = getHandle(); - if (target == null) { - entity.setGoalTarget(null, null, false); - } else if (target instanceof CraftLivingEntity) { - entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false); - } - } - - public CraftLivingEntity getTarget() { - if (getHandle().getGoalTarget() == null) return null; - - return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity(); - } - @Override public EntityCreature getHandle() { return (EntityCreature) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java index f374c7b880..6b0c33b391 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java @@ -4,7 +4,7 @@ import net.minecraft.server.EntityFlying; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Flying; -public class CraftFlying extends CraftLivingEntity implements Flying { +public class CraftFlying extends CraftMob implements Flying { public CraftFlying(CraftServer server, EntityFlying entity) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java new file mode 100644 index 0000000000..43178db810 --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.entity; + +import net.minecraft.server.EntityInsentient; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Mob; + +public abstract class CraftMob extends CraftLivingEntity implements Mob { + public CraftMob(CraftServer server, EntityInsentient entity) { + super(server, entity); + } + + @Override + public void setTarget(LivingEntity target) { + EntityInsentient entity = getHandle(); + if (target == null) { + entity.setGoalTarget(null, null, false); + } else if (target instanceof CraftLivingEntity) { + entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false); + } + } + + @Override + public CraftLivingEntity getTarget() { + if (getHandle().getGoalTarget() == null) return null; + + return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity(); + } + + @Override + public EntityInsentient getHandle() { + return (EntityInsentient) entity; + } + + @Override + public String toString() { + return "CraftMob"; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java index 6bf30c834c..18e7ef80ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java @@ -4,10 +4,9 @@ import net.minecraft.server.EntitySlime; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; -import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Slime; -public class CraftSlime extends CraftLivingEntity implements Slime { +public class CraftSlime extends CraftMob implements Slime { public CraftSlime(CraftServer server, EntitySlime entity) { super(server, entity); @@ -21,20 +20,6 @@ public class CraftSlime extends CraftLivingEntity implements Slime { getHandle().setSize(size, true); } - @Override - public void setTarget(LivingEntity target) { - if (target == null) { - getHandle().setGoalTarget(null, null, false); - } else if (target instanceof CraftLivingEntity) { - getHandle().setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false); - } - } - - @Override - public LivingEntity getTarget() { - return getHandle().getGoalTarget() == null ? null : (LivingEntity)getHandle().getGoalTarget().getBukkitEntity(); - } - @Override public EntitySlime getHandle() { return (EntitySlime) entity;