Set player position before and after

This commit is contained in:
fullwall 2013-07-10 00:14:28 +08:00
parent fd51c577ce
commit d0d2f0fc1f
3 changed files with 4 additions and 2 deletions

View File

@ -185,6 +185,7 @@ public class CitizensNPC extends AbstractNPC {
entityController.spawn(at, this);
EntityLiving mcEntity = ((CraftLivingEntity) getBukkitEntity()).getHandle();
boolean couldSpawn = !Util.isLoaded(at) ? false : mcEntity.world.addEntity(mcEntity, SpawnReason.CUSTOM);
mcEntity.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
if (!couldSpawn) {
Messaging.debug("Retrying spawn of", getId(), "later due to chunk being unloaded.");
// we need to wait for a chunk load before trying to spawn

View File

@ -45,8 +45,6 @@ public abstract class MobEntityController extends AbstractEntityController {
}
}
private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = Maps.newHashMap();
private static Constructor<?> getConstructor(Class<?> clazz) {
Constructor<?> constructor = CONSTRUCTOR_CACHE.get(clazz);
if (constructor != null)
@ -57,4 +55,6 @@ public abstract class MobEntityController extends AbstractEntityController {
throw new IllegalStateException("unable to find an entity constructor");
}
}
private static final Map<Class<?>, Constructor<?>> CONSTRUCTOR_CACHE = Maps.newHashMap();
}

View File

@ -21,6 +21,7 @@ public class HumanController extends AbstractEntityController {
World ws = ((CraftWorld) at.getWorld()).getHandle();
final EntityHumanNPC handle = new EntityHumanNPC(ws.getServer().getServer(), ws, Colorizer.parseColors(npc
.getFullName()), new PlayerInteractManager(ws), npc);
handle.setPositionRotation(at.getX(), at.getY(), at.getZ(), at.getYaw(), at.getPitch());
handle.getBukkitEntity().teleport(at);
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
@Override