Check chunk loaded as well, may fix the yaw issue with players

This commit is contained in:
fullwall 2012-11-04 10:34:57 +08:00
parent 871259dcff
commit 8fea42eba4
3 changed files with 27 additions and 9 deletions

View File

@ -20,6 +20,7 @@ import net.citizensnpcs.trait.CurrentLocation;
import net.citizensnpcs.util.Messages; import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Messaging; import net.citizensnpcs.util.Messaging;
import net.citizensnpcs.util.NMS; import net.citizensnpcs.util.NMS;
import net.citizensnpcs.util.Util;
import net.minecraft.server.EntityLiving; import net.minecraft.server.EntityLiving;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -178,7 +179,8 @@ public abstract class CitizensNPC extends AbstractNPC {
return false; return false;
mcEntity = createHandle(loc); mcEntity = createHandle(loc);
boolean couldSpawn = mcEntity.world.addEntity(mcEntity, SpawnReason.CUSTOM); boolean couldSpawn = !Util.isLoaded(loc) ? false : mcEntity.world.addEntity(mcEntity,
SpawnReason.CUSTOM);
if (!couldSpawn) { if (!couldSpawn) {
// we need to wait for a chunk load before trying to spawn // we need to wait for a chunk load before trying to spawn
mcEntity = null; mcEntity = null;

View File

@ -166,4 +166,12 @@ public class Util {
} }
} }
} }
public static boolean isLoaded(Location location) {
if (location.getWorld() == null)
return false;
int chunkX = location.getBlockX() >> 4;
int chunkZ = location.getBlockZ() >> 4;
return location.getWorld().isChunkLoaded(chunkX, chunkZ);
}
} }

View File

@ -41,36 +41,44 @@ permissions:
citizens.npc.*: citizens.npc.*:
children: children:
citizens.npc.age: true citizens.npc.age: true
citizens.npc.pose: true citizens.npc.anchor: true
citizens.npc.behaviour: true citizens.npc.behaviour: true
citizens.npc.create: true
citizens.npc.controllable: true citizens.npc.controllable: true
citizens.npc.copy: true citizens.npc.copy: true
citizens.npc.create: true
citizens.npc.despawn: true citizens.npc.despawn: true
citizens.npc.edit.*: citizens.npc.edit.*:
children: children:
citizens.npc.edit.equip: true citizens.npc.edit.equip: true
citizens.npc.edit.path: true citizens.npc.edit.path: true
citizens.npc.edit.text: true
citizens.npc.gravity: true
citizens.npc.help: true citizens.npc.help: true
citizens.npc.ignore-cost: true
citizens.npc.list: true citizens.npc.list: true
citizens.npc.lookclose: true citizens.npc.lookclose: true
citizens.npc.moveto: true citizens.npc.moveto: true
citizens.npc.owner: true citizens.npc.owner: true
citizens.npc.path: true citizens.npc.path: true
citizens.npc.pathfindingrange: true
citizens.npc.pose: true
citizens.npc.power: true citizens.npc.power: true
citizens.npc.profession: true citizens.npc.profession: true
citizens.npc.remove.*:
children:
citizens.npc.remove: true citizens.npc.remove: true
citizens.npc.remove.all: true citizens.npc.remove.all: true
citizens.npc.rename: true citizens.npc.rename: true
citizens.npc.select: true citizens.npc.select: true
citizens.npc.size: true
citizens.npc.skeletontype: true
citizens.npc.spawn: true citizens.npc.spawn: true
citizens.npc.speed: true citizens.npc.speed: true
citizens.npc.talk: true citizens.npc.talk: true
citizens.npc.text: true citizens.npc.tp: true
citizens.npc.tphere: true
citizens.npc.trait.*: citizens.npc.trait.*:
children: children:
citizens.npc.trait: true citizens.npc.trait: true
citizens.npc.trait-configure: true citizens.npc.trait-configure: true
citizens.npc.trait-configure.*: true citizens.npc.vulnerable: true
citizens.npc.tp: true
citizens.npc.tphere: true