Skip to content

Commit

Permalink
1.8.8 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 10, 2022
1 parent 4212921 commit 57d27f3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions main/src/main/java/net/citizensnpcs/trait/SleepTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,20 @@ public void run() {

if (npc.getEntity() instanceof Player) {
Player player = (Player) npc.getEntity();
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|| at.getBlock().getState() instanceof Bed) {
player.sleep(at, true);
} else {
if (!SUPPORT_BLOCKSTATE) {
NMS.sleep(player, true);
} else {
try {
if ((SUPPORT_BLOCKDATA && at.getBlock().getBlockData() instanceof Bed)
|| at.getBlock().getState() instanceof Bed) {
player.sleep(at, true);
} else {
NMS.sleep(player, true);
}
} catch (Throwable t) {
SUPPORT_BLOCKSTATE = false;
NMS.sleep(player, true);
}
}
sleeping = true;
} else if (npc.getEntity() instanceof Villager) {
Expand All @@ -75,4 +84,5 @@ private void wakeup() {
}

private static Boolean SUPPORT_BLOCKDATA = null;
private static boolean SUPPORT_BLOCKSTATE = true;
}

0 comments on commit 57d27f3

Please sign in to comment.