mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-01 14:08:08 +01:00
Check chunk loaded as well, may fix the yaw issue with players
This commit is contained in:
parent
871259dcff
commit
8fea42eba4
@ -20,6 +20,7 @@ import net.citizensnpcs.trait.CurrentLocation;
|
||||
import net.citizensnpcs.util.Messages;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.NMS;
|
||||
import net.citizensnpcs.util.Util;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -178,7 +179,8 @@ public abstract class CitizensNPC extends AbstractNPC {
|
||||
return false;
|
||||
|
||||
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) {
|
||||
// we need to wait for a chunk load before trying to spawn
|
||||
mcEntity = null;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -41,36 +41,44 @@ permissions:
|
||||
citizens.npc.*:
|
||||
children:
|
||||
citizens.npc.age: true
|
||||
citizens.npc.pose: true
|
||||
citizens.npc.anchor: true
|
||||
citizens.npc.behaviour: true
|
||||
citizens.npc.create: true
|
||||
citizens.npc.controllable: true
|
||||
citizens.npc.copy: true
|
||||
citizens.npc.create: true
|
||||
citizens.npc.despawn: true
|
||||
citizens.npc.edit.*:
|
||||
children:
|
||||
citizens.npc.edit.equip: true
|
||||
citizens.npc.edit.path: true
|
||||
citizens.npc.edit.text: true
|
||||
citizens.npc.gravity: true
|
||||
citizens.npc.help: true
|
||||
citizens.npc.ignore-cost: true
|
||||
citizens.npc.list: true
|
||||
citizens.npc.lookclose: true
|
||||
citizens.npc.moveto: true
|
||||
citizens.npc.owner: true
|
||||
citizens.npc.path: true
|
||||
citizens.npc.pathfindingrange: true
|
||||
citizens.npc.pose: true
|
||||
citizens.npc.power: true
|
||||
citizens.npc.profession: true
|
||||
citizens.npc.remove: true
|
||||
citizens.npc.remove.all: true
|
||||
citizens.npc.remove.*:
|
||||
children:
|
||||
citizens.npc.remove: true
|
||||
citizens.npc.remove.all: true
|
||||
citizens.npc.rename: true
|
||||
citizens.npc.select: true
|
||||
citizens.npc.size: true
|
||||
citizens.npc.skeletontype: true
|
||||
citizens.npc.spawn: true
|
||||
citizens.npc.speed: true
|
||||
citizens.npc.talk: true
|
||||
citizens.npc.text: true
|
||||
citizens.npc.tp: true
|
||||
citizens.npc.tphere: true
|
||||
citizens.npc.trait.*:
|
||||
children:
|
||||
citizens.npc.trait: true
|
||||
citizens.npc.trait-configure: true
|
||||
citizens.npc.trait-configure.*: true
|
||||
citizens.npc.tp: true
|
||||
citizens.npc.tphere: true
|
||||
citizens.npc.vulnerable: true
|
Loading…
Reference in New Issue
Block a user