Fix build
This commit is contained in:
parent
fdc083616b
commit
2fc1005d68
|
@ -38,6 +38,13 @@
|
|||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>citizens-v1_10_R1</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,172 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftBat;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityBat;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class BatController extends MobEntityController {
|
||||
public BatController() {
|
||||
super(EntityBatNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bat getBukkitEntity() {
|
||||
return (Bat) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class BatNPC extends CraftBat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public BatNPC(EntityBatNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityBatNPC extends EntityBat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityBatNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityBatNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
setFlying(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new BatNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
return super.isLeashed();
|
||||
}
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFlying(boolean flying) {
|
||||
setAsleep(flying);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,163 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftBlaze;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityBlaze;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class BlazeController extends MobEntityController {
|
||||
public BlazeController() {
|
||||
super(EntityBlazeNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blaze getBukkitEntity() {
|
||||
return (Blaze) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class BlazeNPC extends CraftBlaze implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public BlazeNPC(EntityBlazeNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityBlazeNPC extends EntityBlaze implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityBlazeNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityBlazeNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new BlazeNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftCaveSpider;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.CaveSpider;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityCaveSpider;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class CaveSpiderController extends MobEntityController {
|
||||
public CaveSpiderController() {
|
||||
super(EntityCaveSpiderNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaveSpider getBukkitEntity() {
|
||||
return (CaveSpider) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class CaveSpiderNPC extends CraftCaveSpider implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public CaveSpiderNPC(EntityCaveSpiderNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityCaveSpiderNPC extends EntityCaveSpider implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityCaveSpiderNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityCaveSpiderNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new CaveSpiderNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
return super.isLeashed();
|
||||
}
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault)) {
|
||||
return super.isLeashed();
|
||||
}
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,217 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftChicken;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityChicken;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ChickenController extends MobEntityController {
|
||||
public ChickenController() {
|
||||
super(EntityChickenNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chicken getBukkitEntity() {
|
||||
return (Chicken) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class ChickenNPC extends CraftChicken implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ChickenNPC(EntityChickenNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityChickenNPC extends EntityChicken implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityChickenNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityChickenNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new ChickenNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
if (npc != null) {
|
||||
this.bD = 100; // egg timer
|
||||
}
|
||||
super.n();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,210 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftCow;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityCow;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class CowController extends MobEntityController {
|
||||
public CowController() {
|
||||
super(EntityCowNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cow getBukkitEntity() {
|
||||
return (Cow) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class CowNPC extends CraftCow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public CowNPC(EntityCowNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityCowNPC extends EntityCow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityCowNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityCowNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new CowNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftCreeper;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityCreeper;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityLightning;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class CreeperController extends MobEntityController {
|
||||
public CreeperController() {
|
||||
super(EntityCreeperNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Creeper getBukkitEntity() {
|
||||
return (Creeper) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class CreeperNPC extends CraftCreeper implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public CreeperNPC(EntityCreeperNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityCreeperNPC extends EntityCreeper implements NPCHolder {
|
||||
private boolean allowPowered;
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityCreeperNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityCreeperNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
|
||||
return npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)
|
||||
? super.a(entityhuman, enumhand, itemstack) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.g(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new CreeperNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightningStrike(EntityLightning entitylightning) {
|
||||
if (npc == null || allowPowered) {
|
||||
super.onLightningStrike(entitylightning);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllowPowered(boolean allowPowered) {
|
||||
this.allowPowered = allowPowered;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEnderDragon;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityEnderDragon;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EnderDragonController extends MobEntityController {
|
||||
public EnderDragonController() {
|
||||
super(EntityEnderDragonNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderDragon getBukkitEntity() {
|
||||
return (EnderDragon) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderDragonNPC extends CraftEnderDragon implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderDragonNPC(EntityEnderDragonNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderDragonNPC extends EntityEnderDragon implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderDragonNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEnderDragonNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new EnderDragonNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
private float getCorrectYaw(double tX, double tZ) {
|
||||
if (locZ > tZ)
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ))));
|
||||
if (locZ < tZ) {
|
||||
return (float) (-Math.toDegrees(Math.atan((locX - tX) / (locZ - tZ)))) + 180.0F;
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (motX != 0 || motY != 0 || motZ != 0) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
yaw = getCorrectYaw(locX + motX, locZ + motZ);
|
||||
setPosition(locX + motX, locY + motY, locZ + motZ);
|
||||
}
|
||||
} else {
|
||||
super.n();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,214 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEnderman;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityEnderman;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EndermanController extends MobEntityController {
|
||||
public EndermanController() {
|
||||
super(EntityEndermanNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enderman getBukkitEntity() {
|
||||
return (Enderman) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EndermanNPC extends CraftEnderman implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EndermanNPC(EntityEndermanNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEndermanNPC extends EntityEnderman implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEndermanNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEndermanNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new EndermanNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean k(double d1, double d2, double d3) {
|
||||
if (npc == null) {
|
||||
return super.k(d1, d2, d3);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEndermite;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Endermite;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityEndermite;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EndermiteController extends MobEntityController {
|
||||
public EndermiteController() {
|
||||
super(EntityEndermiteNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Endermite getBukkitEntity() {
|
||||
return (Endermite) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EndermiteNPC extends CraftEndermite implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EndermiteNPC(EntityEndermiteNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEndermiteNPC extends EntityEndermite implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEndermiteNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEndermiteNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new EndermiteNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,475 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.MetadataStore;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.trait.trait.Inventory;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyNetHandler;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager;
|
||||
import net.citizensnpcs.nms.v1_10_R1.network.EmptySocket;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerLook;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerNavigation;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.skin.SkinPacketTracker;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.trait.Gravity;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EnumGamemode;
|
||||
import net.minecraft.server.v1_10_R1.EnumItemSlot;
|
||||
import net.minecraft.server.v1_10_R1.EnumProtocolDirection;
|
||||
import net.minecraft.server.v1_10_R1.GenericAttributes;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_10_R1.NavigationAbstract;
|
||||
import net.minecraft.server.v1_10_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityEquipment;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityHeadRotation;
|
||||
import net.minecraft.server.v1_10_R1.PathType;
|
||||
import net.minecraft.server.v1_10_R1.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity {
|
||||
private final Map<PathType, Float> bz = Maps.newEnumMap(PathType.class);
|
||||
private PlayerControllerJump controllerJump;
|
||||
private PlayerControllerLook controllerLook;
|
||||
private PlayerControllerMove controllerMove;
|
||||
private int jumpTicks = 0;
|
||||
private PlayerNavigation navigation;
|
||||
private final CitizensNPC npc;
|
||||
private final Location packetLocationCache = new Location(null, 0, 0, 0);
|
||||
private final SkinPacketTracker skinTracker;
|
||||
private int updateCounter = 0;
|
||||
|
||||
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
|
||||
PlayerInteractManager playerInteractManager, NPC npc) {
|
||||
super(minecraftServer, world, gameProfile, playerInteractManager);
|
||||
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
skinTracker = new SkinPacketTracker(this);
|
||||
playerInteractManager.setGameMode(EnumGamemode.SURVIVAL);
|
||||
initialise(minecraftServer);
|
||||
} else {
|
||||
skinTracker = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
public float a(PathType pathtype) {
|
||||
return this.bz.containsKey(pathtype) ? this.bz.get(pathtype).floatValue() : pathtype.a();
|
||||
}
|
||||
|
||||
public void a(PathType pathtype, float f) {
|
||||
this.bz.put(pathtype, Float.valueOf(f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
// knock back velocity is cancelled and sent to client for handling when
|
||||
// the entity is a player. there is no client so make this happen
|
||||
// manually.
|
||||
boolean damaged = super.damageEntity(damagesource, f);
|
||||
if (damaged && velocityChanged) {
|
||||
velocityChanged = false;
|
||||
Bukkit.getScheduler().runTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EntityHumanNPC.this.velocityChanged = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return damaged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die(DamageSource damagesource) {
|
||||
// players that die are not normally removed from the world. when the
|
||||
// NPC dies, we are done with the instance and it should be removed.
|
||||
if (dead) {
|
||||
return;
|
||||
}
|
||||
super.die(damagesource);
|
||||
Bukkit.getScheduler().runTaskLater(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
world.removeEntity(EntityHumanNPC.this);
|
||||
}
|
||||
}, 35); // give enough time for death and smoke animation
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.g(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftPlayer getBukkitEntity() {
|
||||
if (npc != null && bukkitEntity == null) {
|
||||
bukkitEntity = new PlayerNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public PlayerControllerJump getControllerJump() {
|
||||
return controllerJump;
|
||||
}
|
||||
|
||||
public PlayerControllerMove getControllerMove() {
|
||||
return controllerMove;
|
||||
}
|
||||
|
||||
public NavigationAbstract getNavigation() {
|
||||
return navigation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinName() {
|
||||
MetadataStore meta = npc.data();
|
||||
|
||||
String skinName = meta.get(NPC.PLAYER_SKIN_UUID_METADATA);
|
||||
if (skinName == null) {
|
||||
skinName = ChatColor.stripColor(getName());
|
||||
}
|
||||
return skinName.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkinPacketTracker getSkinTracker() {
|
||||
return skinTracker;
|
||||
}
|
||||
|
||||
private void initialise(MinecraftServer minecraftServer) {
|
||||
Socket socket = new EmptySocket();
|
||||
NetworkManager conn = null;
|
||||
try {
|
||||
conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
|
||||
playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
|
||||
conn.setPacketListener(playerConnection);
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
// swallow
|
||||
}
|
||||
|
||||
AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
|
||||
if (range == null) {
|
||||
range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
|
||||
}
|
||||
range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
|
||||
|
||||
controllerJump = new PlayerControllerJump(this);
|
||||
controllerLook = new PlayerControllerLook(this);
|
||||
controllerMove = new PlayerControllerMove(this);
|
||||
navigation = new PlayerNavigation(this, world);
|
||||
NMS.setStepHeight(getBukkitEntity(), 1); // the default (0) breaks step climbing
|
||||
|
||||
setSkinFlags((byte) 0xFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
return npc == null ? super.isCollidable() : npc.data().get(NPC.COLLIDABLE_METADATA, true);
|
||||
}
|
||||
|
||||
public boolean isNavigating() {
|
||||
return npc.getNavigator().isNavigating();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc == null)
|
||||
return;
|
||||
if (updateCounter + 1 > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||
updateEffects = true;
|
||||
}
|
||||
tickPotionEffects();
|
||||
|
||||
boolean navigating = npc.getNavigator().isNavigating();
|
||||
updatePackets(navigating);
|
||||
if (!navigating && getBukkitEntity() != null && npc.getTrait(Gravity.class).hasGravity()
|
||||
&& Util.isLoaded(getBukkitEntity().getLocation(LOADED_LOCATION))) {
|
||||
g(0, 0);
|
||||
}
|
||||
|
||||
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON) {
|
||||
motX = motY = motZ = 0;
|
||||
}
|
||||
if (navigating) {
|
||||
if (!NMSImpl.isNavigationFinished(navigation)) {
|
||||
NMSImpl.updateNavigation(navigation);
|
||||
}
|
||||
moveOnCurrentHeading();
|
||||
}
|
||||
|
||||
if (noDamageTicks > 0) {
|
||||
--noDamageTicks;
|
||||
}
|
||||
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void moveOnCurrentHeading() {
|
||||
NMSImpl.updateAI(this);
|
||||
if (be) {
|
||||
if (onGround && jumpTicks == 0) {
|
||||
cl();
|
||||
jumpTicks = 10;
|
||||
}
|
||||
} else {
|
||||
jumpTicks = 0;
|
||||
}
|
||||
bf *= 0.98F;
|
||||
bg *= 0.98F;
|
||||
bh *= 0.9F;
|
||||
g(bf, bg); // movement method
|
||||
NMS.setHeadYaw(getBukkitEntity(), yaw);
|
||||
if (jumpTicks > 0) {
|
||||
jumpTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMoveDestination(double x, double y, double z, double speed) {
|
||||
controllerMove.a(x, y, z, speed);
|
||||
}
|
||||
|
||||
public void setShouldJump() {
|
||||
controllerJump.a();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinFlags(byte flags) {
|
||||
// set skin flag byte
|
||||
getDataWatcher().set(EntityHuman.br, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String name) {
|
||||
setSkinName(name, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String name, boolean forceUpdate) {
|
||||
Preconditions.checkNotNull(name);
|
||||
|
||||
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, name.toLowerCase());
|
||||
skinTracker.notifySkinChange(forceUpdate);
|
||||
}
|
||||
|
||||
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
|
||||
controllerLook.a(target, yawOffset, renderOffset);
|
||||
}
|
||||
|
||||
public void updateAI() {
|
||||
controllerMove.c();
|
||||
controllerLook.a();
|
||||
controllerJump.b();
|
||||
}
|
||||
|
||||
private void updatePackets(boolean navigating) {
|
||||
if (updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||
updateCounter = 0;
|
||||
Location current = getBukkitEntity().getLocation(packetLocationCache);
|
||||
Packet<?>[] packets = new Packet[navigating ? EnumItemSlot.values().length
|
||||
: EnumItemSlot.values().length + 1];
|
||||
if (!navigating) {
|
||||
packets[5] = new PacketPlayOutEntityHeadRotation(this,
|
||||
(byte) MathHelper.d(NMSImpl.getHeadYaw(this) * 256.0F / 360.0F));
|
||||
}
|
||||
int i = 0;
|
||||
for (EnumItemSlot slot : EnumItemSlot.values()) {
|
||||
packets[i++] = new PacketPlayOutEntityEquipment(getId(), slot, getEquipment(slot));
|
||||
}
|
||||
NMSImpl.sendPacketsNearby(getBukkitEntity(), current, packets);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePathfindingRange(float pathfindingRange) {
|
||||
this.navigation.setRange(pathfindingRange);
|
||||
}
|
||||
|
||||
public static class PlayerNPC extends CraftPlayer implements NPCHolder, SkinnableEntity {
|
||||
private final CraftServer cserver;
|
||||
private final CitizensNPC npc;
|
||||
|
||||
private PlayerNPC(EntityHumanNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
this.cserver = (CraftServer) Bukkit.getServer();
|
||||
npc.getTrait(Inventory.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getBukkitEntity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityHumanNPC getHandle() {
|
||||
return (EntityHumanNPC) this.entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String metadataKey) {
|
||||
return cserver.getEntityMetadata().getMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinName() {
|
||||
return ((SkinnableEntity) this.entity).getSkinName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkinPacketTracker getSkinTracker() {
|
||||
return ((SkinnableEntity) this.entity).getSkinTracker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String metadataKey) {
|
||||
return cserver.getEntityMetadata().hasMetadata(this, metadataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
|
||||
cserver.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
|
||||
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinFlags(byte flags) {
|
||||
((SkinnableEntity) this.entity).setSkinFlags(flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String name) {
|
||||
((SkinnableEntity) this.entity).setSkinName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkinName(String skinName, boolean forceUpdate) {
|
||||
((SkinnableEntity) this.entity).setSkinName(skinName, forceUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
private static final float EPSILON = 0.005F;
|
||||
|
||||
private static final Location LOADED_LOCATION = new Location(null, 0, 0, 0);
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGhast;
|
||||
import org.bukkit.entity.Ghast;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityGhast;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class GhastController extends MobEntityController {
|
||||
public GhastController() {
|
||||
super(EntityGhastNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ghast getBukkitEntity() {
|
||||
return (Ghast) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityGhastNPC extends EntityGhast implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityGhastNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityGhastNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ct() {
|
||||
return npc != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new GhastNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
super.M();
|
||||
}
|
||||
}
|
||||
|
||||
public static class GhastNPC extends CraftGhast implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public GhastNPC(EntityGhastNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGiant;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityGiantZombie;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class GiantController extends MobEntityController {
|
||||
public GiantController() {
|
||||
super(EntityGiantNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Giant getBukkitEntity() {
|
||||
return (Giant) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityGiantNPC extends EntityGiantZombie implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityGiantNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityGiantNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new GiantNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GiantNPC extends CraftGiant implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public GiantNPC(EntityGiantNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,219 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftGuardian;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityGuardian;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class GuardianController extends MobEntityController {
|
||||
public GuardianController() {
|
||||
super(EntityGuardianNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Guardian getBukkitEntity() {
|
||||
return (Guardian) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityGuardianNPC extends EntityGuardian implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityGuardianNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityGuardianNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new GuardianNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc == null) {
|
||||
super.m();
|
||||
} else {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElder(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.setElder(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuardianNPC extends CraftGuardian implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public GuardianNPC(EntityGuardianNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftHorse;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.HorseModifiers;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityHorse;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class HorseController extends MobEntityController {
|
||||
public HorseController() {
|
||||
super(EntityHorseNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Horse getBukkitEntity() {
|
||||
return (Horse) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawn(Location at, NPC npc) {
|
||||
npc.getTrait(HorseModifiers.class);
|
||||
super.spawn(at, npc);
|
||||
}
|
||||
|
||||
public static class EntityHorseNPC extends EntityHorse implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityHorseNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityHorseNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
((Horse) getBukkitEntity()).setDomestication(((Horse) getBukkitEntity()).getMaxDomestication());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean di() {
|
||||
if (npc == null)
|
||||
return super.di();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
return super.di() && !protectedDefault;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new HorseNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
} else {
|
||||
NMS.setStepHeight(getBukkitEntity(), 1);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class HorseNPC extends CraftHorse implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public HorseNPC(EntityHorseNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.util.Colorizer;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.skin.Skin;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_10_R1.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
public class HumanController extends AbstractEntityController {
|
||||
public HumanController() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(final Location at, final NPC npc) {
|
||||
final WorldServer nmsWorld = ((CraftWorld) at.getWorld()).getHandle();
|
||||
String coloredName = Colorizer.parseColors(npc.getFullName());
|
||||
|
||||
String name = coloredName, prefix = null, suffix = null;
|
||||
if (coloredName.length() > 16) {
|
||||
prefix = coloredName.substring(0, 16);
|
||||
if (coloredName.length() > 30) {
|
||||
int len = 30;
|
||||
name = coloredName.substring(16, 30);
|
||||
if (NON_ALPHABET_MATCHER.matcher(name).matches()) {
|
||||
if (coloredName.length() >= 32) {
|
||||
len = 32;
|
||||
name = coloredName.substring(16, 32);
|
||||
} else if (coloredName.length() == 31) {
|
||||
len = 31;
|
||||
name = coloredName.substring(16, 31);
|
||||
}
|
||||
} else {
|
||||
name = ChatColor.RESET + name;
|
||||
}
|
||||
suffix = coloredName.substring(len);
|
||||
} else {
|
||||
name = coloredName.substring(16);
|
||||
if (!NON_ALPHABET_MATCHER.matcher(name).matches()) {
|
||||
name = ChatColor.RESET + name;
|
||||
}
|
||||
if (name.length() > 16) {
|
||||
suffix = name.substring(16);
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
}
|
||||
coloredName = coloredName.substring(0, 16);
|
||||
}
|
||||
|
||||
final String prefixCapture = prefix, suffixCapture = suffix;
|
||||
|
||||
UUID uuid = npc.getUniqueId();
|
||||
if (uuid.version() == 4) { // clear version
|
||||
long msb = uuid.getMostSignificantBits();
|
||||
msb &= ~0x0000000000004000L;
|
||||
msb |= 0x0000000000002000L;
|
||||
uuid = new UUID(msb, uuid.getLeastSignificantBits());
|
||||
}
|
||||
|
||||
final GameProfile profile = new GameProfile(uuid, name);
|
||||
|
||||
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
|
||||
new PlayerInteractManager(nmsWorld), npc);
|
||||
|
||||
Skin skin = handle.getSkinTracker().getSkin();
|
||||
if (skin != null) {
|
||||
skin.apply(handle);
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid())
|
||||
return;
|
||||
boolean removeFromPlayerList = npc.data().get("removefromplayerlist",
|
||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(),
|
||||
npc.data().get("removefromplayerlist", removeFromPlayerList));
|
||||
|
||||
if (Setting.USE_SCOREBOARD_TEAMS.asBoolean()) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
String teamName = profile.getId().toString().substring(0, 16);
|
||||
|
||||
Team team = scoreboard.getTeam(teamName);
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam(teamName);
|
||||
if (prefixCapture != null) {
|
||||
team.setPrefix(prefixCapture);
|
||||
}
|
||||
if (suffixCapture != null) {
|
||||
team.setSuffix(suffixCapture);
|
||||
}
|
||||
}
|
||||
team.addPlayer(handle.getBukkitEntity());
|
||||
|
||||
handle.getNPC().data().set(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA, teamName);
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
|
||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getBukkitEntity() {
|
||||
return (Player) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
Player entity = getBukkitEntity();
|
||||
if (entity != null) {
|
||||
NMS.removeFromWorld(entity);
|
||||
SkinnableEntity npc = entity instanceof SkinnableEntity ? (SkinnableEntity) entity : null;
|
||||
npc.getSkinTracker().onRemoveNPC();
|
||||
}
|
||||
super.remove();
|
||||
}
|
||||
|
||||
private static Pattern NON_ALPHABET_MATCHER = Pattern.compile(".*[^A-Za-z0-9_].*");
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftIronGolem;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityIronGolem;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class IronGolemController extends MobEntityController {
|
||||
public IronGolemController() {
|
||||
super(EntityIronGolemNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IronGolem getBukkitEntity() {
|
||||
return (IronGolem) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityIronGolemNPC extends EntityIronGolem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityIronGolemNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityIronGolemNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new IronGolemNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class IronGolemNPC extends CraftIronGolem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public IronGolemNPC(EntityIronGolemNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMagmaCube;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityMagmaCube;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MagmaCubeController extends MobEntityController {
|
||||
public MagmaCubeController() {
|
||||
super(EntityMagmaCubeNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagmaCube getBukkitEntity() {
|
||||
return (MagmaCube) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMagmaCubeNPC extends EntityMagmaCube implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMagmaCubeNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMagmaCubeNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3);
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new MagmaCubeNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MagmaCubeNPC extends CraftMagmaCube implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MagmaCubeNPC(EntityMagmaCubeNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public abstract class MobEntityController extends AbstractEntityController {
|
||||
private final Constructor<?> constructor;
|
||||
|
||||
protected MobEntityController(Class<?> clazz) {
|
||||
super(clazz);
|
||||
this.constructor = getConstructor(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
net.minecraft.server.v1_10_R1.Entity entity = createEntityFromClass(((CraftWorld) at.getWorld()).getHandle(),
|
||||
npc);
|
||||
entity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
|
||||
|
||||
// entity.onGround isn't updated right away - we approximate here so
|
||||
// that things like pathfinding still work *immediately* after spawn.
|
||||
org.bukkit.Material beneath = at.getBlock().getRelative(BlockFace.DOWN).getType();
|
||||
if (beneath.isBlock()) {
|
||||
entity.onGround = true;
|
||||
}
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
private net.minecraft.server.v1_10_R1.Entity createEntityFromClass(Object... args) {
|
||||
try {
|
||||
return (net.minecraft.server.v1_10_R1.Entity) constructor.newInstance(args);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Constructor<?> getConstructor(Class<?> clazz) {
|
||||
Constructor<?> constructor = CONSTRUCTOR_CACHE.get(clazz);
|
||||
if (constructor != null)
|
||||
return constructor;
|
||||
try {
|
||||
return clazz.getConstructor(World.class, NPC.class);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException("unable to find an entity constructor");
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = Maps.newHashMap();
|
||||
}
|
|
@ -1,208 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMushroomCow;
|
||||
import org.bukkit.entity.MushroomCow;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityMushroomCow;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MushroomCowController extends MobEntityController {
|
||||
|
||||
public MushroomCowController() {
|
||||
super(EntityMushroomCowNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MushroomCow getBukkitEntity() {
|
||||
return (MushroomCow) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMushroomCowNPC extends EntityMushroomCow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMushroomCowNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMushroomCowNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new MushroomCowNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MushroomCowNPC extends CraftMushroomCow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MushroomCowNPC(EntityMushroomCowNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftOcelot;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityOcelot;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class OcelotController extends MobEntityController {
|
||||
public OcelotController() {
|
||||
super(EntityOcelotNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ocelot getBukkitEntity() {
|
||||
return (Ocelot) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityOcelotNPC extends EntityOcelot implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityOcelotNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityOcelotNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new OcelotNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class OcelotNPC extends CraftOcelot implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public OcelotNPC(EntityOcelotNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,217 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPig;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityLightning;
|
||||
import net.minecraft.server.v1_10_R1.EntityPig;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class PigController extends MobEntityController {
|
||||
public PigController() {
|
||||
super(EntityPigNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pig getBukkitEntity() {
|
||||
return (Pig) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityPigNPC extends EntityPig implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityPigNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityPigNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new PigNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLightningStrike(EntityLightning entitylightning) {
|
||||
if (npc == null) {
|
||||
super.onLightningStrike(entitylightning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PigNPC extends CraftPig implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public PigNPC(EntityPigNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPigZombie;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityPigZombie;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class PigZombieController extends MobEntityController {
|
||||
|
||||
public PigZombieController() {
|
||||
super(EntityPigZombieNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PigZombie getBukkitEntity() {
|
||||
return (PigZombie) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityPigZombieNPC extends EntityPigZombie implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityPigZombieNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityPigZombieNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.g(x, y, z);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new PigZombieNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PigZombieNPC extends CraftPigZombie implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public PigZombieNPC(EntityPigZombieNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,177 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPolarBear;
|
||||
import org.bukkit.entity.PolarBear;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityPolarBear;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class PolarBearController extends MobEntityController {
|
||||
public PolarBearController() {
|
||||
super(EntityPolarBearNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PolarBear getBukkitEntity() {
|
||||
return (PolarBear) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityPolarBearNPC extends EntityPolarBear implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityPolarBearNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityPolarBearNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new PolarBearNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null) {
|
||||
return super.isLeashed();
|
||||
}
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc != null) {
|
||||
NMSImpl.updateAI(this);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PolarBearNPC extends CraftPolarBear implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public PolarBearNPC(EntityPolarBearNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,229 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftRabbit;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_10_R1.EntityRabbit;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class RabbitController extends MobEntityController {
|
||||
public RabbitController() {
|
||||
super(EntityRabbitNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rabbit getBukkitEntity() {
|
||||
return (Rabbit) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityRabbitNPC extends EntityRabbit implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityRabbitNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityRabbitNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new RabbitNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityLiving getGoalTarget() {
|
||||
return npc != null ? null : super.getGoalTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
if (npc != null) {
|
||||
super.M();
|
||||
this.be = npc.getNavigator().isNavigating();
|
||||
npc.update();
|
||||
} else {
|
||||
super.M();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRabbitType(int i) {
|
||||
if (npc != null) {
|
||||
if (NMSImpl.getRabbitTypeField() == null)
|
||||
return;
|
||||
this.datawatcher.set(NMSImpl.getRabbitTypeField(), i);
|
||||
return;
|
||||
}
|
||||
super.setRabbitType(i);
|
||||
}
|
||||
}
|
||||
|
||||
public static class RabbitNPC extends CraftRabbit implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public RabbitNPC(EntityRabbitNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSheep;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySheep;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SheepController extends MobEntityController {
|
||||
public SheepController() {
|
||||
super(EntitySheepNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheep getBukkitEntity() {
|
||||
return (Sheep) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySheepNPC extends EntitySheep implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySheepNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySheepNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SheepNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SheepNPC extends CraftSheep implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SheepNPC(EntitySheepNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,220 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftShulker;
|
||||
import org.bukkit.entity.Shulker;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityAIBodyControl;
|
||||
import net.minecraft.server.v1_10_R1.EntityShulker;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ShulkerController extends MobEntityController {
|
||||
public ShulkerController() {
|
||||
super(EntityShulkerNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shulker getBukkitEntity() {
|
||||
return (Shulker) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityShulkerNPC extends EntityShulker implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityShulkerNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityShulkerNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new ShulkerNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
if (npc == null) {
|
||||
super.n();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityAIBodyControl s() {
|
||||
return new EntityAIBodyControl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShulkerNPC extends CraftShulker implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ShulkerNPC(EntityShulkerNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSilverfish;
|
||||
import org.bukkit.entity.Silverfish;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySilverfish;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SilverfishController extends MobEntityController {
|
||||
public SilverfishController() {
|
||||
super(EntitySilverfishNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Silverfish getBukkitEntity() {
|
||||
return (Silverfish) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySilverfishNPC extends EntitySilverfish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySilverfishNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySilverfishNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SilverfishNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SilverfishNPC extends CraftSilverfish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SilverfishNPC(EntitySilverfishNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSkeleton;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySkeleton;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SkeletonController extends MobEntityController {
|
||||
public SkeletonController() {
|
||||
super(EntitySkeletonNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skeleton getBukkitEntity() {
|
||||
return (Skeleton) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySkeletonNPC extends EntitySkeleton implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySkeletonNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySkeletonNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SkeletonNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SkeletonNPC extends CraftSkeleton implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SkeletonNPC(EntitySkeletonNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSlime;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SlimeController extends MobEntityController {
|
||||
public SlimeController() {
|
||||
super(EntitySlimeNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slime getBukkitEntity() {
|
||||
return (Slime) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySlimeNPC extends EntitySlime implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySlimeNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySlimeNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
setSize(3);
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
this.moveController = new PlayerControllerMove(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d(EntityHuman human) {
|
||||
if (npc == null) {
|
||||
super.d(human);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SlimeNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlimeNPC extends CraftSlime implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SlimeNPC(EntitySlimeNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,218 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSnowman;
|
||||
import org.bukkit.entity.Snowman;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySnowman;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SnowmanController extends MobEntityController {
|
||||
public SnowmanController() {
|
||||
super(EntitySnowmanNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowman getBukkitEntity() {
|
||||
return (Snowman) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySnowmanNPC extends EntitySnowman implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySnowmanNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySnowmanNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SnowmanNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void n() {
|
||||
boolean allowsGriefing = this.world.getGameRules().getBoolean("mobGriefing");
|
||||
if (npc != null) {
|
||||
this.world.getGameRules().set("mobGriefing", "false");
|
||||
}
|
||||
super.n();
|
||||
if (npc != null) {
|
||||
this.world.getGameRules().set("mobGriefing", Boolean.toString(allowsGriefing));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SnowmanNPC extends CraftSnowman implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SnowmanNPC(EntitySnowmanNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSpider;
|
||||
import org.bukkit.entity.Spider;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySpider;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SpiderController extends MobEntityController {
|
||||
public SpiderController() {
|
||||
super(EntitySpiderNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spider getBukkitEntity() {
|
||||
return (Spider) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySpiderNPC extends EntitySpider implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySpiderNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySpiderNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SpiderNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SpiderNPC extends CraftSpider implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SpiderNPC(EntitySpiderNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,198 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSquid;
|
||||
import org.bukkit.entity.Squid;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntitySquid;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SquidController extends MobEntityController {
|
||||
public SquidController() {
|
||||
super(EntitySquidNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Squid getBukkitEntity() {
|
||||
return (Squid) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySquidNPC extends EntitySquid implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySquidNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySquidNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new SquidNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SquidNPC extends CraftSquid implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SquidNPC(EntitySquidNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,228 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftVillager;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityVillager;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class VillagerController extends MobEntityController {
|
||||
public VillagerController() {
|
||||
super(EntityVillagerNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Villager getBukkitEntity() {
|
||||
return (Villager) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
|
||||
private boolean blockTrades = true;
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityVillagerNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityVillagerNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
|
||||
return npc == null || !blockTrades ? super.a(entityhuman) : false; // block trades
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new VillagerNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public boolean isBlockingTrades() {
|
||||
return blockTrades;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
NMS.setHeadYaw(getBukkitEntity(), yaw);
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlockTrades(boolean blocked) {
|
||||
this.blockTrades = blocked;
|
||||
}
|
||||
}
|
||||
|
||||
public static class VillagerNPC extends CraftVillager implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public VillagerNPC(EntityVillagerNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWitch;
|
||||
import org.bukkit.entity.Witch;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityWitch;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class WitchController extends MobEntityController {
|
||||
public WitchController() {
|
||||
super(EntityWitchNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Witch getBukkitEntity() {
|
||||
return (Witch) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityWitchNPC extends EntityWitch implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityWitchNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityWitchNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new WitchNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null)
|
||||
npc.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WitchNPC extends CraftWitch implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public WitchNPC(EntityWitchNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWither;
|
||||
import org.bukkit.entity.Wither;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityWither;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class WitherController extends MobEntityController {
|
||||
public WitherController() {
|
||||
super(EntityWitherNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wither getBukkitEntity() {
|
||||
return (Wither) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityWitherNPC extends EntityWither implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityWitherNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityWitherNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new WitherNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int m(int i) {
|
||||
return npc == null ? super.m(i) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void M() {
|
||||
if (npc == null) {
|
||||
super.M();
|
||||
}
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
public static class WitherNPC extends CraftWither implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public WitherNPC(EntityWitherNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,222 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWolf;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_10_R1.EntityWolf;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class WolfController extends MobEntityController {
|
||||
public WolfController() {
|
||||
super(EntityWolfNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wolf getBukkitEntity() {
|
||||
return (Wolf) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityWolfNPC extends EntityWolf implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityWolfNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityWolfNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean flag) {
|
||||
float oldw = width;
|
||||
float oldl = length;
|
||||
super.a(flag);
|
||||
if (oldw != width || oldl != length) {
|
||||
this.setPosition(locX - 0.01, locY, locZ - 0.01);
|
||||
this.setPosition(locX + 0.01, locY, locZ + 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new WolfNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setGoalTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fire) {
|
||||
return npc == null ? super.setGoalTarget(killer, reason, fire) : false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WolfNPC extends CraftWolf implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public WolfNPC(EntityWolfNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSitting(boolean sitting) {
|
||||
getHandle().setSitting(sitting);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftZombie;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityZombie;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.SoundEffect;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ZombieController extends MobEntityController {
|
||||
public ZombieController() {
|
||||
super(EntityZombieNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Zombie getBukkitEntity() {
|
||||
return (Zombie) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityZombieNPC extends EntityZombie implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityZombieNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityZombieNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
if (npc != null) {
|
||||
NMSImpl.clearGoals(goalSelector, targetSelector);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(double d0, boolean flag, IBlockData block, BlockPosition blockposition) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.a(d0, flag, block, blockposition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bV() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bV(), NPC.DEATH_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect bW() {
|
||||
return NMSImpl.getSoundEffect(npc, super.bW(), NPC.HURT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.e(f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enderTeleportTo(double d0, double d1, double d2) {
|
||||
if (npc == null)
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
super.enderTeleportTo(d0, d1, d2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(float f, float f1) {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
super.g(f, f1);
|
||||
} else {
|
||||
NMSImpl.flyingMoveLogic(this, f, f1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEffect G() {
|
||||
return NMSImpl.getSoundEffect(npc, super.G(), NPC.AMBIENT_SOUND_METADATA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null)
|
||||
bukkitEntity = new ZombieNPC(this);
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeashed() {
|
||||
if (npc == null)
|
||||
return super.isLeashed();
|
||||
boolean protectedDefault = npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
if (!protectedDefault || !npc.data().get(NPC.LEASH_PROTECTED_METADATA, protectedDefault))
|
||||
return super.isLeashed();
|
||||
if (super.isLeashed()) {
|
||||
unleash(true, false); // clearLeash with client update
|
||||
}
|
||||
return false; // shouldLeash
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void L() {
|
||||
if (npc == null) {
|
||||
super.L();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void M() {
|
||||
super.M();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean m_() {
|
||||
if (npc == null || !npc.isFlyable()) {
|
||||
return super.m_();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ZombieNPC extends CraftZombie implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ZombieNPC(EntityZombieNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftAreaEffectCloud;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityAreaEffectCloud;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class AreaEffectCloudController extends MobEntityController {
|
||||
public AreaEffectCloudController() {
|
||||
super(EntityAreaEffectCloudNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AreaEffectCloud getBukkitEntity() {
|
||||
return (AreaEffectCloud) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class AreaEffectCloudNPC extends CraftAreaEffectCloud implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public AreaEffectCloudNPC(EntityAreaEffectCloudNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityAreaEffectCloudNPC extends EntityAreaEffectCloud implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityAreaEffectCloudNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityAreaEffectCloudNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new AreaEffectCloudNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityArmorStand;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.EnumInteractionResult;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.Vec3D;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ArmorStandController extends MobEntityController {
|
||||
public ArmorStandController() {
|
||||
super(EntityArmorStandNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorStand getBukkitEntity() {
|
||||
return (ArmorStand) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class ArmorStandNPC extends CraftArmorStand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ArmorStandNPC(EntityArmorStandNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityArmorStandNPC extends EntityArmorStand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityArmorStandNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityArmorStandNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman entityhuman, Vec3D vec3d, ItemStack itemstack, EnumHand enumhand) {
|
||||
if (npc == null) {
|
||||
return super.a(entityhuman, vec3d, itemstack, enumhand);
|
||||
}
|
||||
PlayerInteractEntityEvent event = new PlayerInteractEntityEvent((Player) entityhuman.getBukkitEntity(),
|
||||
getBukkitEntity());
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event.isCancelled() ? EnumInteractionResult.FAIL : EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ArmorStandNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
super.m();
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftBoat;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityBoat;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class BoatController extends MobEntityController {
|
||||
public BoatController() {
|
||||
super(EntityBoatNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boat getBukkitEntity() {
|
||||
return (Boat) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class BoatNPC extends CraftBoat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public BoatNPC(EntityBoatNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityBoatNPC extends EntityBoat implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityBoatNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityBoatNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new BoatNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftDragonFireball;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.DragonFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityDragonFireball;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class DragonFireballController extends MobEntityController {
|
||||
public DragonFireballController() {
|
||||
super(EntityDragonFireballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DragonFireball getBukkitEntity() {
|
||||
return (DragonFireball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DragonFireballNPC extends CraftDragonFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public DragonFireballNPC(EntityDragonFireballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityDragonFireballNPC extends EntityDragonFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityDragonFireballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityDragonFireballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new DragonFireballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityEgg;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEgg;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EggController extends AbstractEntityController {
|
||||
public EggController() {
|
||||
super(EntityEggNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
|
||||
final EntityEggNPC handle = new EntityEggNPC(ws, npc, at.getX(), at.getY(), at.getZ());
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Egg getBukkitEntity() {
|
||||
return (Egg) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EggNPC extends CraftEgg implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EggNPC(EntityEggNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEggNPC extends EntityEgg implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEggNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEggNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntityEggNPC(World world, NPC npc, double d0, double d1, double d2) {
|
||||
super(world, d0, d1, d2);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EggNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityEnderCrystal;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEnderCrystal;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderCrystal;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderCrystalController extends MobEntityController {
|
||||
public EnderCrystalController() {
|
||||
super(EntityEnderCrystalNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderCrystal getBukkitEntity() {
|
||||
return (EnderCrystal) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderCrystalNPC extends CraftEnderCrystal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderCrystalNPC(EntityEnderCrystalNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderCrystalNPC extends EntityEnderCrystal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderCrystalNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntityEnderCrystalNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderCrystalNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEnderPearl;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityEnderPearl;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class EnderPearlController extends MobEntityController {
|
||||
public EnderPearlController() {
|
||||
super(EntityEnderPearlNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderPearl getBukkitEntity() {
|
||||
return (EnderPearl) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderPearlNPC extends CraftEnderPearl implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderPearlNPC(EntityEnderPearlNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderPearlNPC extends EntityEnderPearl implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderPearlNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityEnderPearlNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderPearlNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityEnderSignal;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEnderSignal;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.EnderSignal;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EnderSignalController extends MobEntityController {
|
||||
public EnderSignalController() {
|
||||
super(EntityEnderSignalNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnderSignal getBukkitEntity() {
|
||||
return (EnderSignal) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EnderSignalNPC extends CraftEnderSignal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EnderSignalNPC(EntityEnderSignalNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntityEnderSignalNPC extends EntityEnderSignal implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityEnderSignalNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntityEnderSignalNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new EnderSignalNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityExperienceOrb;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftExperienceOrb;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ExperienceOrbController extends MobEntityController {
|
||||
public ExperienceOrbController() {
|
||||
super(EntityExperienceOrbNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceOrb getBukkitEntity() {
|
||||
return (ExperienceOrb) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityExperienceOrbNPC extends EntityExperienceOrb implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityExperienceOrbNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityExperienceOrbNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ExperienceOrbNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExperienceOrbNPC extends CraftExperienceOrb implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ExperienceOrbNPC(EntityExperienceOrbNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftFallingSand;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.Block;
|
||||
import net.minecraft.server.v1_10_R1.Blocks;
|
||||
import net.minecraft.server.v1_10_R1.EntityFallingBlock;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
public class FallingBlockController extends AbstractEntityController {
|
||||
public FallingBlockController() {
|
||||
super(EntityFallingBlockNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
|
||||
Block id = Blocks.STONE;
|
||||
int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
|
||||
if (npc.data().has("falling-block-id") || npc.data().has(NPC.ITEM_ID_METADATA)) {
|
||||
id = CraftMagicNumbers.getBlock(Material.getMaterial(
|
||||
npc.data().<String> get(NPC.ITEM_ID_METADATA, npc.data().<String> get("falling-block-id"))));
|
||||
}
|
||||
final EntityFallingBlockNPC handle = new EntityFallingBlockNPC(ws, npc, at.getX(), at.getY(), at.getZ(),
|
||||
id.fromLegacyData(data));
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlock getBukkitEntity() {
|
||||
return (FallingBlock) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFallingBlockNPC extends EntityFallingBlock implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFallingBlockNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFallingBlockNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
public EntityFallingBlockNPC(World world, NPC npc, double d0, double d1, double d2, IBlockData data) {
|
||||
super(world, d0, d1, d2, data);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FallingBlockNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (Math.abs(motX) > EPSILON || Math.abs(motY) > EPSILON || Math.abs(motZ) > EPSILON) {
|
||||
motX *= 0.98;
|
||||
motY *= 0.98;
|
||||
motZ *= 0.98;
|
||||
move(motX, motY, motZ);
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
private static final double EPSILON = 0.001;
|
||||
}
|
||||
|
||||
public static class FallingBlockNPC extends CraftFallingSand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FallingBlockNPC(EntityFallingBlockNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public void setType(Material material, int data) {
|
||||
npc.data().setPersistent(NPC.ITEM_ID_METADATA, material.name());
|
||||
npc.data().setPersistent(NPC.ITEM_DATA_METADATA, data);
|
||||
if (npc.isSpawned()) {
|
||||
npc.despawn();
|
||||
npc.spawn(npc.getStoredLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityFireworks;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftFirework;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class FireworkController extends MobEntityController {
|
||||
public FireworkController() {
|
||||
super(EntityFireworkNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Firework getBukkitEntity() {
|
||||
return (Firework) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFireworkNPC extends EntityFireworks implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFireworkNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFireworkNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FireworkNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FireworkNPC extends CraftFirework implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FireworkNPC(EntityFireworkNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftFish;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityFishingHook;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class FishingHookController extends MobEntityController {
|
||||
public FishingHookController() {
|
||||
super(EntityFishingHookNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FishHook getBukkitEntity() {
|
||||
return (FishHook) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityFishingHookNPC extends EntityFishingHook implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityFishingHookNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityFishingHookNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new FishingHookNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FishingHookNPC extends CraftFish implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public FishingHookNPC(EntityFishingHookNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.AbstractEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_10_R1.EntityItem;
|
||||
import net.minecraft.server.v1_10_R1.ItemStack;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftItem;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ItemController extends AbstractEntityController {
|
||||
public ItemController() {
|
||||
super(EntityItemNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
WorldServer ws = ((CraftWorld) at.getWorld()).getHandle();
|
||||
Material id = Material.STONE;
|
||||
int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
|
||||
if (npc.data().has(NPC.ITEM_ID_METADATA)) {
|
||||
id = Material.getMaterial(npc.data().<String> get(NPC.ITEM_ID_METADATA));
|
||||
}
|
||||
final EntityItemNPC handle = new EntityItemNPC(ws, npc, at.getX(), at.getY(), at.getZ(),
|
||||
CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(id, 1, (short) data)));
|
||||
return handle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getBukkitEntity() {
|
||||
return (Item) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityItemNPC extends EntityItem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityItemNPC(World world) {
|
||||
super(world);
|
||||
this.npc = null;
|
||||
}
|
||||
|
||||
public EntityItemNPC(World world, NPC npc, double x, double y, double z, ItemStack stack) {
|
||||
super(world, x, y, z, stack);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d(EntityHuman entityhuman) {
|
||||
if (npc == null) {
|
||||
super.d(entityhuman);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ItemNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemNPC extends CraftItem implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ItemNPC(EntityItemNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public void setType(Material material, int data) {
|
||||
npc.data().setPersistent(NPC.ITEM_ID_METADATA, material.name());
|
||||
npc.data().setPersistent(NPC.ITEM_DATA_METADATA, data);
|
||||
if (npc.isSpawned()) {
|
||||
npc.despawn();
|
||||
npc.spawn(npc.getStoredLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftItemFrame;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityItemFrame;
|
||||
import net.minecraft.server.v1_10_R1.EnumDirection;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ItemFrameController extends MobEntityController {
|
||||
public ItemFrameController() {
|
||||
super(EntityItemFrameNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createEntity(Location at, NPC npc) {
|
||||
Entity e = super.createEntity(at, npc);
|
||||
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
|
||||
item.setDirection(EnumDirection.EAST);
|
||||
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
|
||||
return e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemFrame getBukkitEntity() {
|
||||
return (ItemFrame) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityItemFrameNPC extends EntityItemFrame implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityItemFrameNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityItemFrameNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ItemFrameNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ItemFrameNPC extends CraftItemFrame implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ItemFrameNPC(EntityItemFrameNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
Material id = Material.STONE;
|
||||
int data = npc.data().get(NPC.ITEM_DATA_METADATA, npc.data().get("falling-block-data", 0));
|
||||
if (npc.data().has(NPC.ITEM_ID_METADATA)) {
|
||||
id = Material.getMaterial(npc.data().<String> get(NPC.ITEM_ID_METADATA));
|
||||
}
|
||||
getItem().setType(id);
|
||||
getItem().setDurability((short) data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
public void setType(Material material, int data) {
|
||||
npc.data().setPersistent(NPC.ITEM_ID_METADATA, material.name());
|
||||
npc.data().setPersistent(NPC.ITEM_DATA_METADATA, data);
|
||||
if (npc.isSpawned()) {
|
||||
npc.despawn();
|
||||
npc.spawn(npc.getStoredLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,128 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLargeFireball;
|
||||
import org.bukkit.entity.LargeFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityLargeFireball;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class LargeFireballController extends MobEntityController {
|
||||
public LargeFireballController() {
|
||||
super(EntityLargeFireballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LargeFireball getBukkitEntity() {
|
||||
return (LargeFireball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityLargeFireballNPC extends EntityLargeFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityLargeFireballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityLargeFireballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new LargeFireballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(float f, float f1) {
|
||||
if (npc == null) {
|
||||
super.setSize(f, f1);
|
||||
} else {
|
||||
NMSImpl.setSize(this, f, f1, justCreated);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LargeFireballNPC extends CraftLargeFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public LargeFireballNPC(EntityLargeFireballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityLeash;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLeash;
|
||||
import org.bukkit.entity.LeashHitch;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class LeashController extends MobEntityController {
|
||||
public LeashController() {
|
||||
super(EntityLeashNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeashHitch getBukkitEntity() {
|
||||
return (LeashHitch) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityLeashNPC extends EntityLeash implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityLeashNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityLeashNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new LeashNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LeashNPC extends CraftLeash implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public LeashNPC(EntityLeashNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMinecartChest;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartChest;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartChestController extends MobEntityController {
|
||||
public MinecartChestController() {
|
||||
super(EntityMinecartChestNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartChestNPC extends EntityMinecartChest implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartChestNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartChestNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartChestNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartChestNPC extends CraftMinecartChest implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartChestNPC(EntityMinecartChestNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMinecartCommand;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartCommandBlock;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartCommandController extends MobEntityController {
|
||||
public MinecartCommandController() {
|
||||
super(EntityMinecartCommandNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartCommandNPC extends EntityMinecartCommandBlock implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartCommandNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartCommandNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartCommandNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartCommandNPC extends CraftMinecartCommand implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartCommandNPC(EntityMinecartCommandNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMinecartFurnace;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartFurnace;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartFurnaceController extends MobEntityController {
|
||||
public MinecartFurnaceController() {
|
||||
super(EntityMinecartFurnaceNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartFurnaceNPC extends EntityMinecartFurnace implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartFurnaceNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartFurnaceNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartFurnaceNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartFurnaceNPC extends CraftMinecartFurnace implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartFurnaceNPC(EntityMinecartFurnaceNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartHopper;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartHopperController extends MobEntityController {
|
||||
public MinecartHopperController() {
|
||||
super(EntityMinecartHopperNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartHopperNPC extends EntityMinecartHopper implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartHopperNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartHopperNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftMinecartRideable;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartRideable;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartRideableController extends MobEntityController {
|
||||
public MinecartRideableController() {
|
||||
super(EntityMinecartRideableNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartRideableNPC extends EntityMinecartRideable implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartRideableNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartRideableNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new MinecartRideableNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MinecartRideableNPC extends CraftMinecartRideable implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public MinecartRideableNPC(EntityMinecartRideableNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartMobSpawner;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartSpawnerController extends MobEntityController {
|
||||
public MinecartSpawnerController() {
|
||||
super(EntityMinecartSpawnerNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartSpawnerNPC extends EntityMinecartMobSpawner implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartSpawnerNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartSpawnerNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.DamageSource;
|
||||
import net.minecraft.server.v1_10_R1.EntityMinecartTNT;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class MinecartTNTController extends MobEntityController {
|
||||
public MinecartTNTController() {
|
||||
super(EntityMinecartTNTNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Minecart getBukkitEntity() {
|
||||
return (Minecart) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityMinecartTNTNPC extends EntityMinecartTNT implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityMinecartTNTNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityMinecartTNTNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (npc == null || !npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
return super.damageEntity(damagesource, f);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
NMSImpl.minecartItemLogic(this);
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,120 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityPainting;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPainting;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PaintingController extends MobEntityController {
|
||||
public PaintingController() {
|
||||
super(EntityPaintingNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Painting getBukkitEntity() {
|
||||
return (Painting) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityPaintingNPC extends EntityPainting implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityPaintingNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityPaintingNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new PaintingNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
return npc == null || !npc.isProtected() ? super.survives() : true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class PaintingNPC extends CraftPainting implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public PaintingNPC(EntityPaintingNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftShulkerBullet;
|
||||
import org.bukkit.entity.ShulkerBullet;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityShulkerBullet;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ShulkerBulletController extends MobEntityController {
|
||||
public ShulkerBulletController() {
|
||||
super(EntityShulkerBulletNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShulkerBullet getBukkitEntity() {
|
||||
return (ShulkerBullet) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityShulkerBulletNPC extends EntityShulkerBullet implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityShulkerBulletNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityShulkerBulletNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ShulkerBulletNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ShulkerBulletNPC extends CraftShulkerBullet implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ShulkerBulletNPC(EntityShulkerBulletNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSmallFireball;
|
||||
import org.bukkit.entity.SmallFireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntitySmallFireball;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SmallFireballController extends MobEntityController {
|
||||
public SmallFireballController() {
|
||||
super(EntitySmallFireballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmallFireball getBukkitEntity() {
|
||||
return (SmallFireball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySmallFireballNPC extends EntitySmallFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySmallFireballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySmallFireballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new SmallFireballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SmallFireballNPC extends CraftSmallFireball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SmallFireballNPC(EntitySmallFireballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntitySnowball;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftSnowball;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SnowballController extends MobEntityController {
|
||||
public SnowballController() {
|
||||
super(EntitySnowballNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowball getBukkitEntity() {
|
||||
return (Snowball) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class SnowballNPC extends CraftSnowball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SnowballNPC(EntitySnowballNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EntitySnowballNPC extends EntitySnowball implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySnowballNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntitySnowballNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new SnowballNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntitySpectralArrow;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class SpectralArrowController extends MobEntityController {
|
||||
public SpectralArrowController() {
|
||||
super(EntitySpectralArrowNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow getBukkitEntity() {
|
||||
return (Arrow) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntitySpectralArrowNPC extends EntitySpectralArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntitySpectralArrowNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntitySpectralArrowNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new SpectralArrowNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class SpectralArrowNPC extends CraftArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SpectralArrowNPC(EntitySpectralArrowNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityTNTPrimed;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftTNTPrimed;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TNTPrimedController extends MobEntityController {
|
||||
public TNTPrimedController() {
|
||||
super(EntityTNTPrimedNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TNTPrimed getBukkitEntity() {
|
||||
return (TNTPrimed) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityTNTPrimedNPC extends EntityTNTPrimed implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityTNTPrimedNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntityTNTPrimedNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new TNTPrimedNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TNTPrimedNPC extends CraftTNTPrimed implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public TNTPrimedNPC(EntityTNTPrimedNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,118 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityThrownExpBottle;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ThrownExpBottleController extends MobEntityController {
|
||||
public ThrownExpBottleController() {
|
||||
super(EntityThrownExpBottleNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThrownExpBottle getBukkitEntity() {
|
||||
return (ThrownExpBottle) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityThrownExpBottleNPC extends EntityThrownExpBottle implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityThrownExpBottleNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityThrownExpBottleNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new ThrownExpBottleNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) {
|
||||
super.m();
|
||||
}
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ThrownExpBottleNPC extends CraftThrownExpBottle implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public ThrownExpBottleNPC(EntityThrownExpBottleNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftLingeringPotion;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityPotion;
|
||||
import net.minecraft.server.v1_10_R1.Items;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class ThrownPotionController extends MobEntityController {
|
||||
public ThrownPotionController() {
|
||||
super(EntityThrownPotionNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThrownPotion getBukkitEntity() {
|
||||
return (ThrownPotion) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityThrownPotionNPC extends EntityPotion implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityThrownPotionNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityThrownPotionNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
if (getItem() != null && getItem().getItem().equals(Items.LINGERING_POTION)) {
|
||||
bukkitEntity = new LingeringThrownPotionNPC(this);
|
||||
} else {
|
||||
bukkitEntity = new SplashThrownPotionNPC(this);
|
||||
}
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LingeringThrownPotionNPC extends CraftLingeringPotion implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public LingeringThrownPotionNPC(EntityThrownPotionNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SplashThrownPotionNPC extends CraftLingeringPotion implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public SplashThrownPotionNPC(EntityThrownPotionNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityTippedArrow;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class TippedArrowController extends MobEntityController {
|
||||
public TippedArrowController() {
|
||||
super(EntityTippedArrowNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow getBukkitEntity() {
|
||||
return (Arrow) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityTippedArrowNPC extends EntityTippedArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityTippedArrowNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
public EntityTippedArrowNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new TippedArrowNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TippedArrowNPC extends CraftArrow implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public TippedArrowNPC(EntityTippedArrowNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.entity.nonliving;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.MobEntityController;
|
||||
import net.citizensnpcs.npc.CitizensNPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.v1_10_R1.EntityWitherSkull;
|
||||
import net.minecraft.server.v1_10_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftWitherSkull;
|
||||
import org.bukkit.entity.WitherSkull;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WitherSkullController extends MobEntityController {
|
||||
public WitherSkullController() {
|
||||
super(EntityWitherSkullNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WitherSkull getBukkitEntity() {
|
||||
return (WitherSkull) super.getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class EntityWitherSkullNPC extends EntityWitherSkull implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public EntityWitherSkullNPC(World world) {
|
||||
this(world, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d(NBTTagCompound save) {
|
||||
return npc == null ? super.d(save) : false;
|
||||
}
|
||||
|
||||
public EntityWitherSkullNPC(World world, NPC npc) {
|
||||
super(world);
|
||||
this.npc = (CitizensNPC) npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collide(net.minecraft.server.v1_10_R1.Entity entity) {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void g(double x, double y, double z) {
|
||||
if (npc == null) {
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
|
||||
if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true))
|
||||
super.g(x, y, z);
|
||||
return;
|
||||
}
|
||||
Vector vector = new Vector(x, y, z);
|
||||
NPCPushEvent event = Util.callPushEvent(npc, vector);
|
||||
if (!event.isCancelled()) {
|
||||
vector = event.getCollisionVector();
|
||||
super.g(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
// when another entity collides, this method is called to push the
|
||||
// NPC so we prevent it from doing anything if the event is
|
||||
// cancelled.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null && npc != null) {
|
||||
bukkitEntity = new WitherSkullNPC(this);
|
||||
}
|
||||
return super.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void m() {
|
||||
if (npc != null) {
|
||||
npc.update();
|
||||
} else {
|
||||
super.m();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class WitherSkullNPC extends CraftWitherSkull implements NPCHolder {
|
||||
private final CitizensNPC npc;
|
||||
|
||||
public WitherSkullNPC(EntityWitherSkullNPC entity) {
|
||||
super((CraftServer) Bukkit.getServer(), entity);
|
||||
this.npc = entity.npc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NPC getNPC() {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import io.netty.channel.AbstractChannel;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelConfig;
|
||||
import io.netty.channel.ChannelMetadata;
|
||||
import io.netty.channel.ChannelOutboundBuffer;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
|
||||
public class EmptyChannel extends AbstractChannel {
|
||||
private final ChannelConfig config = new DefaultChannelConfig(this);
|
||||
|
||||
public EmptyChannel(Channel parent) {
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelConfig config() {
|
||||
config.setAutoRead(true);
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBeginRead() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doBind(SocketAddress arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClose() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDisconnect() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doWrite(ChannelOutboundBuffer arg0) throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCompatible(EventLoop arg0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress localAddress0() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelMetadata metadata() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractUnsafe newUnsafe() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress remoteAddress0() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_10_R1.NetworkManager;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.PlayerConnection;
|
||||
|
||||
public class EmptyNetHandler extends PlayerConnection {
|
||||
public EmptyNetHandler(MinecraftServer minecraftServer, NetworkManager networkManager, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, networkManager, entityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPacket(Packet<?> packet) {
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
|
||||
import net.minecraft.server.v1_10_R1.EnumProtocolDirection;
|
||||
import net.minecraft.server.v1_10_R1.NetworkManager;
|
||||
|
||||
public class EmptyNetworkManager extends NetworkManager {
|
||||
public EmptyNetworkManager(EnumProtocolDirection flag) throws IOException {
|
||||
super(flag);
|
||||
NMSImpl.initNetworkManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.network;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
public class EmptySocket extends Socket {
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return new ByteArrayInputStream(EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return new ByteArrayOutputStream(10);
|
||||
}
|
||||
|
||||
private static final byte[] EMPTY = new byte[50];
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,135 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.trait.ArmorStandTrait;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.PlayerAnimation;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EnumHand;
|
||||
import net.minecraft.server.v1_10_R1.Packet;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutAnimation;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutBed;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayOutEntityMetadata;
|
||||
|
||||
public class PlayerAnimationImpl {
|
||||
public static void play(PlayerAnimation animation, Player bplayer, int radius) {
|
||||
// TODO: this is pretty gross
|
||||
final EntityPlayer player = (EntityPlayer) NMSImpl.getHandle(bplayer);
|
||||
if (DEFAULTS.containsKey(animation)) {
|
||||
playDefaultAnimation(player, radius, DEFAULTS.get(animation));
|
||||
return;
|
||||
}
|
||||
switch (animation) {
|
||||
case SIT:
|
||||
player.getBukkitEntity().setMetadata("citizens.sitting",
|
||||
new FixedMetadataValue(CitizensAPI.getPlugin(), true));
|
||||
final NPC holder = CitizensAPI.getNPCRegistry().createNPC(EntityType.ARMOR_STAND, "");
|
||||
holder.spawn(player.getBukkitEntity().getLocation());
|
||||
ArmorStandTrait trait = holder.getTrait(ArmorStandTrait.class);
|
||||
trait.setGravity(false);
|
||||
trait.setHasArms(false);
|
||||
trait.setHasBaseplate(false);
|
||||
trait.setSmall(true);
|
||||
trait.setMarker(true);
|
||||
trait.setVisible(false);
|
||||
holder.getTrait(ArmorStandTrait.class).setVisible(false);
|
||||
holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
|
||||
holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
super.cancel();
|
||||
holder.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.dead || !player.valid
|
||||
|| !player.getBukkitEntity().getMetadata("citizens.sitting").get(0).asBoolean()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (!NMS.getPassengers(holder.getEntity()).contains(player.getBukkitEntity())) {
|
||||
NMS.mount(holder.getEntity(), player.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
|
||||
break;
|
||||
case SLEEP:
|
||||
PacketPlayOutBed packet = new PacketPlayOutBed(player,
|
||||
new BlockPosition((int) player.locX, (int) player.locY, (int) player.locZ));
|
||||
sendPacketNearby(packet, player, radius);
|
||||
break;
|
||||
case SNEAK:
|
||||
player.getBukkitEntity().setSneaking(true);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case START_USE_MAINHAND_ITEM:
|
||||
player.c(EnumHand.MAIN_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case START_USE_OFFHAND_ITEM:
|
||||
player.c(EnumHand.OFF_HAND);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case STOP_SITTING:
|
||||
player.getBukkitEntity().setMetadata("citizens.sitting",
|
||||
new FixedMetadataValue(CitizensAPI.getPlugin(), false));
|
||||
NMS.mount(player.getBukkitEntity(), null);
|
||||
break;
|
||||
case STOP_SLEEPING:
|
||||
playDefaultAnimation(player, radius, 2);
|
||||
break;
|
||||
case STOP_SNEAKING:
|
||||
player.getBukkitEntity().setSneaking(false);
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
case STOP_USE_ITEM:
|
||||
player.cA();
|
||||
sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player,
|
||||
radius);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void playDefaultAnimation(EntityPlayer player, int radius, int code) {
|
||||
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(player, code);
|
||||
sendPacketNearby(packet, player, radius);
|
||||
}
|
||||
|
||||
protected static void sendPacketNearby(Packet<?> packet, EntityPlayer player, int radius) {
|
||||
NMSImpl.sendPacketNearby(player.getBukkitEntity(), player.getBukkitEntity().getLocation(), packet, radius);
|
||||
}
|
||||
|
||||
private static EnumMap<PlayerAnimation, Integer> DEFAULTS = Maps.newEnumMap(PlayerAnimation.class);
|
||||
static {
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING, 0);
|
||||
DEFAULTS.put(PlayerAnimation.HURT, 1);
|
||||
DEFAULTS.put(PlayerAnimation.EAT_FOOD, 2);
|
||||
DEFAULTS.put(PlayerAnimation.ARM_SWING_OFFHAND, 3);
|
||||
DEFAULTS.put(PlayerAnimation.CRIT, 4);
|
||||
DEFAULTS.put(PlayerAnimation.MAGIC_CRIT, 5);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
|
||||
public class PlayerControllerJump {
|
||||
private final EntityHumanNPC a;
|
||||
private boolean b;
|
||||
|
||||
public PlayerControllerJump(EntityHumanNPC entityinsentient) {
|
||||
this.a = entityinsentient;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.b = true;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.a.k(this.b);
|
||||
this.b = false;
|
||||
}
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
|
||||
public class PlayerControllerLook {
|
||||
private final EntityHumanNPC a;
|
||||
private float b;
|
||||
private float c;
|
||||
private boolean d;
|
||||
private double e;
|
||||
private double f;
|
||||
private double g;
|
||||
|
||||
public PlayerControllerLook(EntityHumanNPC entityinsentient) {
|
||||
this.a = entityinsentient;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.a.pitch = 0.0F;
|
||||
if (this.d) {
|
||||
this.d = false;
|
||||
|
||||
double d1 = this.e - this.a.locX;
|
||||
double d2 = this.f - (this.a.locY + this.a.getHeadHeight());
|
||||
double d3 = this.g - this.a.locZ;
|
||||
double d4 = MathHelper.sqrt(d1 * d1 + d3 * d3);
|
||||
|
||||
float f1 = (float) (MathHelper.b(d3, d1) * 57.2957763671875D) - 90.0F;
|
||||
float f2 = (float) -(MathHelper.b(d2, d4) * 57.2957763671875D);
|
||||
this.a.pitch = a(this.a.pitch, f2, this.c);
|
||||
this.a.aO = a(this.a.aO, f1, this.b);
|
||||
} else {
|
||||
this.a.aO = a(this.a.aO, this.a.aM, 10.0F);
|
||||
}
|
||||
float f3 = MathHelper.g(this.a.aO - this.a.aM);
|
||||
if (!this.a.getNavigation().n()) {
|
||||
if (f3 < -75.0F) {
|
||||
this.a.aO = (this.a.aM - 75.0F);
|
||||
}
|
||||
if (f3 > 75.0F) {
|
||||
this.a.aO = (this.a.aM + 75.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(double d0, double d1, double d2, float f, float f1) {
|
||||
this.e = d0;
|
||||
this.f = d1;
|
||||
this.g = d2;
|
||||
this.b = f;
|
||||
this.c = f1;
|
||||
this.d = true;
|
||||
}
|
||||
|
||||
public void a(Entity entity, float f, float f1) {
|
||||
this.e = entity.locX;
|
||||
if ((entity instanceof EntityLiving))
|
||||
this.f = (entity.locY + entity.getHeadHeight());
|
||||
else {
|
||||
this.f = ((entity.getBoundingBox().b + entity.getBoundingBox().e) / 2.0D);
|
||||
}
|
||||
|
||||
this.g = entity.locZ;
|
||||
this.b = f;
|
||||
this.c = f1;
|
||||
this.d = true;
|
||||
}
|
||||
|
||||
private float a(float f, float f1, float f2) {
|
||||
float f3 = MathHelper.g(f1 - f);
|
||||
|
||||
if (f3 > f2) {
|
||||
f3 = f2;
|
||||
}
|
||||
|
||||
if (f3 < -f2) {
|
||||
f3 = -f2;
|
||||
}
|
||||
|
||||
return f + f3;
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public double e() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public double f() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
public double g() {
|
||||
return this.g;
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_10_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_10_R1.ControllerMove;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.EntityLiving;
|
||||
import net.minecraft.server.v1_10_R1.EntitySlime;
|
||||
import net.minecraft.server.v1_10_R1.GenericAttributes;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
|
||||
public class PlayerControllerMove extends ControllerMove {
|
||||
protected EntityLiving a;
|
||||
protected double b;
|
||||
protected double c;
|
||||
protected double d;
|
||||
protected double e;
|
||||
protected boolean f;
|
||||
private int h;
|
||||
|
||||
public PlayerControllerMove(EntityLiving entityinsentient) {
|
||||
super(entityinsentient instanceof EntityInsentient ? (EntityInsentient) entityinsentient
|
||||
: new EntitySlime(entityinsentient.world));
|
||||
this.a = entityinsentient;
|
||||
this.b = entityinsentient.locX;
|
||||
this.c = entityinsentient.locY;
|
||||
this.d = entityinsentient.locZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(double d0, double d1, double d2, double d3) {
|
||||
this.b = d0;
|
||||
this.c = d1;
|
||||
this.d = d2;
|
||||
this.e = d3;
|
||||
this.f = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float a(float f, float f1, float f2) {
|
||||
float f3 = MathHelper.g(f1 - f);
|
||||
|
||||
if (f3 > f2) {
|
||||
f3 = f2;
|
||||
}
|
||||
|
||||
if (f3 < -f2) {
|
||||
f3 = -f2;
|
||||
}
|
||||
|
||||
float f4 = f + f3;
|
||||
|
||||
if (f4 < 0.0F)
|
||||
f4 += 360.0F;
|
||||
else if (f4 > 360.0F) {
|
||||
f4 -= 360.0F;
|
||||
}
|
||||
|
||||
return f4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double b() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
this.a.bf = 0F;
|
||||
if (this.f) {
|
||||
this.f = false;
|
||||
int i = MathHelper.floor(this.a.getBoundingBox().b + 0.5D);
|
||||
double d0 = this.b - this.a.locX;
|
||||
double d1 = this.d - this.a.locZ;
|
||||
double d2 = this.c - i;
|
||||
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
|
||||
if (d3 < 2.500000277905201E-007D)
|
||||
return;
|
||||
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
|
||||
this.a.yaw = a(this.a.yaw, f, 30.0F);
|
||||
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
|
||||
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||
speed.setValue(0.1D * this.e);
|
||||
float movement = (float) (this.e * speed.getValue()) * 10;
|
||||
this.a.bg = movement;
|
||||
if (shouldSlimeJump() || ((d2 > 0.0D) && (d0 * d0 + d1 * d1 < 1.0D))) {
|
||||
this.h = cg();
|
||||
this.h /= 3;
|
||||
if (this.a instanceof EntityHumanNPC) {
|
||||
((EntityHumanNPC) this.a).getControllerJump().a();
|
||||
} else {
|
||||
((EntityInsentient) this.a).getControllerJump().a();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int cg() {
|
||||
return new Random().nextInt(20) + 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double d() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double e() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double f() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
private boolean shouldSlimeJump() {
|
||||
if (!(this.a instanceof EntitySlime)) {
|
||||
return false;
|
||||
}
|
||||
if (this.h-- <= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,526 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.minecraft.server.v1_10_R1.AttributeInstance;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.Block;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.Blocks;
|
||||
import net.minecraft.server.v1_10_R1.ChunkCache;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.GenericAttributes;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.Material;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
import net.minecraft.server.v1_10_R1.NavigationAbstract;
|
||||
import net.minecraft.server.v1_10_R1.PathEntity;
|
||||
import net.minecraft.server.v1_10_R1.PathPoint;
|
||||
import net.minecraft.server.v1_10_R1.PathType;
|
||||
import net.minecraft.server.v1_10_R1.Pathfinder;
|
||||
import net.minecraft.server.v1_10_R1.Vec3D;
|
||||
import net.minecraft.server.v1_10_R1.World;
|
||||
|
||||
public class PlayerNavigation extends NavigationAbstract {
|
||||
protected EntityHumanNPC a;
|
||||
protected PlayerPathfinderNormal e;
|
||||
private boolean f2;
|
||||
private final AttributeInstance g;
|
||||
private int h;
|
||||
private int i;
|
||||
private Vec3D j = Vec3D.a;
|
||||
private Vec3D k = Vec3D.a;
|
||||
private long l = 0L;
|
||||
private long m = 0L;
|
||||
private double n;
|
||||
private float o = 0.5F;
|
||||
private boolean p;
|
||||
private long q;
|
||||
private BlockPosition r;
|
||||
private final PlayerPathfinder s;
|
||||
|
||||
public PlayerNavigation(EntityHumanNPC entityinsentient, World world) {
|
||||
super(getDummyInsentient(entityinsentient, world), world);
|
||||
this.a = entityinsentient;
|
||||
this.b = world;
|
||||
this.g = entityinsentient.getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
|
||||
this.g.setValue(24);
|
||||
this.e = new PlayerPathfinderNormal();
|
||||
this.e.a(true);
|
||||
this.s = new PlayerPathfinder(this.e);
|
||||
// this.b.C().a(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pathfinder a() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathEntity a(BlockPosition paramBlockPosition) {
|
||||
BlockPosition localBlockPosition;
|
||||
if (this.b.getType(paramBlockPosition).getMaterial() == Material.AIR) {
|
||||
localBlockPosition = paramBlockPosition.down();
|
||||
while ((localBlockPosition.getY() > 0)
|
||||
&& (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
|
||||
localBlockPosition = localBlockPosition.down();
|
||||
}
|
||||
if (localBlockPosition.getY() > 0) {
|
||||
return supera(localBlockPosition.up());
|
||||
}
|
||||
while ((localBlockPosition.getY() < this.b.getHeight())
|
||||
&& (this.b.getType(localBlockPosition).getMaterial() == Material.AIR)) {
|
||||
localBlockPosition = localBlockPosition.up();
|
||||
}
|
||||
paramBlockPosition = localBlockPosition;
|
||||
}
|
||||
if (this.b.getType(paramBlockPosition).getMaterial().isBuildable()) {
|
||||
localBlockPosition = paramBlockPosition.up();
|
||||
while ((localBlockPosition.getY() < this.b.getHeight())
|
||||
&& (this.b.getType(localBlockPosition).getMaterial().isBuildable())) {
|
||||
localBlockPosition = localBlockPosition.up();
|
||||
}
|
||||
return a2(localBlockPosition);
|
||||
}
|
||||
return a2(paramBlockPosition);
|
||||
}
|
||||
|
||||
public void a(boolean paramBoolean) {
|
||||
this.e.b(paramBoolean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(double paramDouble) {
|
||||
this.d = paramDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4) {
|
||||
PathEntity localPathEntity = a(MathHelper.floor(paramDouble1), (int) paramDouble2,
|
||||
MathHelper.floor(paramDouble3));
|
||||
return a(localPathEntity, paramDouble4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathEntity a(Entity paramEntity) {
|
||||
BlockPosition localBlockPosition = new BlockPosition(paramEntity);
|
||||
return a(localBlockPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(Entity paramEntity, double paramDouble) {
|
||||
PathEntity localPathEntity = a(paramEntity);
|
||||
if (localPathEntity != null) {
|
||||
return a(localPathEntity, paramDouble);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6,
|
||||
Vec3D paramVec3D, double paramDouble1, double paramDouble2) {
|
||||
int i = paramInt1 - paramInt4 / 2;
|
||||
int j = paramInt3 - paramInt6 / 2;
|
||||
if (!b(i, paramInt2, j, paramInt4, paramInt5, paramInt6, paramVec3D, paramDouble1, paramDouble2)) {
|
||||
return false;
|
||||
}
|
||||
for (int k = i; k < i + paramInt4; k++) {
|
||||
for (int m = j; m < j + paramInt6; m++) {
|
||||
double d1 = k + 0.5D - paramVec3D.x;
|
||||
double d2 = m + 0.5D - paramVec3D.z;
|
||||
if (d1 * paramDouble1 + d2 * paramDouble2 >= 0.0D) {
|
||||
PathType localPathType = this.e.a(this.b, k, paramInt2 - 1, m, this.a, paramInt4, paramInt5,
|
||||
paramInt6, true, true);
|
||||
if (localPathType == PathType.WATER) {
|
||||
return false;
|
||||
}
|
||||
if (localPathType == PathType.LAVA) {
|
||||
return false;
|
||||
}
|
||||
if (localPathType == PathType.OPEN) {
|
||||
return false;
|
||||
}
|
||||
localPathType = this.e.a(this.b, k, paramInt2, m, this.a, paramInt4, paramInt5, paramInt6, true,
|
||||
true);
|
||||
float f1 = this.a.a(localPathType);
|
||||
if ((f1 < 0.0F) || (f1 >= 8.0F)) {
|
||||
return false;
|
||||
}
|
||||
if ((localPathType == PathType.DAMAGE_FIRE) || (localPathType == PathType.DANGER_FIRE)
|
||||
|| (localPathType == PathType.DAMAGE_OTHER)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(PathEntity paramPathEntity, double paramDouble) {
|
||||
if (paramPathEntity == null) {
|
||||
this.c = null;
|
||||
return false;
|
||||
}
|
||||
if (!paramPathEntity.a(this.c)) {
|
||||
this.c = paramPathEntity;
|
||||
}
|
||||
d();
|
||||
if (this.c.d() == 0) {
|
||||
return false;
|
||||
}
|
||||
this.d = paramDouble;
|
||||
Vec3D localVec3D = c();
|
||||
this.i = this.h;
|
||||
this.j = localVec3D;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void a(Vec3D paramVec3D) {
|
||||
if (this.h - this.i > 100) {
|
||||
if (paramVec3D.distanceSquared(this.j) < 2.25D) {
|
||||
o();
|
||||
}
|
||||
this.i = this.h;
|
||||
this.j = paramVec3D;
|
||||
}
|
||||
if ((this.c != null) && (!this.c.b())) {
|
||||
Vec3D localVec3D = this.c.f();
|
||||
if (!localVec3D.equals(this.k)) {
|
||||
this.k = localVec3D;
|
||||
double d1 = paramVec3D.f(this.k);
|
||||
this.n = (this.a.cp() > 0.0F ? d1 / this.a.cp() * 1000.0D : 0.0D);
|
||||
} else {
|
||||
this.l += System.currentTimeMillis() - this.m;
|
||||
}
|
||||
if ((this.n > 0.0D) && (this.l > this.n * 3.0D)) {
|
||||
this.k = Vec3D.a;
|
||||
this.l = 0L;
|
||||
this.n = 0.0D;
|
||||
o();
|
||||
}
|
||||
this.m = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean a(Vec3D paramVec3D1, Vec3D paramVec3D2, int paramInt1, int paramInt2, int paramInt3) {
|
||||
int i = MathHelper.floor(paramVec3D1.x);
|
||||
int j = MathHelper.floor(paramVec3D1.z);
|
||||
|
||||
double d1 = paramVec3D2.x - paramVec3D1.x;
|
||||
double d2 = paramVec3D2.z - paramVec3D1.z;
|
||||
double d3 = d1 * d1 + d2 * d2;
|
||||
if (d3 < 1.0E-8D) {
|
||||
return false;
|
||||
}
|
||||
double d4 = 1.0D / Math.sqrt(d3);
|
||||
d1 *= d4;
|
||||
d2 *= d4;
|
||||
|
||||
paramInt1 += 2;
|
||||
paramInt3 += 2;
|
||||
if (!a(i, (int) paramVec3D1.y, j, paramInt1, paramInt2, paramInt3, paramVec3D1, d1, d2)) {
|
||||
return false;
|
||||
}
|
||||
paramInt1 -= 2;
|
||||
paramInt3 -= 2;
|
||||
|
||||
double d5 = 1.0D / Math.abs(d1);
|
||||
double d6 = 1.0D / Math.abs(d2);
|
||||
|
||||
double d7 = i - paramVec3D1.x;
|
||||
double d8 = j - paramVec3D1.z;
|
||||
if (d1 >= 0.0D) {
|
||||
d7 += 1.0D;
|
||||
}
|
||||
if (d2 >= 0.0D) {
|
||||
d8 += 1.0D;
|
||||
}
|
||||
d7 /= d1;
|
||||
d8 /= d2;
|
||||
|
||||
int k = d1 < 0.0D ? -1 : 1;
|
||||
int m = d2 < 0.0D ? -1 : 1;
|
||||
int n = MathHelper.floor(paramVec3D2.x);
|
||||
int i1 = MathHelper.floor(paramVec3D2.z);
|
||||
int i2 = n - i;
|
||||
int i3 = i1 - j;
|
||||
while ((i2 * k > 0) || (i3 * m > 0)) {
|
||||
if (d7 < d8) {
|
||||
d7 += d5;
|
||||
i += k;
|
||||
i2 = n - i;
|
||||
} else {
|
||||
d8 += d6;
|
||||
j += m;
|
||||
i3 = i1 - j;
|
||||
}
|
||||
if (!a(i, (int) paramVec3D1.y, j, paramInt1, paramInt2, paramInt3, paramVec3D1, d1, d2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public PathEntity a2(BlockPosition paramBlockPosition) {
|
||||
if (!b()) {
|
||||
return null;
|
||||
}
|
||||
if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.r))) {
|
||||
return this.c;
|
||||
}
|
||||
this.r = paramBlockPosition;
|
||||
|
||||
float f1 = h();
|
||||
this.b.methodProfiler.a("pathfind");
|
||||
BlockPosition localBlockPosition = new BlockPosition(this.a);
|
||||
int i1 = (int) (f1 + 8.0F);
|
||||
|
||||
ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1),
|
||||
localBlockPosition.a(i1, i1, i1), 0);
|
||||
PathEntity localPathEntity = this.s.a(localChunkCache, this.a, this.r, f1);
|
||||
this.b.methodProfiler.b();
|
||||
return localPathEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean b() {
|
||||
return (this.a.onGround) || ((g()) && (p())) || (this.a.isPassenger());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean b(BlockPosition paramBlockPosition) {
|
||||
return this.b.getType(paramBlockPosition.down()).b();
|
||||
}
|
||||
|
||||
public void b(boolean paramBoolean) {
|
||||
this.e.a(paramBoolean);
|
||||
}
|
||||
|
||||
private boolean b(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6,
|
||||
Vec3D paramVec3D, double paramDouble1, double paramDouble2) {
|
||||
for (BlockPosition localBlockPosition : BlockPosition.a(new BlockPosition(paramInt1, paramInt2, paramInt3),
|
||||
new BlockPosition(paramInt1 + paramInt4 - 1, paramInt2 + paramInt5 - 1, paramInt3 + paramInt6 - 1))) {
|
||||
double d1 = localBlockPosition.getX() + 0.5D - paramVec3D.x;
|
||||
double d2 = localBlockPosition.getZ() + 0.5D - paramVec3D.z;
|
||||
if (d1 * paramDouble1 + d2 * paramDouble2 >= 0.0D) {
|
||||
Block localBlock = this.b.getType(localBlockPosition).getBlock();
|
||||
if (!localBlock.b(this.b, localBlockPosition)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3D c() {
|
||||
return new Vec3D(this.a.locX, r(), this.a.locZ);
|
||||
}
|
||||
|
||||
public void c(boolean paramBoolean) {
|
||||
this.e.c(paramBoolean);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void d() {
|
||||
super.d();
|
||||
PathPoint localPathPoint;
|
||||
for (int i = 0; i < this.c.d(); i++) {
|
||||
localPathPoint = this.c.a(i);
|
||||
Object localObject = i + 1 < this.c.d() ? this.c.a(i + 1) : null;
|
||||
|
||||
IBlockData localIBlockData = this.b
|
||||
.getType(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c));
|
||||
Block localBlock = localIBlockData.getBlock();
|
||||
if (localBlock == Blocks.cauldron) {
|
||||
this.c.a(i, localPathPoint.a(localPathPoint.a, localPathPoint.b + 1, localPathPoint.c));
|
||||
if ((localObject != null) && (localPathPoint.b >= ((PathPoint) localObject).b)) {
|
||||
this.c.a(i + 1, ((PathPoint) localObject).a(((PathPoint) localObject).a, localPathPoint.b + 1,
|
||||
((PathPoint) localObject).c));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.f2) {
|
||||
if (this.b.h(new BlockPosition(MathHelper.floor(this.a.locX), (int) (this.a.getBoundingBox().b + 0.5D),
|
||||
MathHelper.floor(this.a.locZ)))) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < this.c.d(); i++) {
|
||||
localPathPoint = this.c.a(i);
|
||||
if (this.b.h(new BlockPosition(localPathPoint.a, localPathPoint.b, localPathPoint.c))) {
|
||||
this.c.b(i - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean f() {
|
||||
return this.e.c();
|
||||
}
|
||||
|
||||
public boolean g() {
|
||||
return this.e.e();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float h() {
|
||||
return (float) this.g.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean i() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void j() {
|
||||
if (this.b.getTime() - this.q > f) {
|
||||
if (this.r != null) {
|
||||
this.c = null;
|
||||
this.c = a(this.r);
|
||||
this.q = this.b.getTime();
|
||||
this.p = false;
|
||||
}
|
||||
} else {
|
||||
this.p = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathEntity k() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l() {
|
||||
this.h += 1;
|
||||
if (this.p) {
|
||||
j();
|
||||
}
|
||||
if (n()) {
|
||||
return;
|
||||
}
|
||||
if (b()) {
|
||||
m();
|
||||
} else if ((this.c != null) && (this.c.e() < this.c.d())) {
|
||||
Vec3D localVec3D = c();
|
||||
Vec3D localObject = this.c.a(this.a, this.c.e());
|
||||
if ((localVec3D.y > localObject.y) && (!this.a.onGround)
|
||||
&& (MathHelper.floor(localVec3D.x) == MathHelper.floor(localObject.x))
|
||||
&& (MathHelper.floor(localVec3D.z) == MathHelper.floor(localObject.z))) {
|
||||
this.c.c(this.c.e() + 1);
|
||||
}
|
||||
}
|
||||
if (n()) {
|
||||
return;
|
||||
}
|
||||
Vec3D localVec3D = this.c.a(this.a);
|
||||
if (localVec3D == null) {
|
||||
return;
|
||||
}
|
||||
Object localObject = new BlockPosition(localVec3D).down();
|
||||
AxisAlignedBB localAxisAlignedBB = this.b.getType((BlockPosition) localObject).c(this.b,
|
||||
(BlockPosition) localObject);
|
||||
localVec3D = localVec3D.a(0.0D, 1.0D - localAxisAlignedBB.e, 0.0D);
|
||||
|
||||
this.a.getControllerMove().a(localVec3D.x, localVec3D.y, localVec3D.z, this.d);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void m() {
|
||||
Vec3D localVec3D1 = c();
|
||||
|
||||
int i1 = this.c.d();
|
||||
for (int i2 = this.c.e(); i2 < this.c.d(); i2++) {
|
||||
if (this.c.a(i2).b != Math.floor(localVec3D1.y)) {
|
||||
i1 = i2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.o = (this.a.width > 0.75F ? this.a.width / 2.0F : 0.75F - this.a.width / 2.0F);
|
||||
Vec3D localVec3D2 = this.c.f();
|
||||
if ((MathHelper.e((float) (this.a.locX - (localVec3D2.x + 0.5D))) < this.o)
|
||||
&& (MathHelper.e((float) (this.a.locZ - (localVec3D2.z + 0.5D))) < this.o)) {
|
||||
this.c.c(this.c.e() + 1);
|
||||
}
|
||||
int i3 = MathHelper.f(this.a.width);
|
||||
int i4 = (int) this.a.length + 1;
|
||||
int i5 = i3;
|
||||
for (int i6 = i1 - 1; i6 >= this.c.e(); i6--) {
|
||||
if (a(localVec3D1, this.c.a(this.a, i6), i3, i4, i5)) {
|
||||
this.c.c(i6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
a(localVec3D1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean n() {
|
||||
return (this.c == null) || (this.c.b());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void o() {
|
||||
this.c = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean p() {
|
||||
return (this.a.isInWater()) || (this.a.ao());
|
||||
}
|
||||
|
||||
private int r() {
|
||||
if ((!this.a.isInWater()) || (!g())) {
|
||||
return (int) (this.a.getBoundingBox().b + 0.5D);
|
||||
}
|
||||
int i = (int) this.a.getBoundingBox().b;
|
||||
Block localBlock = this.b
|
||||
.getType(new BlockPosition(MathHelper.floor(this.a.locX), i, MathHelper.floor(this.a.locZ))).getBlock();
|
||||
int j = 0;
|
||||
while ((localBlock == Blocks.FLOWING_WATER) || (localBlock == Blocks.WATER)) {
|
||||
i++;
|
||||
localBlock = this.b
|
||||
.getType(new BlockPosition(MathHelper.floor(this.a.locX), i, MathHelper.floor(this.a.locZ)))
|
||||
.getBlock();
|
||||
j++;
|
||||
if (j > 16) {
|
||||
return (int) this.a.getBoundingBox().b;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setRange(float pathfindingRange) {
|
||||
this.g.setValue(pathfindingRange);
|
||||
}
|
||||
|
||||
public PathEntity supera(BlockPosition paramBlockPosition) {
|
||||
if (!b()) {
|
||||
return null;
|
||||
}
|
||||
if ((this.c != null) && (!this.c.b()) && (paramBlockPosition.equals(this.r))) {
|
||||
return this.c;
|
||||
}
|
||||
this.r = paramBlockPosition;
|
||||
|
||||
float f1 = h();
|
||||
BlockPosition localBlockPosition = new BlockPosition(this.a);
|
||||
int i1 = (int) (f1 + 8.0F);
|
||||
|
||||
ChunkCache localChunkCache = new ChunkCache(this.b, localBlockPosition.a(-i1, -i1, -i1),
|
||||
localBlockPosition.a(i1, i1, i1), 0);
|
||||
PathEntity localPathEntity = this.s.a(localChunkCache, this.a, this.r, f1);
|
||||
return localPathEntity;
|
||||
}
|
||||
|
||||
private static EntityInsentient getDummyInsentient(EntityHumanNPC from, World world) {
|
||||
return new EntityInsentient(world) {
|
||||
};
|
||||
}
|
||||
|
||||
private static int f = 20;
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.IBlockAccess;
|
||||
import net.minecraft.server.v1_10_R1.Path;
|
||||
import net.minecraft.server.v1_10_R1.PathEntity;
|
||||
import net.minecraft.server.v1_10_R1.PathPoint;
|
||||
|
||||
public class PlayerPathfinder {
|
||||
private final Path a = new Path();
|
||||
private final Set<PathPoint> b = new HashSet<PathPoint>();
|
||||
private final PathPoint[] c = new PathPoint[32];
|
||||
private final PlayerPathfinderNormal d;
|
||||
|
||||
public PlayerPathfinder(PlayerPathfinderNormal paramPathfinderAbstract) {
|
||||
this.d = paramPathfinderAbstract;
|
||||
}
|
||||
|
||||
public PathEntity a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient,
|
||||
BlockPosition paramBlockPosition, float paramFloat) {
|
||||
return a(paramIBlockAccess, paramEntityInsentient, paramBlockPosition.getX() + 0.5F,
|
||||
paramBlockPosition.getY() + 0.5F, paramBlockPosition.getZ() + 0.5F, paramFloat);
|
||||
}
|
||||
|
||||
private PathEntity a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient, double paramDouble1,
|
||||
double paramDouble2, double paramDouble3, float paramFloat) {
|
||||
this.a.a();
|
||||
this.d.a(paramIBlockAccess, paramEntityInsentient);
|
||||
PathPoint localPathPoint1 = this.d.b();
|
||||
PathPoint localPathPoint2 = this.d.a(paramDouble1, paramDouble2, paramDouble3);
|
||||
|
||||
PathEntity localPathEntity = a(localPathPoint1, localPathPoint2, paramFloat);
|
||||
|
||||
this.d.a();
|
||||
return localPathEntity;
|
||||
}
|
||||
|
||||
public PathEntity a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient, Entity paramEntity,
|
||||
float paramFloat) {
|
||||
return a(paramIBlockAccess, paramEntityInsentient, paramEntity.locX, paramEntity.getBoundingBox().b,
|
||||
paramEntity.locZ, paramFloat);
|
||||
}
|
||||
|
||||
private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2) {
|
||||
int i = 1;
|
||||
PathPoint localPathPoint = paramPathPoint2;
|
||||
while (localPathPoint.h != null) {
|
||||
i++;
|
||||
localPathPoint = localPathPoint.h;
|
||||
}
|
||||
PathPoint[] arrayOfPathPoint = new PathPoint[i];
|
||||
localPathPoint = paramPathPoint2;
|
||||
arrayOfPathPoint[(--i)] = localPathPoint;
|
||||
while (localPathPoint.h != null) {
|
||||
localPathPoint = localPathPoint.h;
|
||||
arrayOfPathPoint[(--i)] = localPathPoint;
|
||||
}
|
||||
return new PathEntity(arrayOfPathPoint);
|
||||
}
|
||||
|
||||
private PathEntity a(PathPoint paramPathPoint1, PathPoint paramPathPoint2, float paramFloat) {
|
||||
paramPathPoint1.e = 0.0F;
|
||||
paramPathPoint1.f = paramPathPoint1.c(paramPathPoint2);
|
||||
paramPathPoint1.g = paramPathPoint1.f;
|
||||
|
||||
this.a.a();
|
||||
this.b.clear();
|
||||
this.a.a(paramPathPoint1);
|
||||
|
||||
Object localObject1 = paramPathPoint1;
|
||||
int i = 0;
|
||||
while (!this.a.e()) {
|
||||
i++;
|
||||
if (i >= 2000) {
|
||||
break;
|
||||
}
|
||||
PathPoint localObject2 = this.a.c();
|
||||
if (localObject2.equals(paramPathPoint2)) {
|
||||
localObject1 = paramPathPoint2;
|
||||
break;
|
||||
}
|
||||
if (localObject2.c(paramPathPoint2) < ((PathPoint) localObject1).c(paramPathPoint2)) {
|
||||
localObject1 = localObject2;
|
||||
}
|
||||
localObject2.i = true;
|
||||
|
||||
int j = this.d.a(this.c, localObject2, paramPathPoint2, paramFloat);
|
||||
for (int k = 0; k < j; k++) {
|
||||
PathPoint localPathPoint = this.c[k];
|
||||
|
||||
float f1 = localObject2.c(localPathPoint);
|
||||
localPathPoint.j = (localObject2.j + f1);
|
||||
localPathPoint.k = (f1 + localPathPoint.l);
|
||||
|
||||
float f2 = localObject2.e + localPathPoint.k;
|
||||
if ((localPathPoint.j < paramFloat) && ((!localPathPoint.a()) || (f2 < localPathPoint.e))) {
|
||||
localPathPoint.h = (localObject2);
|
||||
localPathPoint.e = f2;
|
||||
localPathPoint.f = (localPathPoint.c(paramPathPoint2) + localPathPoint.l);
|
||||
if (localPathPoint.a()) {
|
||||
this.a.a(localPathPoint, localPathPoint.e + localPathPoint.f);
|
||||
} else {
|
||||
localPathPoint.g = (localPathPoint.e + localPathPoint.f);
|
||||
this.a.a(localPathPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localObject1 == paramPathPoint1) {
|
||||
return null;
|
||||
}
|
||||
Object localObject2 = a(paramPathPoint1, (PathPoint) localObject1);
|
||||
|
||||
return (PathEntity) localObject2;
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.IBlockAccess;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
import net.minecraft.server.v1_10_R1.PathPoint;
|
||||
import net.minecraft.server.v1_10_R1.PathType;
|
||||
import net.minecraft.server.v1_10_R1.PathfinderAbstract;
|
||||
|
||||
public abstract class PlayerPathfinderAbstract extends PathfinderAbstract {
|
||||
protected IBlockAccess a;
|
||||
protected EntityHumanNPC b;
|
||||
protected int d;
|
||||
protected int e;
|
||||
protected int f;
|
||||
protected boolean g;
|
||||
protected boolean h;
|
||||
protected boolean i;
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(boolean paramBoolean) {
|
||||
this.g = paramBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract PathPoint a(double paramDouble1, double paramDouble2, double paramDouble3);
|
||||
|
||||
public void a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient) {
|
||||
this.a = paramIBlockAccess;
|
||||
this.b = paramEntityInsentient;
|
||||
this.c.c();
|
||||
|
||||
this.d = MathHelper.d(paramEntityInsentient.width + 1.0F);
|
||||
this.e = MathHelper.d(paramEntityInsentient.length + 1.0F);
|
||||
this.f = MathHelper.d(paramEntityInsentient.width + 1.0F);
|
||||
}
|
||||
|
||||
public abstract PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3,
|
||||
EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
|
||||
boolean paramBoolean2);
|
||||
|
||||
@Override
|
||||
public abstract PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3,
|
||||
EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
|
||||
boolean paramBoolean2);
|
||||
|
||||
@Override
|
||||
protected PathPoint a(int paramInt1, int paramInt2, int paramInt3) {
|
||||
int j = PathPoint.b(paramInt1, paramInt2, paramInt3);
|
||||
PathPoint localPathPoint = this.c.get(j);
|
||||
if (localPathPoint == null) {
|
||||
localPathPoint = new PathPoint(paramInt1, paramInt2, paramInt3);
|
||||
this.c.a(j, localPathPoint);
|
||||
}
|
||||
return localPathPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract int a(PathPoint[] paramArrayOfPathPoint, PathPoint paramPathPoint1, PathPoint paramPathPoint2,
|
||||
float paramFloat);
|
||||
|
||||
@Override
|
||||
public abstract PathPoint b();
|
||||
|
||||
@Override
|
||||
public void b(boolean paramBoolean) {
|
||||
this.h = paramBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean c() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c(boolean paramBoolean) {
|
||||
this.i = paramBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean d() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean e() {
|
||||
return this.i;
|
||||
}
|
||||
}
|
|
@ -1,439 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_10_R1.Block;
|
||||
import net.minecraft.server.v1_10_R1.BlockCobbleWall;
|
||||
import net.minecraft.server.v1_10_R1.BlockDoor;
|
||||
import net.minecraft.server.v1_10_R1.BlockFence;
|
||||
import net.minecraft.server.v1_10_R1.BlockFenceGate;
|
||||
import net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition;
|
||||
import net.minecraft.server.v1_10_R1.Blocks;
|
||||
import net.minecraft.server.v1_10_R1.EntityInsentient;
|
||||
import net.minecraft.server.v1_10_R1.EnumDirection;
|
||||
import net.minecraft.server.v1_10_R1.IBlockAccess;
|
||||
import net.minecraft.server.v1_10_R1.IBlockData;
|
||||
import net.minecraft.server.v1_10_R1.Material;
|
||||
import net.minecraft.server.v1_10_R1.MathHelper;
|
||||
import net.minecraft.server.v1_10_R1.PathPoint;
|
||||
import net.minecraft.server.v1_10_R1.PathType;
|
||||
|
||||
public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
|
||||
private float j;
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
super.a();
|
||||
this.b.a(PathType.WATER, this.j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathPoint a(double paramDouble1, double paramDouble2, double paramDouble3) {
|
||||
return a(MathHelper.floor(paramDouble1 - this.b.width / 2.0F), MathHelper.floor(paramDouble2),
|
||||
MathHelper.floor(paramDouble3 - this.b.width / 2.0F));
|
||||
}
|
||||
|
||||
private PathType a(EntityHumanNPC paramEntityInsentient, BlockPosition paramBlockPosition) {
|
||||
return a(this.a, paramBlockPosition.getX(), paramBlockPosition.getY(), paramBlockPosition.getZ(),
|
||||
paramEntityInsentient, this.d, this.e, this.f, d(), c());
|
||||
}
|
||||
|
||||
private PathType a(EntityHumanNPC paramEntityInsentient, int paramInt1, int paramInt2, int paramInt3) {
|
||||
return a(this.a, paramInt1, paramInt2, paramInt3, paramEntityInsentient, this.d, this.e, this.f, d(), c());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(IBlockAccess paramIBlockAccess, EntityHumanNPC paramEntityInsentient) {
|
||||
super.a(paramIBlockAccess, paramEntityInsentient);
|
||||
this.j = paramEntityInsentient.a(PathType.WATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
|
||||
PathType localPathType1 = getPathTypeBase(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
|
||||
if ((localPathType1 == PathType.OPEN) && (paramInt2 >= 1)) {
|
||||
PathType localPathType2 = localPathType1;
|
||||
while (localPathType2 == PathType.OPEN && (--paramInt2 >= 1)) {
|
||||
localPathType2 = getPathTypeBase(paramIBlockAccess, paramInt1, paramInt2, paramInt3);
|
||||
}
|
||||
localPathType1 = (localPathType2 == PathType.WALKABLE) || (localPathType2 == PathType.OPEN)
|
||||
|| (localPathType2 == PathType.WATER) || (localPathType2 == PathType.LAVA) ? PathType.OPEN
|
||||
: PathType.WALKABLE;
|
||||
}
|
||||
if (localPathType1 == PathType.WALKABLE) {
|
||||
for (int i = paramInt1 - 1; i <= paramInt1 + 1; i++) {
|
||||
for (int k = paramInt3 - 1; k <= paramInt3 + 1; k++) {
|
||||
if ((i != paramInt1) || (k != paramInt3)) {
|
||||
Block localBlock2 = paramIBlockAccess.getType(new BlockPosition(i, paramInt2, k)).getBlock();
|
||||
if (localBlock2 == Blocks.CACTUS) {
|
||||
localPathType1 = PathType.DANGER_CACTUS;
|
||||
} else if (localBlock2 == Blocks.FIRE) {
|
||||
localPathType1 = PathType.DANGER_FIRE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return localPathType1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3,
|
||||
EntityHumanNPC paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
|
||||
boolean paramBoolean2) {
|
||||
EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
|
||||
Object localObject1 = PathType.BLOCKED;
|
||||
|
||||
double d = paramEntityInsentient.width / 2.0D;
|
||||
BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
|
||||
for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
|
||||
for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
|
||||
for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
|
||||
PathType localPathType2 = a(paramIBlockAccess, i, k, m);
|
||||
if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
|
||||
localPathType2 = PathType.WALKABLE;
|
||||
}
|
||||
if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
|
||||
localPathType2 = PathType.BLOCKED;
|
||||
}
|
||||
if ((localPathType2 == PathType.RAIL)
|
||||
&& (!(paramIBlockAccess.getType(localBlockPosition)
|
||||
.getBlock() instanceof BlockMinecartTrackAbstract))
|
||||
&& (!(paramIBlockAccess.getType(localBlockPosition.down())
|
||||
.getBlock() instanceof BlockMinecartTrackAbstract))) {
|
||||
localPathType2 = PathType.FENCE;
|
||||
}
|
||||
if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
|
||||
localObject1 = localPathType2;
|
||||
}
|
||||
if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
|
||||
AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D,
|
||||
m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
|
||||
if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
|
||||
localPathType2 = PathType.OPEN;
|
||||
}
|
||||
}
|
||||
localEnumSet.add(localPathType2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localEnumSet.contains(PathType.FENCE)) {
|
||||
return PathType.FENCE;
|
||||
}
|
||||
Object localObject2 = PathType.BLOCKED;
|
||||
for (PathType localPathType1 : localEnumSet) {
|
||||
if (paramEntityInsentient.a(localPathType1) < 0.0F) {
|
||||
return localPathType1;
|
||||
}
|
||||
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
|
||||
localObject2 = localPathType1;
|
||||
}
|
||||
}
|
||||
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
|
||||
return PathType.OPEN;
|
||||
}
|
||||
return (PathType) localObject2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3,
|
||||
EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1,
|
||||
boolean paramBoolean2) {
|
||||
EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
|
||||
Object localObject1 = PathType.BLOCKED;
|
||||
|
||||
double d = paramEntityInsentient.width / 2.0D;
|
||||
BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
|
||||
for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
|
||||
for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
|
||||
for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
|
||||
PathType localPathType2 = a(paramIBlockAccess, i, k, m);
|
||||
if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
|
||||
localPathType2 = PathType.WALKABLE;
|
||||
}
|
||||
if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
|
||||
localPathType2 = PathType.BLOCKED;
|
||||
}
|
||||
if ((localPathType2 == PathType.RAIL)
|
||||
&& (!(paramIBlockAccess.getType(localBlockPosition)
|
||||
.getBlock() instanceof BlockMinecartTrackAbstract))
|
||||
&& (!(paramIBlockAccess.getType(localBlockPosition.down())
|
||||
.getBlock() instanceof BlockMinecartTrackAbstract))) {
|
||||
localPathType2 = PathType.FENCE;
|
||||
}
|
||||
if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
|
||||
localObject1 = localPathType2;
|
||||
}
|
||||
if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
|
||||
AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D,
|
||||
m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
|
||||
if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
|
||||
localPathType2 = PathType.OPEN;
|
||||
}
|
||||
}
|
||||
localEnumSet.add(localPathType2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localEnumSet.contains(PathType.FENCE)) {
|
||||
return PathType.FENCE;
|
||||
}
|
||||
Object localObject2 = PathType.BLOCKED;
|
||||
for (PathType localPathType1 : localEnumSet) {
|
||||
if (paramEntityInsentient.a(localPathType1) < 0.0F) {
|
||||
return localPathType1;
|
||||
}
|
||||
if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
|
||||
localObject2 = localPathType1;
|
||||
}
|
||||
}
|
||||
if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
|
||||
return PathType.OPEN;
|
||||
}
|
||||
return (PathType) localObject2;
|
||||
}
|
||||
|
||||
private PathPoint a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, double paramDouble,
|
||||
EnumDirection paramEnumDirection) {
|
||||
PathPoint localPathPoint = null;
|
||||
|
||||
BlockPosition localBlockPosition1 = new BlockPosition(paramInt1, paramInt2, paramInt3);
|
||||
BlockPosition localBlockPosition2 = localBlockPosition1.down();
|
||||
double d1 = paramInt2 - (1.0D - this.a.getType(localBlockPosition2).c(this.a, localBlockPosition2).e);
|
||||
if (d1 - paramDouble > 1.0D) {
|
||||
return null;
|
||||
}
|
||||
PathType localPathType = a(this.b, paramInt1, paramInt2, paramInt3);
|
||||
float f = this.b.a(localPathType);
|
||||
double d2 = this.b.width / 2.0D;
|
||||
if (f >= 0.0F) {
|
||||
localPathPoint = a(paramInt1, paramInt2, paramInt3);
|
||||
localPathPoint.m = localPathType;
|
||||
localPathPoint.l = Math.max(localPathPoint.l, f);
|
||||
}
|
||||
if (localPathType == PathType.WALKABLE) {
|
||||
return localPathPoint;
|
||||
}
|
||||
if ((localPathPoint == null) && (paramInt4 > 0) && (localPathType != PathType.FENCE)
|
||||
&& (localPathType != PathType.TRAPDOOR)) {
|
||||
localPathPoint = a(paramInt1, paramInt2 + 1, paramInt3, paramInt4 - 1, paramDouble, paramEnumDirection);
|
||||
if ((localPathPoint != null)
|
||||
&& ((localPathPoint.m == PathType.OPEN) || (localPathPoint.m == PathType.WALKABLE))) {
|
||||
double d3 = paramInt1 - paramEnumDirection.getAdjacentX() + 0.5D;
|
||||
double d4 = paramInt3 - paramEnumDirection.getAdjacentZ() + 0.5D;
|
||||
|
||||
AxisAlignedBB localAxisAlignedBB1 = new AxisAlignedBB(d3 - d2, paramInt2 + 0.001D, d4 - d2, d3 + d2,
|
||||
paramInt2 + this.b.length, d4 + d2);
|
||||
AxisAlignedBB localAxisAlignedBB2 = this.a.getType(localBlockPosition1).c(this.a, localBlockPosition1);
|
||||
|
||||
AxisAlignedBB localAxisAlignedBB3 = localAxisAlignedBB1.a(0.0D, localAxisAlignedBB2.e - 0.002D, 0.0D);
|
||||
if (this.b.world.b(localAxisAlignedBB3)) {
|
||||
localPathPoint = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (localPathType == PathType.OPEN) {
|
||||
AxisAlignedBB localAxisAlignedBB4 = new AxisAlignedBB(paramInt1 - d2 + 0.5D, paramInt2 + 0.001D,
|
||||
paramInt3 - d2 + 0.5D, paramInt1 + d2 + 0.5D, paramInt2 + this.b.length, paramInt3 + d2 + 0.5D);
|
||||
if (this.b.world.b(localAxisAlignedBB4)) {
|
||||
return null;
|
||||
}
|
||||
int i = 0;
|
||||
while ((paramInt2 > 0) && (localPathType == PathType.OPEN)) {
|
||||
paramInt2--;
|
||||
if (i++ >= this.b.aY()) {
|
||||
return null;
|
||||
}
|
||||
localPathType = a(this.b, paramInt1, paramInt2, paramInt3);
|
||||
f = this.b.a(localPathType);
|
||||
if ((localPathType != PathType.OPEN) && (f >= 0.0F)) {
|
||||
localPathPoint = a(paramInt1, paramInt2, paramInt3);
|
||||
localPathPoint.m = localPathType;
|
||||
localPathPoint.l = Math.max(localPathPoint.l, f);
|
||||
} else if (f < 0.0F) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return localPathPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int a(PathPoint[] paramArrayOfPathPoint, PathPoint paramPathPoint1, PathPoint paramPathPoint2,
|
||||
float paramFloat) {
|
||||
int i = 0;
|
||||
|
||||
int k = 0;
|
||||
PathType localPathType = a(this.b, paramPathPoint1.a, paramPathPoint1.b + 1, paramPathPoint1.c);
|
||||
if (this.b.a(localPathType) >= 0.0F) {
|
||||
k = 1;
|
||||
}
|
||||
BlockPosition localBlockPosition = new BlockPosition(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c)
|
||||
.down();
|
||||
double d = paramPathPoint1.b - (1.0D - this.a.getType(localBlockPosition).c(this.a, localBlockPosition).e);
|
||||
|
||||
PathPoint localPathPoint1 = a(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c + 1, k, d,
|
||||
EnumDirection.SOUTH);
|
||||
PathPoint localPathPoint2 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c, k, d,
|
||||
EnumDirection.WEST);
|
||||
PathPoint localPathPoint3 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c, k, d,
|
||||
EnumDirection.EAST);
|
||||
PathPoint localPathPoint4 = a(paramPathPoint1.a, paramPathPoint1.b, paramPathPoint1.c - 1, k, d,
|
||||
EnumDirection.NORTH);
|
||||
if ((localPathPoint1 != null) && (!localPathPoint1.i) && (localPathPoint1.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint1;
|
||||
}
|
||||
if ((localPathPoint2 != null) && (!localPathPoint2.i) && (localPathPoint2.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint2;
|
||||
}
|
||||
if ((localPathPoint3 != null) && (!localPathPoint3.i) && (localPathPoint3.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint3;
|
||||
}
|
||||
if ((localPathPoint4 != null) && (!localPathPoint4.i) && (localPathPoint4.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint4;
|
||||
}
|
||||
int m = (localPathPoint4 == null) || (localPathPoint4.m == PathType.OPEN) || (localPathPoint4.l != 0.0F) ? 1
|
||||
: 0;
|
||||
int n = (localPathPoint1 == null) || (localPathPoint1.m == PathType.OPEN) || (localPathPoint1.l != 0.0F) ? 1
|
||||
: 0;
|
||||
int i1 = (localPathPoint3 == null) || (localPathPoint3.m == PathType.OPEN) || (localPathPoint3.l != 0.0F) ? 1
|
||||
: 0;
|
||||
int i2 = (localPathPoint2 == null) || (localPathPoint2.m == PathType.OPEN) || (localPathPoint2.l != 0.0F) ? 1
|
||||
: 0;
|
||||
PathPoint localPathPoint5;
|
||||
if ((m != 0) && (i2 != 0)) {
|
||||
localPathPoint5 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c - 1, k, d,
|
||||
EnumDirection.NORTH);
|
||||
if ((localPathPoint5 != null) && (!localPathPoint5.i)
|
||||
&& (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint5;
|
||||
}
|
||||
}
|
||||
if ((m != 0) && (i1 != 0)) {
|
||||
localPathPoint5 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c - 1, k, d,
|
||||
EnumDirection.NORTH);
|
||||
if ((localPathPoint5 != null) && (!localPathPoint5.i)
|
||||
&& (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint5;
|
||||
}
|
||||
}
|
||||
if ((n != 0) && (i2 != 0)) {
|
||||
localPathPoint5 = a(paramPathPoint1.a - 1, paramPathPoint1.b, paramPathPoint1.c + 1, k, d,
|
||||
EnumDirection.SOUTH);
|
||||
if ((localPathPoint5 != null) && (!localPathPoint5.i)
|
||||
&& (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint5;
|
||||
}
|
||||
}
|
||||
if ((n != 0) && (i1 != 0)) {
|
||||
localPathPoint5 = a(paramPathPoint1.a + 1, paramPathPoint1.b, paramPathPoint1.c + 1, k, d,
|
||||
EnumDirection.SOUTH);
|
||||
if ((localPathPoint5 != null) && (!localPathPoint5.i)
|
||||
&& (localPathPoint5.a(paramPathPoint2) < paramFloat)) {
|
||||
paramArrayOfPathPoint[(i++)] = localPathPoint5;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PathPoint b() {
|
||||
int i;
|
||||
BlockPosition localObject1;
|
||||
if ((e()) && (this.b.isInWater())) {
|
||||
i = (int) this.b.getBoundingBox().b;
|
||||
localObject1 = new BlockPosition.MutableBlockPosition(MathHelper.floor(this.b.locX), i,
|
||||
MathHelper.floor(this.b.locZ));
|
||||
Block localObject2 = this.a.getType(localObject1).getBlock();
|
||||
while ((localObject2 == Blocks.FLOWING_WATER) || (localObject2 == Blocks.WATER)) {
|
||||
i++;
|
||||
((MutableBlockPosition) localObject1).c(MathHelper.floor(this.b.locX), i,
|
||||
MathHelper.floor(this.b.locZ));
|
||||
localObject2 = this.a.getType(localObject1).getBlock();
|
||||
}
|
||||
} else if (!this.b.onGround) {
|
||||
localObject1 = new BlockPosition(this.b);
|
||||
while (((this.a.getType(localObject1).getMaterial() == Material.AIR)
|
||||
|| (this.a.getType(localObject1).getBlock().b(this.a, localObject1)))
|
||||
&& (localObject1.getY() > 0)) {
|
||||
localObject1 = localObject1.down();
|
||||
}
|
||||
i = localObject1.up().getY();
|
||||
} else {
|
||||
i = MathHelper.floor(this.b.getBoundingBox().b + 0.5D);
|
||||
}
|
||||
localObject1 = new BlockPosition(this.b);
|
||||
Object localObject2 = a(this.b, localObject1.getX(), i, localObject1.getZ());
|
||||
if (this.b.a((PathType) localObject2) < 0.0F) {
|
||||
HashSet<BlockPosition> localHashSet = new HashSet<BlockPosition>();
|
||||
localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().c));
|
||||
localHashSet.add(new BlockPosition(this.b.getBoundingBox().a, i, this.b.getBoundingBox().f));
|
||||
localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().c));
|
||||
localHashSet.add(new BlockPosition(this.b.getBoundingBox().d, i, this.b.getBoundingBox().f));
|
||||
for (BlockPosition localBlockPosition : localHashSet) {
|
||||
PathType localPathType = a(this.b, localBlockPosition);
|
||||
if (this.b.a(localPathType) >= 0.0F) {
|
||||
return a(localBlockPosition.getX(), localBlockPosition.getY(), localBlockPosition.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
return a(localObject1.getX(), i, localObject1.getZ());
|
||||
}
|
||||
|
||||
public PathType getPathTypeBase(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3) {
|
||||
BlockPosition localBlockPosition = new BlockPosition(paramInt1, paramInt2, paramInt3);
|
||||
IBlockData localIBlockData = paramIBlockAccess.getType(localBlockPosition);
|
||||
Block localBlock1 = localIBlockData.getBlock();
|
||||
Material localMaterial = localIBlockData.getMaterial();
|
||||
|
||||
PathType localPathType1 = PathType.BLOCKED;
|
||||
if ((localBlock1 == Blocks.TRAPDOOR) || (localBlock1 == Blocks.IRON_TRAPDOOR)
|
||||
|| (localBlock1 == Blocks.WATERLILY)) {
|
||||
return PathType.TRAPDOOR;
|
||||
}
|
||||
if (localBlock1 == Blocks.FIRE) {
|
||||
return PathType.DAMAGE_FIRE;
|
||||
}
|
||||
if (localBlock1 == Blocks.CACTUS) {
|
||||
return PathType.DAMAGE_CACTUS;
|
||||
}
|
||||
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.WOOD)
|
||||
&& (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
|
||||
return PathType.DOOR_WOOD_CLOSED;
|
||||
}
|
||||
if (((localBlock1 instanceof BlockDoor)) && (localMaterial == Material.ORE)
|
||||
&& (!localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
|
||||
return PathType.DOOR_IRON_CLOSED;
|
||||
}
|
||||
if (((localBlock1 instanceof BlockDoor)) && (localIBlockData.get(BlockDoor.OPEN).booleanValue())) {
|
||||
return PathType.DOOR_OPEN;
|
||||
}
|
||||
if ((localBlock1 instanceof BlockMinecartTrackAbstract)) {
|
||||
return PathType.RAIL;
|
||||
}
|
||||
if (((localBlock1 instanceof BlockFence)) || ((localBlock1 instanceof BlockCobbleWall))
|
||||
|| (((localBlock1 instanceof BlockFenceGate))
|
||||
&& (!localIBlockData.get(BlockFenceGate.OPEN).booleanValue()))) {
|
||||
return PathType.FENCE;
|
||||
}
|
||||
if (localMaterial == Material.AIR) {
|
||||
localPathType1 = PathType.OPEN;
|
||||
} else {
|
||||
if (localMaterial == Material.WATER) {
|
||||
return PathType.WATER;
|
||||
}
|
||||
if (localMaterial == Material.LAVA) {
|
||||
return PathType.LAVA;
|
||||
}
|
||||
}
|
||||
if ((localBlock1.b(paramIBlockAccess, localBlockPosition)) && (localPathType1 == PathType.BLOCKED)) {
|
||||
localPathType1 = PathType.OPEN;
|
||||
}
|
||||
return localPathType1;
|
||||
}
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
package net.citizensnpcs.nms.v1_10_R1.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC;
|
||||
import net.citizensnpcs.npc.skin.SkinnableEntity;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_10_R1.EntityTrackerEntry;
|
||||
|
||||
public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
||||
public PlayerlistTrackerEntry(Entity entity, int i, int j, int k, boolean flag) {
|
||||
super(entity, i, j, k, flag);
|
||||
}
|
||||
|
||||
public PlayerlistTrackerEntry(EntityTrackerEntry entry) {
|
||||
this(getTracker(entry), getE(entry), getF(entry), getG(entry), getU(entry));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePlayer(final EntityPlayer entityplayer) {
|
||||
// prevent updates to NPC "viewers"
|
||||
if (entityplayer instanceof EntityHumanNPC)
|
||||
return;
|
||||
Entity tracker = getTracker(this);
|
||||
if (entityplayer != tracker && c(entityplayer)) {
|
||||
if (!this.trackedPlayers.contains(entityplayer)
|
||||
&& ((entityplayer.x().getPlayerChunkMap().a(entityplayer, tracker.ac, tracker.ae))
|
||||
|| (tracker.attachedToPlayer))) {
|
||||
if ((tracker instanceof SkinnableEntity)) {
|
||||
|
||||
SkinnableEntity skinnable = (SkinnableEntity) tracker;
|
||||
|
||||
Player player = skinnable.getBukkitEntity();
|
||||
if (!entityplayer.getBukkitEntity().canSee(player))
|
||||
return;
|
||||
|
||||
skinnable.getSkinTracker().updateViewer(entityplayer.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
super.updatePlayer(entityplayer);
|
||||
}
|
||||
|
||||
private static int getE(EntityTrackerEntry entry) {
|
||||
try {
|
||||
return (Integer) E.get(entry);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int getF(EntityTrackerEntry entry) {
|
||||
try {
|
||||
return (Integer) F.get(entry);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int getG(EntityTrackerEntry entry) {
|
||||
try {
|
||||
return (Integer) G.get(entry);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static Entity getTracker(EntityTrackerEntry entry) {
|
||||
try {
|
||||
return (Entity) TRACKER.get(entry);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean getU(EntityTrackerEntry entry) {
|
||||
try {
|
||||
return (Boolean) U.get(entry);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Field E = NMS.getField(EntityTrackerEntry.class, "e");
|
||||
private static Field F = NMS.getField(EntityTrackerEntry.class, "f");
|
||||
private static Field G = NMS.getField(EntityTrackerEntry.class, "g");
|
||||
private static Field TRACKER = NMS.getField(EntityTrackerEntry.class, "tracker");
|
||||
private static Field U = NMS.getField(EntityTrackerEntry.class, "u");
|
||||
}
|
Loading…
Reference in New Issue