Add isPushable() and setPushable(), cleanup

This commit is contained in:
fullwall 2012-07-24 14:47:10 +08:00
parent 7158aa6bfb
commit 4cf071bf4b
31 changed files with 390 additions and 23 deletions

View File

@ -132,11 +132,6 @@ public class EventListen implements Listener {
// undesirable as player NPCs are not real players and confuse plugins.
}
@EventHandler(ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
Editor.leave(event.getPlayer());
}
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!npcRegistry.isNPC(event.getRightClicked()))
@ -147,6 +142,11 @@ public class EventListen implements Listener {
new EntityTargetEvent(event.getRightClicked(), event.getPlayer(), TargetReason.CUSTOM));
}
@EventHandler(ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
Editor.leave(event.getPlayer());
}
/*
* World events
*/

View File

@ -114,7 +114,7 @@ public class CitizensNavigator implements Navigator {
}
public void update() {
if (executing == null)
if (executing == null || !npc.isSpawned())
return;
boolean finished = executing.update();
if (finished) {

View File

@ -4,4 +4,8 @@ import net.citizensnpcs.api.npc.NPC;
public interface NPCHolder {
public NPC getNPC();
boolean isPushable();
void setPushable(boolean pushable);
}

View File

@ -24,6 +24,8 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
public static class EntityBlazeNPC extends EntityBlaze implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityBlazeNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -55,5 +59,15 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
public static class EntityCaveSpiderNPC extends EntityCaveSpider implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityCaveSpiderNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
@ -35,6 +37,8 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -44,6 +48,16 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensChickenNPC extends CitizensMobNPC {
public static class EntityChickenNPC extends EntityChicken implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityChickenNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensChickenNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensChickenNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensCowNPC extends CitizensMobNPC {
public static class EntityCowNPC extends EntityCow implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityCowNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensCowNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensCowNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,7 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
public static class EntityCreeperNPC extends EntityCreeper implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityCreeperNPC(World world) {
this(world, null);
@ -46,6 +47,8 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -55,6 +58,16 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
public static class EntityEnderDragonNPC extends EntityEnderDragon implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityEnderDragonNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
@ -35,6 +37,8 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -57,5 +61,15 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -62,6 +62,8 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
public static class EntityEndermanNPC extends EntityEnderman implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityEndermanNPC(World world) {
this(world, null);
}
@ -77,6 +79,8 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -99,5 +103,15 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensGhastNPC extends CitizensMobNPC {
public static class EntityGhastNPC extends EntityGhast implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityGhastNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensGhastNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -55,5 +59,15 @@ public class CitizensGhastNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensGiantNPC extends CitizensMobNPC {
public static class EntityGiantNPC extends EntityGiantZombie implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityGiantNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
@ -35,6 +37,8 @@ public class CitizensGiantNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,5 +52,15 @@ public class CitizensGiantNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
public static class EntityIronGolemNPC extends EntityIronGolem implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityIronGolemNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
@ -35,6 +37,8 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -44,6 +48,16 @@ public class CitizensIronGolemNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
public static class EntityMagmaCubeNPC extends EntityMagmaCube implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityMagmaCubeNPC(World world) {
this(world, null);
}
@ -40,6 +42,8 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -56,5 +60,15 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
public static class EntityMushroomCowNPC extends EntityMushroomCow implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityMushroomCowNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
public static class EntityOcelotNPC extends EntityOcelot implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityOcelotNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensOcelotNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -51,6 +51,8 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
public static class EntityPigNPC extends EntityPig implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityPigNPC(World world) {
this(world, null);
}
@ -72,6 +74,8 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -81,6 +85,16 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
public static class EntityPigZombieNPC extends EntityPigZombie implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityPigZombieNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -55,5 +59,15 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -62,6 +62,8 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
public static class EntitySheepNPC extends EntitySheep implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySheepNPC(World world) {
this(world, null);
}
@ -77,6 +79,8 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -86,6 +90,16 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
public static class EntitySilverfishNPC extends EntitySilverfish implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySilverfishNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
public static class EntitySkeletonNPC extends EntitySkeleton implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySkeletonNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
public static class EntitySlimeNPC extends EntitySlime implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySlimeNPC(World world) {
this(world, null);
}
@ -40,6 +42,8 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -49,6 +53,16 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
public static class EntitySnowmanNPC extends EntitySnowman implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySnowmanNPC(World world, NPC npc) {
super(world);
this.npc = (CitizensNPC) npc;
@ -35,6 +37,8 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -44,6 +48,16 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
public static class EntitySpiderNPC extends EntitySpider implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySpiderNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensSquidNPC extends CitizensMobNPC {
public static class EntitySquidNPC extends EntitySquid implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntitySquidNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensSquidNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -55,5 +59,15 @@ public class CitizensSquidNPC extends CitizensMobNPC {
public NPC getNPC() {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}
}

View File

@ -24,6 +24,8 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
public static class EntityVillagerNPC extends EntityVillager implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityVillagerNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensWolfNPC extends CitizensMobNPC {
public static class EntityWolfNPC extends EntityWolf implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityWolfNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensWolfNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensWolfNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -24,6 +24,8 @@ public class CitizensZombieNPC extends CitizensMobNPC {
public static class EntityZombieNPC extends EntityZombie implements NPCHolder {
private final CitizensNPC npc;
private boolean pushable = false;
public EntityZombieNPC(World world) {
this(world, null);
}
@ -39,6 +41,8 @@ public class CitizensZombieNPC extends CitizensMobNPC {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -48,6 +52,16 @@ public class CitizensZombieNPC extends CitizensMobNPC {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
@Override
public void z_() {
super.z_();

View File

@ -19,6 +19,8 @@ import net.minecraft.server.World;
public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
private CitizensNPC npc;
private boolean pushable = false;
public EntityHumanNPC(MinecraftServer minecraftServer, World world, String string,
ItemInWorldManager itemInWorldManager, NPC npc) {
super(minecraftServer, world, string, itemInWorldManager);
@ -44,6 +46,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
@Override
public void b_(double x, double y, double z) {
if (npc == null || pushable)
super.b_(x, y, z);
// when another entity collides, b_ is called to push the NPC
// so we prevent b_ from doing anything.
}
@ -68,6 +72,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
return npc;
}
@Override
public boolean isPushable() {
return pushable;
}
private void moveOnCurrentHeading() {
getControllerMove().c();
getControllerLook().a();
@ -91,4 +100,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
a(aW, aX);
X = yaw;
}
@Override
public void setPushable(boolean pushable) {
this.pushable = pushable;
}
}

View File

@ -23,8 +23,8 @@ import com.google.common.collect.Lists;
public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoint> {
private WaypointGoal currentGoal;
private final List<Waypoint> waypoints = Lists.newArrayList();
private NPC npc;
private final List<Waypoint> waypoints = Lists.newArrayList();
@Override
public Editor createEditor(final Player player) {
@ -47,6 +47,12 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
location.getBlockY(), location.getBlockZ());
}
@EventHandler
public void onNPCDespawn(NPCDespawnEvent event) {
if (event.getNPC().equals(npc))
end();
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (!event.getPlayer().equals(player) || event.getAction() == Action.PHYSICAL)
@ -73,12 +79,6 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
currentGoal.onProviderChanged();
}
@EventHandler
public void onNPCDespawn(NPCDespawnEvent event) {
if (event.getNPC().equals(npc))
end();
}
@EventHandler
public void onPlayerItemHeldChange(PlayerItemHeldEvent event) {
if (!event.getPlayer().equals(player) || waypoints.size() == 0)
@ -107,14 +107,6 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
};
}
@Override
public void onSpawn(NPC npc) {
this.npc = npc;
if (currentGoal == null)
currentGoal = new WaypointGoal(this, npc.getNavigator());
npc.getDefaultGoalController().addGoal(currentGoal, 1);
}
@Override
public Iterator<Waypoint> iterator() {
return waypoints.iterator();
@ -130,6 +122,14 @@ public class LinearWaypointProvider implements WaypointProvider, Iterable<Waypoi
}
}
@Override
public void onSpawn(NPC npc) {
this.npc = npc;
if (currentGoal == null)
currentGoal = new WaypointGoal(this, npc.getNavigator());
npc.getDefaultGoalController().addGoal(currentGoal, 1);
}
@Override
public void save(DataKey key) {
key.removeKey("points");

View File

@ -25,6 +25,8 @@ public interface WaypointProvider {
*/
public void load(DataKey key);
public void onSpawn(NPC npc);
/**
* Saves to the specified {@link DataKey}.
*
@ -32,6 +34,4 @@ public interface WaypointProvider {
* The key to save to
*/
public void save(DataKey key);
public void onSpawn(NPC npc);
}