Skip to content

Commit 5b55708

Browse files
committed
Update z_sleep for 1.14.4
1 parent 49091b8 commit 5b55708

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

z_sleep/data/z_sleep/functions/main.mcfunction

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# Reset
2-
scoreboard players set #players_sleeping z_sleep 0
2+
scoreboard players set z_players_sleeping z_sleep 0
33
scoreboard players set #players_slept z_sleep 0
44
scoreboard players set #percent_sleeping z_sleep 0
55
scoreboard players set #percent_slept z_sleep 0
6+
tag @a remove z_sleep_sleeping
67

78
# Count players
9+
execute as @a if data entity @s SleepingY run tag @s add z_sleep_sleeping
810
execute as @a store result score @s z_sleep run data get entity @s SleepTimer
9-
execute as @a[nbt={Sleeping:1b}] run scoreboard players add #players_sleeping z_sleep 1
10-
execute as @a[nbt={Sleeping:1b}] run scoreboard players add #percent_sleeping z_sleep 100
11-
execute as @a[nbt={Sleeping:1b}] if score @s z_sleep matches 100.. run scoreboard players add #players_slept z_sleep 1
12-
execute as @a[nbt={Sleeping:1b}] if score @s z_sleep matches 100.. run scoreboard players add #percent_slept z_sleep 100
11+
execute as @a[tag=z_sleep_sleeping] run scoreboard players add z_players_sleeping z_sleep 1
12+
execute as @a[tag=z_sleep_sleeping] run scoreboard players add #percent_sleeping z_sleep 100
13+
execute as @a[tag=z_sleep_sleeping] if score @s z_sleep matches 100.. run scoreboard players add #players_slept z_sleep 1
14+
execute as @a[tag=z_sleep_sleeping] if score @s z_sleep matches 100.. run scoreboard players add #percent_slept z_sleep 100
1315

1416
# Calculate percent sleeping/slept
1517
scoreboard players operation #percent_sleeping z_sleep /= #players_overworld z_sleep
1618
scoreboard players operation #percent_slept z_sleep /= #players_overworld z_sleep
1719

1820
# Send chat message every time someone starts sleeping
19-
execute if entity @a[nbt={Sleeping:1b,SleepTimer:0s}] run function z_sleep:notify_sleep
21+
execute if entity @a[tag=z_sleep_sleeping,nbt={SleepTimer:0s}] run function z_sleep:notify_sleep
2022

2123
# Wake players if someone clicked the trigger
2224
execute as @a if score @s z_sleep_wake matches 1 run function z_sleep:wake_players
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
execute if score #threshold_type z_sleep matches 0 run tellraw @a ["",{"score":{"name":"#players_sleeping","objective":"z_sleep"},"color":"gold"}," players (",{"selector":"@a[nbt={Sleeping:1b}]","color":"aqua"},") are now sleeping.\n",{"score":{"name":"#threshold_count","objective":"z_sleep"},"color":"gold"},{"text":" are required to pass the night."}]
1+
execute if score #threshold_type z_sleep matches 0 run tellraw @a ["",{"score":{"name":"z_players_sleeping","objective":"z_sleep"},"color":"gold"}," players (",{"selector":"@a[tag=z_sleep_sleeping]","color":"aqua"},") are now sleeping.\n",{"score":{"name":"#threshold_count","objective":"z_sleep"},"color":"gold"},{"text":" are required to pass the night."}]
22

3-
execute if score #threshold_type z_sleep matches 1 run tellraw @a ["",{"score":{"name":"#percent_sleeping","objective":"z_sleep"},"color":"gold"},{"text":"%","color":"gold"}," of overworld players (",{"selector":"@a[nbt={Sleeping:1b}]","color":"aqua"},") are now sleeping.\n",{"score":{"name":"#threshold_percent","objective":"z_sleep"},"color":"gold"},{"text":"%","color":"gold"},{"text":" are required to pass the night."}]
3+
execute if score #threshold_type z_sleep matches 1 run tellraw @a ["",{"score":{"name":"#percent_sleeping","objective":"z_sleep"},"color":"gold"},{"text":"%","color":"gold"}," of overworld players (",{"selector":"@a[tag=z_sleep_sleeping]","color":"aqua"},") are now sleeping.\n",{"score":{"name":"#threshold_percent","objective":"z_sleep"},"color":"gold"},{"text":"%","color":"gold"},{"text":" are required to pass the night."}]
44

55
scoreboard players enable @a z_sleep_wake
66
tellraw @a ["Click ",{"text":"[here]","color":"blue","clickEvent":{"action":"run_command","value":"/trigger z_sleep_wake set 1"}}," to wake them from sleep."]
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
execute at @a[nbt={Sleeping:1b}] run summon minecraft:snowball ~ ~0.6 ~ {Motion:[0.0,-1.0,0.0]}
1+
execute as @a[tag=z_sleep_sleeping] run tp @s @s
22
tellraw @a ["",{"selector":"@s","color":"aqua"},{"text":" has stopped everyone from sleeping."}]
33
scoreboard players reset @a z_sleep_wake

0 commit comments

Comments
 (0)