Skip to content

Commit

Permalink
Improve alarm
Browse files Browse the repository at this point in the history
v3.1.0
  • Loading branch information
bill96012 committed Jan 19, 2024
1 parent 8e93bd2 commit aa3e577
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/bossbarclock/functions/clock/alarm/main.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
execute as @a[scores={bossbarclock.clockStatus=1}] at @s run function bossbarclock:clock/alarm/player
execute if score #bossbarclock$alarm_method Config matches 3 as @e[type=#minecraft:item_frame,nbt={Item:{id:"minecraft:clock"}},predicate=minecraft:dimension-overworld] at @s run playsound minecraft:entity.player.levelup ambient @a ~ ~ ~ 0.4 0 1.0
6 changes: 6 additions & 0 deletions data/bossbarclock/functions/clock/alarm/player.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tag @s add bossbarclock._tag.ThisEntity

execute if score #bossbarclock$alarm_method Config matches 1.. run playsound minecraft:entity.player.levelup ambient @s ~ ~ ~ 6.0 0 1.0
execute if score #bossbarclock$alarm_method Config matches 2.. if predicate bossbarclock:hold-clock run playsound minecraft:entity.player.levelup ambient @a[tag=!bossbarclock._tag.ThisEntity] ~ ~ ~ 0.4 0 1.0

tag @s remove bossbarclock._tag.ThisEntity
2 changes: 1 addition & 1 deletion data/bossbarclock/functions/clock/main.mcfunction
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
execute as @a at @s run function bossbarclock:clock/player/main

execute if entity @a[scores={bossbarclock.clockStatus=1}] run function bossbarclock:clock/refresh
function bossbarclock:clock/refresh

bossbar set bossbarclock:clock players @a[scores={bossbarclock.clockStatus=1}]
bossbar set bossbarclock:orderless_clock players @a[scores={bossbarclock.clockStatus=2}]
2 changes: 1 addition & 1 deletion data/bossbarclock/functions/clock/refresh.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ execute if score #bossbarclock$12hr_clock Config matches 1 if score #time.hour b
execute if score #bossbarclock$12hr_clock Config matches 1 if score #time.hour bossbarclock matches 12.. run bossbar set bossbarclock:clock name {"translate":"%s - %s","with":[{"translate":"Day %s","with":[{"score":{"name":"#day","objective":"bossbarclock"},"color":"yellow"}],"color":"white"},{"translate":"%s:%s %s","with":[{"storage":"bossbarclock:temp","nbt":"time.12hr_hour","interpret":true,"color":"yellow"},{"storage":"bossbarclock:temp","nbt":"time.minute","interpret":true,"color":"yellow"},{"text":"PM","color":"aqua"}],"color":"white"}],"color":"dark_gray"}

execute unless score #daytime bossbarclock matches 0 unless score #alarm bossbarclock matches 0 run scoreboard players set #alarm bossbarclock 0
execute if score #daytime bossbarclock matches 0 if score #alarm bossbarclock matches 0 store success score #alarm bossbarclock as @a[scores={bossbarclock.clockStatus=1}] at @s run playsound minecraft:entity.player.levelup ambient @s ~ ~ ~ 4.0 0 1.0
execute if score #daytime bossbarclock matches 0 if score #alarm bossbarclock matches 0 if score #bossbarclock$alarm_method Config matches 1.. store success score #alarm bossbarclock run function bossbarclock:clock/alarm/main
10 changes: 10 additions & 0 deletions data/bossbarclock/functions/config.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ scoreboard players set #bossbarclock$display_method Config 1
# 2: Always.
scoreboard players set #bossbarclock$print_clock_toggle Config 1

# Alarm method
# How the clock sounds the alarm when a new day comes.
# integer, default: 3
# values:
# 0: Do not sound the alarm.
# 1: When displaying the clock, and only heard by self.
# 2: Based on 1, alarms by players who hold and display the clock can be heard by others.
# 3: Based on 2, item frames can sound the alarm individually.
scoreboard players set #bossbarclock$alarm_method Config 3

# Enable item frame clock display
# Displays when looking at the clock in the item frame.
# Boolean, default: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ execute unless score #bossbarclock$general.print_version Config matches 0..2 run

execute unless score #bossbarclock$display_method Config matches 0..3 run scoreboard players set #bossbarclock$display_method Config 1
execute unless score #bossbarclock$print_clock_toggle Config matches 0..2 run scoreboard players set #bossbarclock$print_clock_toggle Config 1
execute unless score #bossbarclock$alarm_method Config matches 0..3 run scoreboard players set #bossbarclock$alarm_method Config 3
execute unless score #bossbarclock$item_frame_clock_display Config matches 0..1 run scoreboard players set #bossbarclock$item_frame_clock_display Config 1
execute unless score #bossbarclock$show_orderless Config matches 0..1 run scoreboard players set #bossbarclock$show_orderless Config 1
execute unless score #bossbarclock$real_day_cycle Config matches 0..1 run scoreboard players set #bossbarclock$real_day_cycle Config 1
Expand Down
2 changes: 1 addition & 1 deletion data/bossbarclock/functions/version.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scoreboard players set #bossbarclock$version.x Meta 3
scoreboard players set #bossbarclock$version.y Meta 0
scoreboard players set #bossbarclock$version.y Meta 1
scoreboard players set #bossbarclock$version.z Meta 0
data modify storage meta:bossbarclock version.t set value ''

0 comments on commit aa3e577

Please sign in to comment.