Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Improve entity hierarchy by adding Mob interface.
Dieser Commit ist enthalten in:
Ursprung
0e1d79b449
Commit
50e6858b72
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
39
src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
Normale Datei
39
src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
Normale Datei
@ -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";
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren