summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-08-10 19:48:09 +1000
committermd_5 <git@md-5.net>2018-08-10 19:48:09 +1000
commit50e6858b72343827ddc8ca15a387fa950d459e3a (patch)
tree0400775c3f9d3eb17f9f49f0c0297997f6269a96 /src/main
parent0e1d79b44960de50725955c9bb87c2772c62855a (diff)
downloadcraftbukkit-50e6858b72343827ddc8ca15a387fa950d459e3a.tar
craftbukkit-50e6858b72343827ddc8ca15a387fa950d459e3a.tar.gz
craftbukkit-50e6858b72343827ddc8ca15a387fa950d459e3a.tar.lz
craftbukkit-50e6858b72343827ddc8ca15a387fa950d459e3a.tar.xz
craftbukkit-50e6858b72343827ddc8ca15a387fa950d459e3a.zip
Improve entity hierarchy by adding Mob interface.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java18
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftFlying.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java39
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java17
5 files changed, 43 insertions, 35 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAmbient.java
index 086980e7..734f5489 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 09d42141..73db6101 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 f374c7b8..6b0c33b3 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 00000000..43178db8
--- /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 6bf30c83..18e7ef80 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);
@@ -22,20 +21,6 @@ public class CraftSlime extends CraftLivingEntity implements Slime {
}
@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;
}