Set NPCs as persistent

This commit is contained in:
fullwall 2014-01-21 12:25:14 +08:00
parent 74f6c0c543
commit 628c61ae3e
29 changed files with 311 additions and 164 deletions

View File

@ -132,6 +132,11 @@ public class BatController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setFlying(boolean flying) {
a(flying);
}

View File

@ -122,5 +122,10 @@ public class BlazeController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
}

View File

@ -165,5 +165,10 @@ public class CaveSpiderController extends MobEntityController {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
}

View File

@ -150,5 +150,10 @@ public class ChickenController extends MobEntityController {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
}

View File

@ -153,5 +153,10 @@ public class CowController extends MobEntityController {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
}

View File

@ -108,15 +108,6 @@ public class CreeperController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -160,6 +151,20 @@ public class CreeperController extends MobEntityController {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setAllowPowered(boolean allowPowered) {
this.allowPowered = allowPowered;
}

View File

@ -143,5 +143,10 @@ public class EnderDragonController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
}

View File

@ -172,6 +172,11 @@ public class EndermanController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected boolean k(double d1, double d2, double d3) {
if (npc == null) {

View File

@ -105,6 +105,11 @@ public class GhastController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class GhastNPC extends CraftGhast implements NPCHolder {

View File

@ -88,15 +88,6 @@ public class GiantController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -139,6 +130,20 @@ public class GiantController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class GiantNPC extends CraftGiant implements NPCHolder {

View File

@ -152,6 +152,11 @@ public class HorseController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
private void updateAIWithMovement() {
NMS.updateAI(this);
// taken from EntityLiving update method

View File

@ -85,15 +85,6 @@ public class IronGolemController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -136,6 +127,20 @@ public class IronGolemController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class IronGolemNPC extends CraftIronGolem implements NPCHolder {

View File

@ -96,15 +96,6 @@ public class MagmaCubeController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -147,6 +138,20 @@ public class MagmaCubeController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class MagmaCubeNPC extends CraftMagmaCube implements NPCHolder {

View File

@ -86,15 +86,6 @@ public class MushroomCowController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -137,6 +128,20 @@ public class MushroomCowController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class MushroomCowNPC extends CraftMushroomCow implements NPCHolder {

View File

@ -86,15 +86,6 @@ public class OcelotController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -137,6 +128,20 @@ public class OcelotController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class OcelotNPC extends CraftOcelot implements NPCHolder {

View File

@ -92,15 +92,6 @@ public class PigController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -143,6 +134,20 @@ public class PigController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class PigNPC extends CraftPig implements NPCHolder {

View File

@ -96,15 +96,6 @@ public class PigZombieController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -147,6 +138,20 @@ public class PigZombieController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class PigZombieNPC extends CraftPigZombie implements NPCHolder {

View File

@ -86,15 +86,6 @@ public class SheepController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -137,6 +128,20 @@ public class SheepController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SheepNPC extends CraftSheep implements NPCHolder {

View File

@ -95,15 +95,6 @@ public class SilverfishController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -146,6 +137,20 @@ public class SilverfishController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SilverfishNPC extends CraftSilverfish implements NPCHolder {

View File

@ -85,15 +85,6 @@ public class SkeletonController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -136,6 +127,20 @@ public class SkeletonController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SkeletonNPC extends CraftSkeleton implements NPCHolder {

View File

@ -97,15 +97,6 @@ public class SlimeController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -148,6 +139,20 @@ public class SlimeController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SlimeNPC extends CraftSlime implements NPCHolder {

View File

@ -85,15 +85,6 @@ public class SnowmanController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -136,6 +127,20 @@ public class SnowmanController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SnowmanNPC extends CraftSnowman implements NPCHolder {

View File

@ -95,15 +95,6 @@ public class SpiderController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -146,6 +137,20 @@ public class SpiderController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SpiderNPC extends CraftSpider implements NPCHolder {

View File

@ -86,15 +86,6 @@ public class SquidController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -137,6 +128,20 @@ public class SquidController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class SquidNPC extends CraftSquid implements NPCHolder {

View File

@ -54,7 +54,7 @@ public class VillagerController extends MobEntityController {
@Override
public boolean a(EntityHuman entityhuman) {
return npc == null || !blockTrades ? super.a(entityhuman) : false; // block
// trades
// trades
}
@Override
@ -80,8 +80,9 @@ public class VillagerController extends MobEntityController {
@Override
public void bn() {
super.bn();
if (npc != null)
if (npc != null) {
npc.update();
}
}
@Override
@ -89,16 +90,8 @@ public class VillagerController extends MobEntityController {
// this method is called by both the entities involved - cancelling
// it will not stop the NPC from moving.
super.collide(entity);
if (npc != null)
if (npc != null) {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@ -145,10 +138,24 @@ public class VillagerController extends MobEntityController {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
public boolean isBlockingTrades() {
return blockTrades;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setBlockTrades(boolean blocked) {
this.blockTrades = blocked;
}

View File

@ -85,15 +85,6 @@ public class WitchController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -136,6 +127,20 @@ public class WitchController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class WitchNPC extends CraftWitch implements NPCHolder {

View File

@ -116,6 +116,11 @@ public class WitherController extends MobEntityController {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
private void updateAIWithMovement() {
NMS.updateAI(this);
// taken from EntityLiving update method

View File

@ -139,6 +139,11 @@ public class WolfController extends MobEntityController {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class WolfNPC extends CraftWolf implements NPCHolder {

View File

@ -86,15 +86,6 @@ public class ZombieController extends MobEntityController {
Util.callCollisionEvent(npc, entity.getBukkitEntity());
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
public void e(float f, float f1) {
if (npc == null || !npc.isFlyable()) {
@ -137,6 +128,20 @@ public class ZombieController extends MobEntityController {
public NPC getNPC() {
return npc;
}
@Override
public boolean h_() {
if (npc == null || !npc.isFlyable()) {
return super.h_();
} else {
return false;
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
}
public static class ZombieNPC extends CraftZombie implements NPCHolder {