Fix load bug in body yaw
This commit is contained in:
parent
521c1d3fda
commit
8336fe1b7c
|
@ -157,11 +157,11 @@ public class CitizensNPC extends AbstractNPC {
|
|||
// Spawn the NPC
|
||||
CurrentLocation spawnLocation = getTrait(CurrentLocation.class);
|
||||
if (getTrait(Spawned.class).shouldSpawn() && spawnLocation.getLocation() != null) {
|
||||
spawn(spawnLocation.getLocation(), SpawnReason.RESPAWN);
|
||||
NMS.setBodyYaw(getEntity(), spawnLocation.getBodyYaw());
|
||||
}
|
||||
if (getTrait(Spawned.class).shouldSpawn() && spawnLocation.getLocation() == null) {
|
||||
Messaging.debug("Tried to spawn", getId(), "on load but world was null");
|
||||
if (spawnLocation.getLocation() != null) {
|
||||
spawn(spawnLocation.getLocation(), SpawnReason.RESPAWN);
|
||||
} else {
|
||||
Messaging.debug("Tried to spawn", getId(), "on load but world was null");
|
||||
}
|
||||
}
|
||||
|
||||
navigator.load(root.getRelative("navigator"));
|
||||
|
|
|
@ -106,7 +106,7 @@ public class CommandTrait extends Trait {
|
|||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PermissionAttachment attachment = new PermissionAttachment(CitizensAPI.getPlugin(), player);
|
||||
PermissionAttachment attachment = player.addAttachment(CitizensAPI.getPlugin());
|
||||
if (temporaryPermissions.size() > 0) {
|
||||
for (String permission : temporaryPermissions) {
|
||||
attachment.setPermission(permission, true);
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.citizensnpcs.util.NMS;
|
|||
@TraitName("location")
|
||||
public class CurrentLocation extends Trait {
|
||||
@Persist
|
||||
private float bodyYaw;
|
||||
private float bodyYaw = Float.NaN;
|
||||
@Persist(value = "", required = true)
|
||||
private Location location = new Location(null, 0, 0, 0);
|
||||
|
||||
|
@ -35,6 +35,13 @@ public class CurrentLocation extends Trait {
|
|||
key.removeKey("headYaw");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSpawn() {
|
||||
if (!Float.isNaN(bodyYaw)) {
|
||||
NMS.setBodyYaw(npc.getEntity(), bodyYaw);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!npc.isSpawned())
|
||||
|
|
Loading…
Reference in New Issue