Better overriding of persistent check

This commit is contained in:
fullwall 2014-02-20 11:57:24 +08:00
parent 5b2e5323c3
commit 8700974e88
30 changed files with 203 additions and 136 deletions

View File

@ -120,12 +120,17 @@ public class EventListen implements Listener {
continue;
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
event.setCancelled(true);
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
if (Messaging.isDebugging()) {
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
}
respawnAllFromCoord(coord);
return;
}
toRespawn.put(coord, npc);
Messaging.debug("Despawned id", npc.getId(), "due to chunk unload at [" + coord.x + "," + coord.z + "]");
if (Messaging.isDebugging()) {
Messaging
.debug("Despawned id", npc.getId(), "due to chunk unload at [" + coord.x + "," + coord.z + "]");
}
}
}
@ -322,19 +327,25 @@ public class EventListen implements Listener {
NPC npc = ids.get(i);
boolean success = spawn(npc);
if (!success) {
Messaging.debug("Couldn't respawn id", npc.getId(), "during chunk event at [" + coord.x + "," + coord.z
+ "]");
if (Messaging.isDebugging()) {
Messaging.debug("Couldn't respawn id", npc.getId(), "during chunk event at [" + coord.x + ","
+ coord.z + "]");
}
continue;
}
ids.remove(i--);
Messaging.debug("Spawned id", npc.getId(), "due to chunk event at [" + coord.x + "," + coord.z + "]");
if (Messaging.isDebugging()) {
Messaging.debug("Spawned id", npc.getId(), "due to chunk event at [" + coord.x + "," + coord.z + "]");
}
}
}
private boolean spawn(NPC npc) {
Location spawn = npc.getTrait(CurrentLocation.class).getLocation();
if (spawn == null) {
Messaging.debug("Couldn't find a spawn location for despawned NPC id", npc.getId());
if (Messaging.isDebugging()) {
Messaging.debug("Couldn't find a spawn location for despawned NPC id", npc.getId());
}
return false;
}
return npc.spawn(spawn);
@ -389,9 +400,7 @@ public class EventListen implements Listener {
@Override
public int hashCode() {
final int prime = 31;
int result = prime + ((worldName == null) ? 0 : worldName.hashCode());
result = prime * result + x;
return prime * result + z;
return prime * (prime * (prime + ((worldName == null) ? 0 : worldName.hashCode())) + x) + z;
}
}
}

View File

@ -142,11 +142,6 @@ public class BatController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setFlying(boolean flying) {
a(flying);
}
@ -155,5 +150,12 @@ public class BatController extends MobEntityController {
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -133,14 +133,16 @@ public class BlazeController extends MobEntityController {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -175,14 +175,16 @@ public class CaveSpiderController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -161,14 +161,16 @@ public class ChickenController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -164,14 +164,16 @@ public class CowController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -170,11 +170,6 @@ public class CreeperController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setAllowPowered(boolean allowPowered) {
this.allowPowered = allowPowered;
}
@ -183,5 +178,12 @@ public class CreeperController extends MobEntityController {
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -154,14 +154,16 @@ public class EnderDragonController extends MobEntityController {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -182,11 +182,6 @@ 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) {
@ -224,5 +219,12 @@ public class EndermanController extends MobEntityController {
jumpTicks--;
}
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
}

View File

@ -117,13 +117,15 @@ public class GhastController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -151,13 +151,15 @@ public class GiantController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -162,11 +162,6 @@ public class HorseController extends MobEntityController {
}
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
@ -197,6 +192,13 @@ public class HorseController extends MobEntityController {
jumpTicks--;
}
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
public static class HorseNPC extends CraftHorse implements NPCHolder {

View File

@ -148,13 +148,15 @@ public class IronGolemController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -159,13 +159,15 @@ public class MagmaCubeController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -149,13 +149,15 @@ public class MushroomCowController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -149,13 +149,15 @@ public class OcelotController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -155,13 +155,15 @@ public class PigController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -159,13 +159,15 @@ public class PigZombieController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -149,13 +149,15 @@ public class SheepController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -158,13 +158,15 @@ public class SilverfishController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -148,13 +148,15 @@ public class SkeletonController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -160,13 +160,15 @@ public class SlimeController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -148,13 +148,15 @@ public class SnowmanController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -158,13 +158,15 @@ public class SpiderController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -149,13 +149,15 @@ public class SquidController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -161,11 +161,6 @@ public class VillagerController extends MobEntityController {
return blockTrades;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
public void setBlockTrades(boolean blocked) {
this.blockTrades = blocked;
}
@ -174,6 +169,13 @@ public class VillagerController extends MobEntityController {
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
public static class VillagerNPC extends CraftVillager implements NPCHolder {

View File

@ -148,13 +148,15 @@ public class WitchController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -126,11 +126,6 @@ public class WitherController extends MobEntityController {
return npc;
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
@ -161,6 +156,13 @@ public class WitherController extends MobEntityController {
jumpTicks--;
}
}
@Override
protected void w() {
if (npc == null) {
super.w();
}
}
}
public static class WitherNPC extends CraftWither implements NPCHolder {

View File

@ -150,13 +150,15 @@ public class WolfController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}

View File

@ -149,13 +149,15 @@ public class ZombieController extends MobEntityController {
}
@Override
protected boolean isTypeNotPersistent() {
return npc == null ? super.isTypeNotPersistent() : false;
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
}
@Override
protected String t() {
return npc == null ? super.aT() : npc.data().get(NPC.AMBIENT_SOUND_METADATA, super.t());
protected void w() {
if (npc == null) {
super.w();
}
}
}