diff --git a/smithed_libraries/packs/actionbar/beet.yaml b/smithed_libraries/packs/actionbar/beet.yaml index 579b0ed..ad1dd2d 100644 --- a/smithed_libraries/packs/actionbar/beet.yaml +++ b/smithed_libraries/packs/actionbar/beet.yaml @@ -9,5 +9,7 @@ data_pack: name: Smithed Actionbar load: . +output: dist + require: - bolt diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/bed/clicked_bed.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/bed/clicked_bed.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/clicked_bed.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/bed/slept_in_bed.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/bed/slept_in_bed.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/bed/slept_in_bed.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/container/clicked_lockable_block.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/advancements/impl/vanilla/container/clicked_lockable_block.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/advancement/impl/vanilla/container/clicked_lockable_block.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/display.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/display.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/display.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/display.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/message.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/message.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/message.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/message.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/reset.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/reset.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/reset.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/reset.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/technical/load.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/technical/load.mcfunction similarity index 90% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/technical/load.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/technical/load.mcfunction index 3052fec..ab53b5b 100644 --- a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/technical/load.mcfunction +++ b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/technical/load.mcfunction @@ -16,3 +16,6 @@ scoreboard players set $min.freeze smithed.actionbar.const 0 scoreboard players set #100 smithed.actionbar.const 100 schedule function smithed.actionbar:impl/technical/tick 1t + +function smithed.title:impl/technical/load +schedule function smithed.title:impl/technical/tick 1t diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/technical/tick.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/technical/tick.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/technical/tick.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/technical/tick.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/check_sleep_status.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/check_sleep_status.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/check_sleep_status.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/check_sleep_status.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/clicked_bed.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/clicked_bed.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/clicked_bed.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/clicked_bed.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/get_server_status.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/get_server_status.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/get_server_status.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/get_server_status.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/send_sleep_status.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/send_sleep_status.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/send_sleep_status.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/send_sleep_status.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/show_sleep_percentage.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/show_sleep_percentage.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/show_sleep_percentage.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/show_sleep_percentage.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/track_leave_bed.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/track_leave_bed.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/bed/track_leave_bed.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/bed/track_leave_bed.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/east.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/east.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/east.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/east.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/north.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/north.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/north.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/north.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/south.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/south.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/south.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/south.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/west.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/west.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_double_chest_lock/west.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_double_chest_lock/west.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_lock.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_lock.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/check_lock.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/check_lock.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/clicked_lockable_block.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/clicked_lockable_block.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/clicked_lockable_block.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/clicked_lockable_block.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/raycast.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/raycast.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/raycast.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/raycast.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/send_message.mcfunction b/smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/send_message.mcfunction similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/functions/impl/vanilla/container/send_message.mcfunction rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/function/impl/vanilla/container/send_message.mcfunction diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicates/impl/is_day.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/predicates/impl/is_day.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/predicate/impl/is_day.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/blocks/impl/chests.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/block/impl/chests.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/blocks/impl/chests.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/block/impl/chests.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/blocks/impl/lockable.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/block/impl/lockable.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/blocks/impl/lockable.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/block/impl/lockable.json diff --git a/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/functions/event/player/on_click_locked_container.json b/smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/function/event/player/on_click_locked_container.json similarity index 100% rename from smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/functions/event/player/on_click_locked_container.json rename to smithed_libraries/packs/actionbar/data/smithed.actionbar/tags/function/event/player/on_click_locked_container.json diff --git a/smithed_libraries/packs/title/README.md b/smithed_libraries/packs/title/README.md new file mode 100644 index 0000000..b6bdd43 --- /dev/null +++ b/smithed_libraries/packs/title/README.md @@ -0,0 +1,10 @@ +# Title +This library helps multiple data packs manage title & subtitle by aggregating usage by priority. This allows persistent messages to display without interrupting more urgent notification type messages. + +## Usage +For usage information, see the [documentation](https://wiki.smithed.dev/libraries/smithed-core) +## Downloading +You can download this library from [the website](https://smithed.dev/packs/smithed/title) +or +You can build it from source using [beet](https://github.com/mcbeet/beet) + diff --git a/smithed_libraries/packs/title/beet.yaml b/smithed_libraries/packs/title/beet.yaml new file mode 100644 index 0000000..8e73666 --- /dev/null +++ b/smithed_libraries/packs/title/beet.yaml @@ -0,0 +1,15 @@ +extend: "@smithed_libraries/common.yaml" + +id: smithed.title +name: Smithed Title +version: "0.0.1" +description: Native Title Library for Smithed + +data_pack: + name: Smithed Title + load: . + +output: dist + +require: + - bolt diff --git a/smithed_libraries/packs/title/data/smithed.title/function/impl/display.mcfunction b/smithed_libraries/packs/title/data/smithed.title/function/impl/display.mcfunction new file mode 100644 index 0000000..e7c547a --- /dev/null +++ b/smithed_libraries/packs/title/data/smithed.title/function/impl/display.mcfunction @@ -0,0 +1,24 @@ +# display the message to the player +# @s = player that needs a new title shown +# location undefined; based on how the user calls the function +# run from message + +# yes, if you define raw and json, you'll get 2 messages +# i left this "bug" in so that folks catch this in testing + +execute if data storage smithed.title:input message.subtitle_raw run title @s subtitle {"storage": "smithed.title:input", "nbt": "message.subtitle_raw"} +execute if data storage smithed.title:input message.subtitle_json run title @s subtitle {"storage": "smithed.title:input", "nbt": "message.subtitle_json", "interpret": true} + +execute if data storage smithed.title:input message.title_raw run title @s title {"storage": "smithed.title:input", "nbt": "message.title_raw"} +execute if data storage smithed.title:input message.title_json run title @s title {"storage": "smithed.title:input", "nbt": "message.title_json", "interpret": true} + + +# copy freeze w/ bounds checking +scoreboard players operation @s smithed.title.freeze = $freeze smithed.title.temp +scoreboard players operation @s smithed.title.freeze > $min.freeze smithed.title.const +scoreboard players operation @s smithed.title.freeze < $max.freeze smithed.title.const + +# unless freeze is explicitly 0, copy priority +# allows folks to let their messages disappear +# prolly won't interact nicely w/ persistent messages +execute unless score @s smithed.title.freeze matches 0 run scoreboard players operation @s smithed.title.priority = $priority smithed.title.temp diff --git a/smithed_libraries/packs/title/data/smithed.title/function/impl/message.mcfunction b/smithed_libraries/packs/title/data/smithed.title/function/impl/message.mcfunction new file mode 100644 index 0000000..b0a71d4 --- /dev/null +++ b/smithed_libraries/packs/title/data/smithed.title/function/impl/message.mcfunction @@ -0,0 +1,40 @@ +# @public + +# get the message input +# @s = player that needs a new title shown +# location undefined; based on how the user calls the function +# run from #smithed.title:message + +# force-give player a priority score +scoreboard players add @s smithed.title.priority 0 + +# if there is a message, but they forgot the priority, it should be the default +execute if data storage smithed.title:input message run scoreboard players set $priority smithed.title.temp 99 + +# convert string priority into number +# if we introduce new priorities in future versions +# we can renumber our ints w/o issues +execute if data storage smithed.title:input message{priority:'override'} run scoreboard players set $priority smithed.title.temp 1 +execute if data storage smithed.title:input message{priority:'notification'} run scoreboard players set $priority smithed.title.temp 2 +execute if data storage smithed.title:input message{priority:'conditional'} run scoreboard players set $priority smithed.title.temp 3 +execute if data storage smithed.title:input message{priority:'persistent'} run scoreboard players set $priority smithed.title.temp 4 +execute unless data storage smithed.title:input message.priority run scoreboard players set $priority smithed.title.temp 99 + +# grab freeze +# load default freeze if not defined +execute store result score $freeze smithed.title.temp run data get storage smithed.title:input message.freeze +execute + unless data storage smithed.title:input message.freeze + run scoreboard players operation $freeze smithed.title.temp = $default.freeze smithed.title.const + +# to determine if we display +# if priority is the same or lower AND current priority is not "override" +# OR if player has no shown title +# then display the message +execute + unless score @s smithed.title.priority matches 1 # override notifications should not be "overriden" + if score $priority smithed.title.temp <= @s smithed.title.priority + run function smithed.title:impl/display + +execute if score @s smithed.title.priority matches 0 run function smithed.title:impl/display + diff --git a/smithed_libraries/packs/title/data/smithed.title/function/impl/reset.mcfunction b/smithed_libraries/packs/title/data/smithed.title/function/impl/reset.mcfunction new file mode 100644 index 0000000..924629a --- /dev/null +++ b/smithed_libraries/packs/title/data/smithed.title/function/impl/reset.mcfunction @@ -0,0 +1,10 @@ +# @public + +# resets player's title scores so they can see any new title +# @s = player that has a freeze score of 1 +# located at @s +# run from technical/tick + + +scoreboard players reset @s smithed.title.freeze +scoreboard players set @s smithed.title.priority 0 diff --git a/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/load.mcfunction b/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/load.mcfunction new file mode 100644 index 0000000..c1a75e8 --- /dev/null +++ b/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/load.mcfunction @@ -0,0 +1,12 @@ +scoreboard objectives add smithed.title.temp dummy +scoreboard objectives add smithed.title.const dummy +scoreboard objectives add smithed.title.priority dummy +scoreboard objectives add smithed.title.freeze dummy + + +scoreboard players set $default.freeze smithed.title.const 20 +scoreboard players set $max.freeze smithed.title.const 50 +scoreboard players set $min.freeze smithed.title.const 0 +scoreboard players set #100 smithed.title.const 100 + +schedule function smithed.title:impl/technical/tick 1t diff --git a/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/tick.mcfunction b/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/tick.mcfunction new file mode 100644 index 0000000..7bc36fc --- /dev/null +++ b/smithed_libraries/packs/title/data/smithed.title/function/impl/technical/tick.mcfunction @@ -0,0 +1,11 @@ +# loop every tick +schedule function smithed.title:impl/technical/tick 1t replace + +# reset scores when at 1 +execute as @a[scores={smithed.title.freeze=1}] run function smithed.title:impl/reset + +# decrement everyone's score +scoreboard players remove @a[scores={smithed.title.freeze=1..}] smithed.title.freeze 1 + +# reset sneak_time score +scoreboard players reset @a smithed.title.sneaking diff --git a/smithed_libraries/packs/title/pack.png b/smithed_libraries/packs/title/pack.png new file mode 100644 index 0000000..02154cf Binary files /dev/null and b/smithed_libraries/packs/title/pack.png differ