Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:ender_pearl"},
"title": {"text": "RTWrapper: changed dimension hook", "color": "aqua"},
"description": "Internal - fires the registered changed_dimension hook action for tagged players",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:changed_dimension",
"conditions": {
"player": {
"type": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"minecraft:nbt": "{Tags:[\"rtw.target\"]}"
}
}
}
}
},
"rewards": {
"function": "rtwrapper:core/hooks/changed_dimension"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:potion"},
"title": {"text": "RTWrapper: consume item hook", "color": "aqua"},
"description": "Internal - fires rtwrapper:api/run/context when a tagged item is consumed",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:consume_item",
"conditions": {
"item": {
"components": {
"minecraft:custom_data": {
"rtwrapper": {
"hook": "consume_item"
}
}
}
}
}
}
},
"rewards": {
"function": "rtwrapper:core/hooks/consume_item"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:obsidian"},
"title": {"text": "RTWrapper: enter block hook", "color": "aqua"},
"description": "Internal - fires the registered enter_block hook action when a player's hitbox enters the configured block",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:enter_block",
"conditions": {
"block": "minecraft:nether_portal"
}
}
},
"rewards": {
"function": "rtwrapper:core/hooks/enter_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:skeleton_skull"},
"title": {"text": "RTWrapper: entity killed player hook", "color": "aqua"},
"description": "Internal - fires the registered entity_killed_player hook action when a player is killed by a living entity",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:entity_killed_player"
}
},
"rewards": {
"function": "rtwrapper:core/hooks/entity_killed_player"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:grass_block"},
"title": {"text": "RTWrapper: placed block hook", "color": "aqua"},
"description": "Internal - fires the registered placed_block hook action when a player places a block",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:placed_block"
}
},
"rewards": {
"function": "rtwrapper:core/hooks/placed_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"parent": "rtwrapper:hooks/root",
"display": {
"icon": {"id": "minecraft:iron_sword"},
"title": {"text": "RTWrapper: player killed entity hook", "color": "aqua"},
"description": "Internal - fires the registered player_killed_entity hook action when a player kills a tagged entity",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"requirement": {
"trigger": "minecraft:player_killed_entity",
"conditions": {
"entity": {
"type": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"minecraft:nbt": "{Tags:[\"rtw.target\"]}"
}
}
}
}
},
"rewards": {
"function": "rtwrapper:core/hooks/player_killed_entity"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"display": {
"icon": {"id": "minecraft:command_block"},
"title": {"text": "RTWrapper Hooks", "color": "dark_gray"},
"description": "Internal - parent for RTWrapper's advancement-based event hooks",
"background": "minecraft:block/gray_concrete",
"frame": "task",
"show_toast": false,
"announce_to_chat": false,
"hidden": true
},
"criteria": {
"trigger": {
"trigger": "minecraft:tick"
}
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Multi-action API entry (v0.1.2, basic form — see note at bottom).
# Multi-action API entry (v1.0.0, basic form — see note at bottom).
#
# Usage from a dependent pack:
# data modify storage rtwrapper:api batch set value [{cmd:"tp",params:{...}},{cmd:"say",params:{...}}]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Register an action to run when a named RTWrapper advancement hook fires
# (e.g. "consume_item", "changed_dimension" - see data/rtwrapper/advancement/hooks/).
# Required storage keys: hook.name (string, must match a hook's registered name),
# hook.action (compound, same shape as rtwrapper:api request, e.g. {cmd:"say",...}).
# No-ops (does not duplicate) if this hook name is already registered - unregister first
# to replace it.
execute unless data storage rtwrapper:api hook.name run return fail
execute unless data storage rtwrapper:api hook.action run return fail
execute unless data storage rtwrapper:hooks registry run data modify storage rtwrapper:hooks registry set value []

function rtwrapper:core/hooks/register_check with storage rtwrapper:api hook
data remove storage rtwrapper:api hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Unregister a hook action previously set with rtwrapper:api/hooks/register.
# Required storage keys: hook.name (string). Safe no-op if not registered.
execute unless data storage rtwrapper:api hook.name run return fail
function rtwrapper:core/hooks/unregister_apply with storage rtwrapper:api hook
data remove storage rtwrapper:api hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Dynamic menu API: show an inline dialog definition without registering it under a
# resource location first. Put the full dialog SNBT/JSON (a "minecraft:notice",
# "minecraft:dialog_list", etc. compound - see the /dialog command's inline-dialog form)
# in storage rtwrapper:api menu.dialog, and the target selector in rtwrapper:api menu.targets
# (defaults to @s if omitted).
#
# Required storage keys: menu.dialog (compound). Optional: menu.targets (defaults to @s).
execute unless data storage rtwrapper:api menu.targets run data modify storage rtwrapper:api menu.targets set value "@s"

data modify storage rtwrapper:runtime menu_ctx.targets set from storage rtwrapper:api menu.targets
data modify storage rtwrapper:runtime menu_ctx.dialog set from storage rtwrapper:api menu.dialog

function rtwrapper:core/menu/show_inline with storage rtwrapper:runtime menu_ctx

data remove storage rtwrapper:runtime menu_ctx
data remove storage rtwrapper:api menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Disable a registered RTWrapper trigger. The objective/registry entry stays, but
# core/trigger/poll will not fire it or reset its score while disabled.
# Required storage keys: trigger.objective (string).
execute unless data storage rtwrapper:api trigger.objective run return fail
function rtwrapper:core/trigger/set_enabled_false with storage rtwrapper:api trigger
data remove storage rtwrapper:api trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enable a registered RTWrapper trigger (it will fire again when set). No-op if unregistered.
# Required storage keys: trigger.objective (string).
execute unless data storage rtwrapper:api trigger.objective run return fail
function rtwrapper:core/trigger/set_enabled_true with storage rtwrapper:api trigger
data remove storage rtwrapper:api trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Modify an existing RTWrapper trigger's action and/or reset_mode.
# Required storage keys: trigger.objective (string, must already be registered).
# Optional: trigger.action (compound, replaces the fire action if present),
# trigger.reset_mode ("value"|"keep", replaces the reset mode if present).
# Fails (no-op) if the objective is not registered.
execute unless data storage rtwrapper:api trigger.objective run return fail
function rtwrapper:core/trigger/modify_check with storage rtwrapper:api trigger
data remove storage rtwrapper:api trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Register a new custom /trigger command backed by RTWrapper.
# Required storage keys: trigger.objective (string, the trigger's scoreboard name),
# trigger.action (RTWrapper request compound to run when the trigger fires - the same
# shape as rtwrapper:api request, e.g. {cmd:"say", params:{message:"hi"}} or {type:"..."}).
# Optional: trigger.reset_mode ("value"|"keep", default "value" - whether the trigger score
# is reset to 0 after firing like vanilla `trigger <obj> set 0`, or left as-is for "keep").
#
# No-ops (does not duplicate) if the objective is already registered - use
# rtwrapper:api/trigger/modify to change an existing registration.

execute unless data storage rtwrapper:api trigger.objective run return fail
execute unless data storage rtwrapper:api trigger.action run return fail
execute unless data storage rtwrapper:triggers registry run data modify storage rtwrapper:triggers registry set value []
execute unless data storage rtwrapper:api trigger.reset_mode run data modify storage rtwrapper:api trigger.reset_mode set value "value"

function rtwrapper:core/trigger/register_check with storage rtwrapper:api trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Unregister a previously-registered RTWrapper trigger.
# Required storage keys: trigger.objective (string).
# Removes the registry entry and the scoreboard objective. Safe no-op if not registered.
execute unless data storage rtwrapper:api trigger.objective run return fail
function rtwrapper:core/trigger/unregister_apply with storage rtwrapper:api trigger
data remove storage rtwrapper:api trigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fired by data/rtwrapper/advancement/hooks/changed_dimension.json when a player tagged
# "rtw.target" changes dimension.
# Looks up the registered action for hook "changed_dimension" (see
# rtwrapper:api/hooks/register) and runs it. No-op if nothing is registered.
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time per player.
execute if data storage rtwrapper:hooks registry[{name:"changed_dimension"}] run function rtwrapper:core/hooks/dispatch {name:"changed_dimension"}
advancement revoke @s only rtwrapper:hooks/changed_dimension
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fired by data/rtwrapper/advancement/hooks/consume_item.json when a player consumes an
# item tagged {custom_data:{rtwrapper:{hook:"consume_item"}}}.
# Looks up the registered action for hook "consume_item" (see rtwrapper:api/hooks/register)
# and runs it. No-op if nothing is registered for this hook name.
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time per player.
execute if data storage rtwrapper:hooks registry[{name:"consume_item"}] run function rtwrapper:core/hooks/dispatch {name:"consume_item"}
advancement revoke @s only rtwrapper:hooks/consume_item
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Macro: called with an inline compound {name:"<hook name>"}.
# Looks up the registered action for this hook name and runs it via rtwrapper:api/run.
$data modify storage rtwrapper:runtime hook_action set from storage rtwrapper:hooks registry[{name:"$(name)"}].action
data modify storage rtwrapper:api request set from storage rtwrapper:runtime hook_action
data remove storage rtwrapper:runtime hook_action
function rtwrapper:api/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Fired by data/rtwrapper/advancement/hooks/enter_block.json when a player's hitbox
# enters the configured block (default: minecraft:nether_portal - edit the "block" field
# in that file to target a different block).
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time a player enters
# the block, not every time.
execute if data storage rtwrapper:hooks registry[{name:"enter_block"}] run function rtwrapper:core/hooks/dispatch {name:"enter_block"}
advancement revoke @s only rtwrapper:hooks/enter_block
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Fired by data/rtwrapper/advancement/hooks/entity_killed_player.json when a player is
# killed by any living entity (edit the "entity" conditions in that file to filter by
# killer type, e.g. only skeletons).
# Note: the executing player here is the one who died - the advancement/reward system
# still runs as that player even though they are dead when it fires.
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time per player.
execute if data storage rtwrapper:hooks registry[{name:"entity_killed_player"}] run function rtwrapper:core/hooks/dispatch {name:"entity_killed_player"}
advancement revoke @s only rtwrapper:hooks/entity_killed_player
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Executor context (@s) is one online player. Compares current xp_level score to the
# stored previous-tick value; fires the level_up hook if it increased.
# A player with no rtw.xp_level_prev entry yet (first tick seen) is seeded from their
# current level so it does not look like a level-up on the very first poll.
# A fully-bounded range (min..max int) is true only when the score entry exists; a missing
# entry never matches any range, so this reliably detects "never seeded" vs "seeded".
# (Note: bare `..` with no bounds is not valid range syntax.)
execute unless score @s rtw.xp_level_prev matches -2147483648..2147483647 run scoreboard players operation @s rtw.xp_level_prev = @s rtw.xp_level

execute if score @s rtw.xp_level > @s rtw.xp_level_prev run function rtwrapper:core/hooks/level_up_fire
scoreboard players operation @s rtw.xp_level_prev = @s rtw.xp_level
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Executor context (@s) is the player whose xp_level just increased.
execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] level_up fired","color":"gray"}]
function rtwrapper:core/hooks/dispatch {name:"level_up"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Polls every online player's xp_level score once per tick and fires the registered
# "level_up" hook (see rtwrapper:api/hooks/register) for anyone whose level increased
# since the last tick. Unlike the advancement-based hooks, there's no vanilla advancement
# trigger for leveling up, so this is tick-polled instead.
# Uses two objectives: rtw.xp_level (criteria "xp_level", auto-tracks the real level) and
# rtw.xp_level_prev (dummy, stores each player's level as of the previous tick).
execute if data storage rtwrapper:hooks registry[{name:"level_up"}] as @a at @s run function rtwrapper:core/hooks/level_up_check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Fired by data/rtwrapper/advancement/hooks/placed_block.json when a player places any
# block (edit the "conditions" in that file to filter by block type, e.g. only stone).
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time per player.
execute if data storage rtwrapper:hooks registry[{name:"placed_block"}] run function rtwrapper:core/hooks/dispatch {name:"placed_block"}
advancement revoke @s only rtwrapper:hooks/placed_block
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Fired by data/rtwrapper/advancement/hooks/player_killed_entity.json when a player kills
# an entity tagged "rtw.target" (edit the "entity" predicate in that file to target
# something else, e.g. a specific mob type).
# Advancements only grant once per player, so this revokes its own advancement right
# after firing - otherwise the hook would only ever fire the first time per player.
execute if data storage rtwrapper:hooks registry[{name:"player_killed_entity"}] run function rtwrapper:core/hooks/dispatch {name:"player_killed_entity"}
advancement revoke @s only rtwrapper:hooks/player_killed_entity
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Macro: called with storage rtwrapper:api hook (fields: name, action).
# Fails (no-op) if this hook name is already registered.
$execute if data storage rtwrapper:hooks registry[{name:"$(name)"}] run return fail
$data modify storage rtwrapper:hooks registry append value {name:"$(name)",action:$(action)}
execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] hook registered","color":"gray"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Macro: called with storage rtwrapper:api hook (field: name).
$data remove storage rtwrapper:hooks registry[{name:"$(name)"}]
execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] hook unregistered","color":"gray"}]
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ execute if data storage rtwrapper:meta {loaded:1b} run return 0

scoreboard objectives add rtw.config dummy
scoreboard objectives add rtw.status dummy
scoreboard objectives add rtw.xp_level xp_level
scoreboard objectives add rtw.xp_level_prev dummy

function rtwrapper:core/meta_init
execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] meta gate checked (status/version left untouched if already present)","color":"gray"}]
Expand All @@ -19,12 +21,14 @@ execute unless score #processed rtw.status matches 0.. run scoreboard players se
execute unless score #errors rtw.status matches 0.. run scoreboard players set #errors rtw.status 0

# Bind storage roots if missing. Other packs may write rtwrapper:api request/args.
execute unless data storage rtwrapper:runtime config run data modify storage rtwrapper:runtime config set value {version:"v0.1.2",debug:0b,silent:1b,auto_tick:0b}
execute unless data storage rtwrapper:runtime config run data modify storage rtwrapper:runtime config set value {version:"v1.0.0",debug:0b,silent:1b,auto_tick:0b}
execute unless data storage rtwrapper:runtime queue run data modify storage rtwrapper:runtime queue set value []
execute unless data storage rtwrapper:runtime current run data modify storage rtwrapper:runtime current set value {}
execute unless data storage rtwrapper:api request run data modify storage rtwrapper:api request set value {}
execute unless data storage rtwrapper:api params run data modify storage rtwrapper:api params set value {}
execute unless data storage rtwrapper:api batch run data modify storage rtwrapper:api batch set value []
execute unless data storage rtwrapper:triggers registry run data modify storage rtwrapper:triggers registry set value []
execute unless data storage rtwrapper:hooks registry run data modify storage rtwrapper:hooks registry set value []

data modify storage rtwrapper:meta loaded set value 1b
execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] load complete","color":"gold"}]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sends an inline dialog (no resource-location registration needed) via macro.
# Expects storage keys: targets (string selector), dialog (compound dialog definition,
# e.g. {type:"minecraft:notice", title:{...}, body:[...]}).
$execute if score #debug rtw.config matches 1.. run tellraw @a[tag=rtwrapper.debug] [{"text":"[RTWrapper] menu/show_inline targets=$(targets)","color":"gray"}]
$dialog show $(targets) $(dialog)
Original file line number Diff line number Diff line change
@@ -1 +1 @@
execute unless data storage rtwrapper:meta loaded run data merge storage rtwrapper:meta {version:"v0.1.2",id:"RTWrapper",type:"datapack",datapack_type:"library",status:"enabled"}
execute unless data storage rtwrapper:meta loaded run data merge storage rtwrapper:meta {version:"v1.0.0",id:"RTWrapper",type:"datapack",datapack_type:"library",status:"enabled"}
Loading
Loading