mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-25 20:25:19 +01:00
Pass wander pause through to wander goal, fix SleepTrait
This commit is contained in:
parent
ce1f306b08
commit
102630a5e0
@ -25,12 +25,16 @@ public class SleepTrait extends Trait {
|
||||
public void run() {
|
||||
if (!npc.isSpawned())
|
||||
return;
|
||||
if (sleeping && at != null) {
|
||||
return;
|
||||
} else if (sleeping && at == null) {
|
||||
stopSleeping();
|
||||
if (sleeping) {
|
||||
if (at == null) {
|
||||
wakeup();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (at == null)
|
||||
return;
|
||||
|
||||
npc.teleport(at, TeleportCause.PLUGIN);
|
||||
if (npc.getEntity() instanceof Player) {
|
||||
Player player = (Player) npc.getEntity();
|
||||
if (at.getBlock().getBlockData() instanceof Bed || at.getBlock().getState() instanceof Bed) {
|
||||
@ -46,15 +50,15 @@ public class SleepTrait extends Trait {
|
||||
|
||||
public void setSleeping(Location at) {
|
||||
this.at = at != null ? at.clone() : null;
|
||||
stopSleeping();
|
||||
npc.teleport(at, TeleportCause.PLUGIN);
|
||||
wakeup();
|
||||
}
|
||||
|
||||
private void stopSleeping() {
|
||||
private void wakeup() {
|
||||
if (npc.getEntity() instanceof Player) {
|
||||
NMS.sleep((Player) npc.getEntity(), false);
|
||||
} else if (npc.getEntity() instanceof Villager) {
|
||||
((Villager) npc.getEntity()).wakeup();
|
||||
}
|
||||
sleeping = false;
|
||||
}
|
||||
}
|
||||
|
@ -345,6 +345,13 @@ public class WanderWaypointProvider
|
||||
@Override
|
||||
public void setPaused(boolean paused) {
|
||||
this.paused = paused;
|
||||
if (currentGoal != null) {
|
||||
if (paused) {
|
||||
currentGoal.pause();
|
||||
} else {
|
||||
currentGoal.unpause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setXYRange(int xrange, int yrange) {
|
||||
|
Loading…
Reference in New Issue
Block a user