From 4dffaea19309650d761ab998e803cf4a3980fe80 Mon Sep 17 00:00:00 2001 From: IronCrest <234182831+asn44nb@users.noreply.github.com> Date: Sun, 24 May 2026 13:57:36 +0000 Subject: [PATCH 1/3] 2.3.0 --- .github/README.md | 31 ++++++++++--- data/mce/function/api/batch/run.mcfunction | 5 +- .../function/api/cooldown/check.mcfunction | 14 +++--- data/mce/function/api/cooldown/set.mcfunction | 7 ++- data/mce/function/api/log/show.mcfunction | 11 ++--- data/mce/function/api/log/write.mcfunction | 27 ++++++----- data/mce/function/api/queue/add.mcfunction | 7 +-- data/mce/function/api/run/as.mcfunction | 12 ++--- data/mce/function/api/run/at.mcfunction | 46 ++++++++----------- data/mce/function/api/run/cmd.mcfunction | 7 ++- data/mce/function/api/schedule/run.mcfunction | 22 ++++----- .../function/api/text/batch/clear.mcfunction | 10 ++++ .../function/api/text/batch/run.mcfunction | 32 +++++++++++++ .../function/api/util/broadcast.mcfunction | 11 ++--- data/mce/function/api/util/help.mcfunction | 4 +- data/mce/function/api/util/log.mcfunction | 9 ++-- data/mce/function/api/util/version.mcfunction | 6 +-- data/mce/function/core/load.mcfunction | 6 +-- .../function/core/log/show_iter.mcfunction | 16 +++---- data/mce/function/core/queue/tick.mcfunction | 12 ++--- .../mce/function/core/schedule/add.mcfunction | 11 ++--- .../function/core/schedule/fire.mcfunction | 2 +- .../function/core/schedule/iter.mcfunction | 14 +++--- .../function/core/schedule/tick.mcfunction | 5 +- .../function/core/text/batch/iter.mcfunction | 19 ++++++++ .../core/text/dispatch/actionbar.mcfunction | 10 ++++ .../core/text/dispatch/tellraw.mcfunction | 18 ++++++++ .../core/text/dispatch/title.mcfunction | 20 ++++++++ data/mce/functions/api/batch/run.mcfunction | 5 +- .../functions/api/cooldown/check.mcfunction | 14 +++--- .../mce/functions/api/cooldown/set.mcfunction | 7 ++- data/mce/functions/api/log/show.mcfunction | 11 ++--- data/mce/functions/api/log/write.mcfunction | 27 ++++++----- data/mce/functions/api/queue/add.mcfunction | 7 +-- data/mce/functions/api/run/as.mcfunction | 12 ++--- data/mce/functions/api/run/at.mcfunction | 46 ++++++++----------- data/mce/functions/api/run/cmd.mcfunction | 7 ++- .../mce/functions/api/schedule/run.mcfunction | 22 ++++----- .../functions/api/text/batch/clear.mcfunction | 10 ++++ .../functions/api/text/batch/run.mcfunction | 32 +++++++++++++ pack.mcmeta | 2 +- 41 files changed, 363 insertions(+), 233 deletions(-) create mode 100644 data/mce/function/api/text/batch/clear.mcfunction create mode 100644 data/mce/function/api/text/batch/run.mcfunction create mode 100644 data/mce/function/core/text/batch/iter.mcfunction create mode 100644 data/mce/function/core/text/dispatch/actionbar.mcfunction create mode 100644 data/mce/function/core/text/dispatch/tellraw.mcfunction create mode 100644 data/mce/function/core/text/dispatch/title.mcfunction create mode 100644 data/mce/functions/api/text/batch/clear.mcfunction create mode 100644 data/mce/functions/api/text/batch/run.mcfunction diff --git a/.github/README.md b/.github/README.md index e5d5db1..3ff1d4d 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,6 +1,6 @@ # Marker Command Engine - Macro-free Command Framework -[![Minecraft](https://img.shields.io/badge/Minecraft-1.20--26.1.2-green)](https://minecraft.net) +[![Minecraft](https://img.shields.io/badge/Minecraft-1.19.3%2B-green)](https://minecraft.net) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![LanternLoad](https://img.shields.io/badge/LanternLoad-compatible-blue)](https://github.com/LanternMC/load) @@ -30,7 +30,7 @@ ## Requirements - Minecraft **1.19.3+** (pack_format 10+) -- `mce:api/cooldown/check` requires **1.20.2+** (`return` command) +- All functions compatible with **1.19.3+** (no `return` command used) - LanternLoad is **bundled** — no separate installation needed ## Installation @@ -221,12 +221,20 @@ Only `mce:api/*` functions are part of the public API. All `mce:core/*` function | `mce:api/batch/run` | Add `mce:batch commands` list to queue and run | | `mce:api/batch/clear` | Clear batch staging area without queuing | + +### `mce:api/text/batch/` + +| Function | Description | +|---|---| +| `mce:api/text/batch/run` | Send all entries in `mce:text_batch entries` (tellraw / title / actionbar) | +| `mce:api/text/batch/clear` | Clear `mce:text_batch entries` without sending | + ### `mce:api/cooldown/` | Function | Min Version | Description | |---|---|---| | `mce:api/cooldown/set` | 1.19.3+ | Set cooldown ticks for `@s` from `mce:cd Ticks` | -| `mce:api/cooldown/check` | 1.20.2+ | Returns 1 if `@s` is ready, 0 if on cooldown | +| `mce:api/cooldown/check` | 1.19.3+ | Sets `mce:output Cooldown.ready` (1b=ready, 0b=on cooldown) | | `mce:api/cooldown/clear` | 1.19.3+ | Clear cooldown for `@s` immediately | | `mce:api/cooldown/get` | 1.19.3+ | Write remaining ticks to `mce:output Cooldown.remaining` | @@ -272,8 +280,8 @@ To make your pack load after MCE, add your load function to `#load:post_load` an ```mcfunction # yourpack:load # Require MCE v2.2.0+ (score format: major*1000000 + minor*1000 + patch) -execute unless score mce load.status matches 2002000.. run tellraw @a {"text":"[YourPack] ERROR: MCE v2.2.0+ required!","color":"red"} -execute unless score mce load.status matches 2002000.. run return 0 +execute unless score mce load.status matches 2003000.. run tellraw @a {"text":"[YourPack] ERROR: MCE v2.2.0+ required!","color":"red"} +execute unless score mce load.status matches 2003000.. run tellraw @a {"text":"[YourPack] Aborting: MCE v2.3.0+ required.","color":"red"} # Your init here... ``` @@ -286,7 +294,7 @@ execute unless score mce load.status matches 2002000.. run return 0 - **Command block position**: `0 -64 0` - **Reset delay**: 3 ticks after execution - **Queue interval**: 3 ticks between commands -- **Version score**: `mce load.status` = `2002000` (v2.2.0) +- **Version score**: `mce load.status` = `2003000` (v2.3.0) ## Storage Reference @@ -300,6 +308,7 @@ execute unless score mce load.status matches 2002000.. run return 0 | `mce:cd` | `Ticks` | Int | Cooldown duration in ticks for `cooldown/set` | | `mce:queue` | `commands` | List | Pending queue commands | | `mce:batch` | `commands` | List | Batch staging area | +| `mce:text_batch` | `entries` | List | Text batch entries: `{type, target, msg?, prefix?, title?, subtitle?, preset?}` | | `mce:schedule` | `jobs` | List | Scheduled job list | | `mce:config` | `mce.debug` | Byte | Debug mode flag (`1b` = on) | | `mce:config` | `mce.version` | String | MCE version string | @@ -312,7 +321,7 @@ execute unless score mce load.status matches 2002000.. run return 0 | `mce:log` | `entries` | List | Log entries: `{n, lvl, msg}` (max 64) | | `mce:broadcast` | `Msg` | String | Message text for `util/broadcast` | | `mce:broadcast` | `Prefix` | String | Optional prefix for `util/broadcast` | -| `mce:output` | `Cooldown.ready` | Byte | `1b` if `@s` is ready, `0b` if on cooldown | +| `mce:output` | `Cooldown.ready` | Byte | `1b` if `@s` is ready, `0b` if on cooldown — set by `cooldown/check` | | `mce:output` | `Cooldown.remaining` | Int | Remaining cooldown ticks | | `mce:output` | `Version.string` | String | MCE version string (e.g. `"2.2.0"`) | | `mce:output` | `Version.numeric` | Int | MCE version as int (e.g. `2002000`) | @@ -336,6 +345,14 @@ execute unless score mce load.status matches 2002000.. run return 0 ## Changelog +### v2.3.0 +- **Breaking:** `mce:api/cooldown/check` no longer supports `execute if function` syntax — use `mce:output Cooldown.ready` instead +- Removed all `return` commands — fully compatible with Minecraft 1.19.3+ +- Added `mce:api/text/batch/run` — send multiple tellraw/title/actionbar messages in a single call +- Added `mce:api/text/batch/clear` — clear pending text batch without sending +- Updated Requirements: all APIs now 1.19.3+ (no exceptions) + + ### v2.2.0 - Added `mce:api/log/write` — structured log entries `{n, lvl, msg}`, 64-entry cap - Added `mce:api/log/info` / `log/warn` / `log/error` — level shorthands diff --git a/data/mce/function/api/batch/run.mcfunction b/data/mce/function/api/batch/run.mcfunction index ea04eb5..57a1a29 100644 --- a/data/mce/function/api/batch/run.mcfunction +++ b/data/mce/function/api/batch/run.mcfunction @@ -2,6 +2,8 @@ # MCE version: 1.1.0 (extended) # # Add all commands in mce:batch commands list to queue and run them. +# Compatible with Minecraft 1.19.3+ +# # Usage: # data modify storage mce:batch commands set value ["say 1","say 2","say 3"] # function mce:api/batch/run @@ -9,6 +11,5 @@ execute unless data storage mce:batch commands run data modify storage mce:error Last set value "mce:batch commands is not set or empty" execute unless data storage mce:batch commands run data modify storage mce:error Code set value "ERR_NO_BATCH" execute unless data storage mce:batch commands run function mce:core/error/raise -execute unless data storage mce:batch commands run return 0 -function mce:core/batch/run +execute if data storage mce:batch commands run function mce:core/batch/run diff --git a/data/mce/function/api/cooldown/check.mcfunction b/data/mce/function/api/cooldown/check.mcfunction index 3a36027..432872c 100644 --- a/data/mce/function/api/cooldown/check.mcfunction +++ b/data/mce/function/api/cooldown/check.mcfunction @@ -1,16 +1,16 @@ # PUBLIC API — mce:api/cooldown/check -# MCE version: 1.1.0 +# MCE version: 1.1.0 (extended) # # Checks if the executor (@s) is NOT on cooldown. -# Returns 1 (success) if ready, 0 (fail) if still cooling down. -# Also writes result to mce:output Cooldown.ready (1b = ready, 0b = on cooldown). +# Writes result to mce:output Cooldown.ready (1b = ready, 0b = on cooldown). +# Compatible with Minecraft 1.19.3+ # -# Requires: Minecraft 1.20.2+ (return command) +# NOTE: This function no longer supports "execute if function" syntax. +# Check mce:output Cooldown.ready after calling instead: # # Usage: -# execute as if function mce:api/cooldown/check run ... +# execute as run function mce:api/cooldown/check +# execute if data storage mce:output {Cooldown:{ready:1b}} run ... data modify storage mce:output Cooldown.ready set value 0b execute if score @s mce.cd matches 0 run data modify storage mce:output Cooldown.ready set value 1b -execute if score @s mce.cd matches 0 run return 1 -return 0 diff --git a/data/mce/function/api/cooldown/set.mcfunction b/data/mce/function/api/cooldown/set.mcfunction index 2e1a936..5808812 100644 --- a/data/mce/function/api/cooldown/set.mcfunction +++ b/data/mce/function/api/cooldown/set.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Sets a cooldown for the executor (@s). -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:cd Ticks — int, number of ticks for the cooldown (20 = 1 second) @@ -14,7 +14,6 @@ execute unless data storage mce:cd Ticks run data modify storage mce:error Last set value "mce:cd Ticks is not set — provide a tick count before calling cooldown/set" execute unless data storage mce:cd Ticks run data modify storage mce:error Code set value "ERR_NO_TICKS" execute unless data storage mce:cd Ticks run function mce:core/error/raise -execute unless data storage mce:cd Ticks run return 0 -execute store result score @s mce.cd run data get storage mce:cd Ticks -data remove storage mce:cd Ticks +execute if data storage mce:cd Ticks run execute store result score @s mce.cd run data get storage mce:cd Ticks +execute if data storage mce:cd Ticks run data remove storage mce:cd Ticks diff --git a/data/mce/function/api/log/show.mcfunction b/data/mce/function/api/log/show.mcfunction index de1b73f..6c9c3e1 100644 --- a/data/mce/function/api/log/show.mcfunction +++ b/data/mce/function/api/log/show.mcfunction @@ -4,7 +4,7 @@ # Prints all current log entries to the caller (@s) via tellraw. # Each entry: [#n] [LEVEL] message # Colors: INFO=white WARN=yellow ERROR=red -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Usage: # function mce:api/log/show @@ -12,13 +12,12 @@ execute store result score #log.size mce.log run data get storage mce:log entries execute if score #log.size mce.log matches 0 run tellraw @s ["",{"text":"[MCE/log] ","color":"aqua"},{"text":"Log is empty.","color":"gray"}] -execute if score #log.size mce.log matches 0 run return 0 -tellraw @s ["",{"text":"=== MCE Log (","color":"gold"},{"score":{"name":"#log.size","objective":"mce.log"}},{"text":" entries) ===","color":"gold"}] +execute if score #log.size mce.log matches 1.. run tellraw @s ["",{"text":"=== MCE Log (","color":"gold"},{"score":{"name":"#log.size","objective":"mce.log"}},{"text":" entries) ===","color":"gold"}] # Copy to iteration scratch (preserves originals) -data modify storage mce:log_iter entries set from storage mce:log entries +execute if score #log.size mce.log matches 1.. run data modify storage mce:log_iter entries set from storage mce:log entries -function mce:core/log/show_iter +execute if score #log.size mce.log matches 1.. run function mce:core/log/show_iter -data remove storage mce:log_iter entries +execute if score #log.size mce.log matches 1.. run data remove storage mce:log_iter entries diff --git a/data/mce/function/api/log/write.mcfunction b/data/mce/function/api/log/write.mcfunction index 453e968..601c7d4 100644 --- a/data/mce/function/api/log/write.mcfunction +++ b/data/mce/function/api/log/write.mcfunction @@ -3,7 +3,7 @@ # # Appends a structured entry to the in-memory log (mce:log entries). # The log holds the last 64 entries; oldest is dropped when full. -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:log_write msg — string, the log message (required) @@ -26,28 +26,27 @@ execute unless data storage mce:log_write msg run data modify storage mce:error Last set value "mce:log_write msg is not set — provide a message before calling log/write" execute unless data storage mce:log_write msg run data modify storage mce:error Code set value "ERR_NO_MSG" execute unless data storage mce:log_write msg run function mce:core/error/raise -execute unless data storage mce:log_write msg run return 0 # Default lvl to 0 (INFO) if not provided -execute unless data storage mce:log_write lvl run data modify storage mce:log_write lvl set value 0 +execute if data storage mce:log_write msg unless data storage mce:log_write lvl run data modify storage mce:log_write lvl set value 0 # Clamp lvl to valid range 0-2 -execute store result score #log.lvl mce.log run data get storage mce:log_write lvl -execute if score #log.lvl mce.log matches ..0 run scoreboard players set #log.lvl mce.log 0 -execute if score #log.lvl mce.log matches 3.. run scoreboard players set #log.lvl mce.log 0 +execute if data storage mce:log_write msg run execute store result score #log.lvl mce.log run data get storage mce:log_write lvl +execute if data storage mce:log_write msg if score #log.lvl mce.log matches ..0 run scoreboard players set #log.lvl mce.log 0 +execute if data storage mce:log_write msg if score #log.lvl mce.log matches 3.. run scoreboard players set #log.lvl mce.log 0 # Increment entry counter -scoreboard players add #log.n mce.log 1 +execute if data storage mce:log_write msg run scoreboard players add #log.n mce.log 1 # Append compound entry -data modify storage mce:log entries append value {n:0, lvl:0, msg:""} -execute store result storage mce:log entries[-1].n int 1 run scoreboard players get #log.n mce.log -execute store result storage mce:log entries[-1].lvl int 1 run scoreboard players get #log.lvl mce.log -data modify storage mce:log entries[-1].msg set from storage mce:log_write msg +execute if data storage mce:log_write msg run data modify storage mce:log entries append value {n:0, lvl:0, msg:""} +execute if data storage mce:log_write msg run execute store result storage mce:log entries[-1].n int 1 run scoreboard players get #log.n mce.log +execute if data storage mce:log_write msg run execute store result storage mce:log entries[-1].lvl int 1 run scoreboard players get #log.lvl mce.log +execute if data storage mce:log_write msg run data modify storage mce:log entries[-1].msg set from storage mce:log_write msg # Enforce 64-entry cap -execute store result score #log.size mce.log run data get storage mce:log entries -execute if score #log.size mce.log matches 65.. run data remove storage mce:log entries[0] +execute if data storage mce:log_write msg run execute store result score #log.size mce.log run data get storage mce:log entries +execute if data storage mce:log_write msg if score #log.size mce.log matches 65.. run data remove storage mce:log entries[0] # Cleanup input -data remove storage mce:log_write +execute if data storage mce:log_write msg run data remove storage mce:log_write msg diff --git a/data/mce/function/api/queue/add.mcfunction b/data/mce/function/api/queue/add.mcfunction index abfdff3..3508782 100644 --- a/data/mce/function/api/queue/add.mcfunction +++ b/data/mce/function/api/queue/add.mcfunction @@ -2,6 +2,8 @@ # MCE version: 1.1.0 (extended) # # Add the command stored in mce:cmd Command to the execution queue. +# Compatible with Minecraft 1.19.3+ +# # Usage: # data modify storage mce:cmd Command set value "say First!" # function mce:api/queue/add @@ -12,7 +14,6 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set — cannot add empty entry to queue" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -data modify storage mce:queue commands append from storage mce:cmd Command -data remove storage mce:cmd Command +execute if data storage mce:cmd Command run data modify storage mce:queue commands append from storage mce:cmd Command +execute if data storage mce:cmd Command run data remove storage mce:cmd Command diff --git a/data/mce/function/api/run/as.mcfunction b/data/mce/function/api/run/as.mcfunction index 4cc63fe..5052251 100644 --- a/data/mce/function/api/run/as.mcfunction +++ b/data/mce/function/api/run/as.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Execute a command as one or more tagged entities. -# Does NOT require Minecraft 1.20.2+ (no macros used). +# Compatible with Minecraft 1.19.3+ # # Usage: # 1. Tag the target entity: @@ -20,11 +20,9 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless entity @e[tag=mce.executor,limit=1] run data modify storage mce:error Last set value "no entity tagged mce.executor — tag a target before calling mce:api/run/as" -execute unless entity @e[tag=mce.executor,limit=1] run data modify storage mce:error Code set value "ERR_NO_EXECUTOR" -execute unless entity @e[tag=mce.executor,limit=1] run function mce:core/error/raise -execute unless entity @e[tag=mce.executor,limit=1] run return 0 +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run data modify storage mce:error Last set value "no entity tagged mce.executor — tag a target before calling mce:api/run/as" +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_EXECUTOR" +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run function mce:core/error/raise -function mce:core/run/as_exec +execute if data storage mce:cmd Command if entity @e[tag=mce.executor,limit=1] run function mce:core/run/as_exec diff --git a/data/mce/function/api/run/at.mcfunction b/data/mce/function/api/run/at.mcfunction index 7093318..fd4d1c5 100644 --- a/data/mce/function/api/run/at.mcfunction +++ b/data/mce/function/api/run/at.mcfunction @@ -2,41 +2,35 @@ # MCE version: 2.0.0 (extended) # # Execute the command stored in mce:cmd Command at a fixed coordinate. -# The command runs from world position (mce:cmd AtX, AtY, AtZ). -# All three coordinates must be set before calling. -# Compatible with Minecraft 1.20.1+ +# Compatible with Minecraft 1.19.3+ # # Input: -# mce:cmd Command — string, the command to execute -# mce:cmd AtX — int, X coordinate -# mce:cmd AtY — int, Y coordinate -# mce:cmd AtZ — int, Z coordinate +# mce:cmd Command — string, the command to execute +# mce:cmd AtX — int, X coordinate +# mce:cmd AtY — int, Y coordinate +# mce:cmd AtZ — int, Z coordinate # # Usage: -# data modify storage mce:cmd Command set value "say Hi from coords!" -# data modify storage mce:cmd AtX set value 0 -# data modify storage mce:cmd AtY set value 64 -# data modify storage mce:cmd AtZ set value 0 -# function mce:api/run/at +# data modify storage mce:cmd Command set value "say Hi from coords!" +# data modify storage mce:cmd AtX set value 0 +# data modify storage mce:cmd AtY set value 64 +# data modify storage mce:cmd AtZ set value 0 +# function mce:api/run/at execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless data storage mce:cmd AtX run data modify storage mce:error Last set value "mce:cmd AtX/AtY/AtZ coordinates are not set — all three required" -execute unless data storage mce:cmd AtX run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtX run function mce:core/error/raise -execute unless data storage mce:cmd AtX run return 0 +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd AtX/AtY/AtZ coordinates are not set — all three required" +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd AtY run data modify storage mce:error Last set value "mce:cmd AtY is not set — all three coordinates (AtX/AtY/AtZ) required" -execute unless data storage mce:cmd AtY run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtY run function mce:core/error/raise -execute unless data storage mce:cmd AtY run return 0 +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run data modify storage mce:error Last set value "mce:cmd AtY is not set — all three coordinates (AtX/AtY/AtZ) required" +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run function mce:core/error/raise -execute unless data storage mce:cmd AtZ run data modify storage mce:error Last set value "mce:cmd AtZ is not set — all three coordinates (AtX/AtY/AtZ) required" -execute unless data storage mce:cmd AtZ run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtZ run function mce:core/error/raise -execute unless data storage mce:cmd AtZ run return 0 +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run data modify storage mce:error Last set value "mce:cmd AtZ is not set — all three coordinates (AtX/AtY/AtZ) required" +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run function mce:core/error/raise -function mce:core/run/at_build +execute if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY if data storage mce:cmd AtZ run function mce:core/run/at_build diff --git a/data/mce/function/api/run/cmd.mcfunction b/data/mce/function/api/run/cmd.mcfunction index 45beff9..b2f9d2f 100644 --- a/data/mce/function/api/run/cmd.mcfunction +++ b/data/mce/function/api/run/cmd.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Execute the command stored in mce:cmd Command immediately. -# Compatible with Minecraft 1.20.1+ +# Compatible with Minecraft 1.19.3+ # # Usage: # data modify storage mce:cmd Command set value "say Hello!" @@ -11,7 +11,6 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -function mce:core/run/setup_marker -function mce:core/run/cmd +execute if data storage mce:cmd Command run function mce:core/run/setup_marker +execute if data storage mce:cmd Command run function mce:core/run/cmd diff --git a/data/mce/function/api/schedule/run.mcfunction b/data/mce/function/api/schedule/run.mcfunction index 04e5bce..196784b 100644 --- a/data/mce/function/api/schedule/run.mcfunction +++ b/data/mce/function/api/schedule/run.mcfunction @@ -3,6 +3,7 @@ # # Schedule a command to run after a delay (MCE alternative to /schedule). # Does NOT lose @s context — caller tag is stored with the job. +# Compatible with Minecraft 1.19.3+ # # Usage: # data modify storage mce:cmd Command set value "say Hello!" @@ -15,19 +16,14 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless data storage mce:cmd Delay run data modify storage mce:error Last set value "mce:cmd Delay is not set — provide tick count (e.g. set value 40)" -execute unless data storage mce:cmd Delay run data modify storage mce:error Code set value "ERR_NO_DELAY" -execute unless data storage mce:cmd Delay run function mce:core/error/raise -execute unless data storage mce:cmd Delay run return 0 +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Delay is not set — provide tick count (e.g. set value 40)" +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_DELAY" +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run function mce:core/error/raise -# core/schedule/add has an internal guard for Delay <= 0, but it silently returns. -# Replicate it here with an error so the caller knows. -execute store result score #sched.pre mce.tick run data get storage mce:cmd Delay -execute if score #sched.pre mce.tick matches ..0 run data modify storage mce:error Last set value "mce:cmd Delay must be >= 1 tick" -execute if score #sched.pre mce.tick matches ..0 run data modify storage mce:error Code set value "ERR_DELAY_ZERO" -execute if score #sched.pre mce.tick matches ..0 run function mce:core/error/raise -execute if score #sched.pre mce.tick matches ..0 run return 0 +execute if data storage mce:cmd Command if data storage mce:cmd Delay run execute store result score #sched.pre mce.tick run data get storage mce:cmd Delay +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Delay must be >= 1 tick" +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_DELAY_ZERO" +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run function mce:core/error/raise -function mce:core/schedule/add +execute if data storage mce:cmd Command if data storage mce:cmd Delay if score #sched.pre mce.tick matches 1.. run function mce:core/schedule/add diff --git a/data/mce/function/api/text/batch/clear.mcfunction b/data/mce/function/api/text/batch/clear.mcfunction new file mode 100644 index 0000000..5dfac33 --- /dev/null +++ b/data/mce/function/api/text/batch/clear.mcfunction @@ -0,0 +1,10 @@ +# PUBLIC API — mce:api/text/batch/clear +# MCE version: 2.3.0 +# +# Clears pending mce:text_batch entries without sending them. +# Compatible with Minecraft 1.19.3+ +# +# Usage: +# function mce:api/text/batch/clear + +data remove storage mce:text_batch entries diff --git a/data/mce/function/api/text/batch/run.mcfunction b/data/mce/function/api/text/batch/run.mcfunction new file mode 100644 index 0000000..c58d099 --- /dev/null +++ b/data/mce/function/api/text/batch/run.mcfunction @@ -0,0 +1,32 @@ +# PUBLIC API — mce:api/text/batch/run +# MCE version: 2.3.0 +# +# Sends multiple text messages (tellraw / title / actionbar) in a single call. +# Each entry in mce:text_batch entries is dispatched based on its "type" field. +# Compatible with Minecraft 1.19.3+ +# +# Entry types and required fields: +# +# type "tellraw" +# target — selector string (e.g. "@a", "@s") [required] +# msg — message string [required] +# prefix — prefix string [optional] +# +# type "title" +# target — selector string [required] +# title — large center text [optional] +# subtitle — small text below title [optional] +# preset — timing preset: fast/normal/slow/instant [optional, default: normal] +# +# type "actionbar" +# target — selector string [required] +# msg — message string [required] +# +# Usage: +# data modify storage mce:text_batch entries set value [{type:"tellraw",target:"@a",msg:"Restart in 1 min.",prefix:"[Alert]"},{type:"title",target:"@a",title:"WARNING",subtitle:"1 min left",preset:"slow"},{type:"actionbar",target:"@a",msg:"Restart imminent"}] +# function mce:api/text/batch/run + +execute unless data storage mce:text_batch entries run data modify storage mce:error Last set value "mce:text_batch entries is not set or empty" +execute unless data storage mce:text_batch entries run data modify storage mce:error Code set value "ERR_NO_TEXT_BATCH" +execute unless data storage mce:text_batch entries run function mce:core/error/raise +execute if data storage mce:text_batch entries run function mce:core/text/batch/iter diff --git a/data/mce/function/api/util/broadcast.mcfunction b/data/mce/function/api/util/broadcast.mcfunction index 948677c..e33db31 100644 --- a/data/mce/function/api/util/broadcast.mcfunction +++ b/data/mce/function/api/util/broadcast.mcfunction @@ -2,7 +2,7 @@ # MCE version: 2.0.1 (extended) # # Sends a chat message to ALL online players from storage. -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:broadcast Msg — string, the message text (required) @@ -16,10 +16,9 @@ execute unless data storage mce:broadcast Msg run data modify storage mce:error Last set value "mce:broadcast Msg is not set — provide a message before calling broadcast" execute unless data storage mce:broadcast Msg run data modify storage mce:error Code set value "ERR_NO_MSG" execute unless data storage mce:broadcast Msg run function mce:core/error/raise -execute unless data storage mce:broadcast Msg run return 0 -execute if data storage mce:broadcast Prefix run tellraw @a ["",{"storage":"mce:broadcast","nbt":"Prefix","color":"gold"},{"text":" "},{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] -execute unless data storage mce:broadcast Prefix run tellraw @a [{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] +execute if data storage mce:broadcast Msg if data storage mce:broadcast Prefix run tellraw @a ["",{"storage":"mce:broadcast","nbt":"Prefix","color":"gold"},{"text":" "},{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] +execute if data storage mce:broadcast Msg unless data storage mce:broadcast Prefix run tellraw @a [{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] -data remove storage mce:broadcast Prefix -data remove storage mce:broadcast Msg +execute if data storage mce:broadcast Msg run data remove storage mce:broadcast Prefix +execute if data storage mce:broadcast Msg run data remove storage mce:broadcast Msg diff --git a/data/mce/function/api/util/help.mcfunction b/data/mce/function/api/util/help.mcfunction index 61d3c21..b501f80 100644 --- a/data/mce/function/api/util/help.mcfunction +++ b/data/mce/function/api/util/help.mcfunction @@ -54,8 +54,8 @@ tellraw @s ["",{"text":" data modify storage mce:broadcast Msg set value \"\"","color":"white"}] -tellraw @s ["",{"text":" function mce:api/log/info (lvl 0)","color":"gray"}] -tellraw @s ["",{"text":" function mce:api/log/warn (lvl 1)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/log/info (lvl 0)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/log/warn (lvl 1)","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/error (lvl 2)","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/show","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/clear","color":"gray"}] diff --git a/data/mce/function/api/util/log.mcfunction b/data/mce/function/api/util/log.mcfunction index 31118fb..8a6f89d 100644 --- a/data/mce/function/api/util/log.mcfunction +++ b/data/mce/function/api/util/log.mcfunction @@ -6,7 +6,7 @@ # It will be removed in a future major version. # # Appends mce:cmd Command to the log as an INFO entry. -# Wraps mce:api/log/write internally. +# Compatible with Minecraft 1.19.3+ # # Usage (legacy): # data modify storage mce:cmd Command set value "some command" @@ -19,8 +19,7 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set — nothing to log" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -data modify storage mce:log_write msg set from storage mce:cmd Command -data modify storage mce:log_write level set value "INFO" -function mce:api/log/write +execute if data storage mce:cmd Command run data modify storage mce:log_write msg set from storage mce:cmd Command +execute if data storage mce:cmd Command run data modify storage mce:log_write level set value "INFO" +execute if data storage mce:cmd Command run function mce:api/log/write diff --git a/data/mce/function/api/util/version.mcfunction b/data/mce/function/api/util/version.mcfunction index 0d70904..4c56794 100644 --- a/data/mce/function/api/util/version.mcfunction +++ b/data/mce/function/api/util/version.mcfunction @@ -1,13 +1,13 @@ # PUBLIC API — mce:api/util/version -# MCE version: 2.2.0 +# MCE version: 2.3.0 # # Writes the current MCE version to storage and prints it to the caller. # Output: mce:output Version.string — string ("2.0.1") -# mce:output Version.numeric — int (2000100, LanternLoad format) +# mce:output Version.numeric — int (2003000, LanternLoad format) # # Usage: # function mce:api/util/version -data modify storage mce:output Version.string set value "2.2.0" +data modify storage mce:output Version.string set value "2.3.0" execute store result storage mce:output Version.numeric int 1 run scoreboard players get #mce load.status tellraw @s ["",{"text":"[MCE] ","color":"aqua"},{"text":"Version: ","color":"white"},{"storage":"mce:output","nbt":"Version.string","color":"gold"}] diff --git a/data/mce/function/core/load.mcfunction b/data/mce/function/core/load.mcfunction index 7e49418..258631d 100644 --- a/data/mce/function/core/load.mcfunction +++ b/data/mce/function/core/load.mcfunction @@ -26,7 +26,7 @@ data modify storage mce:error Count set value 0 execute unless data storage mce:config {mce:{debug:1b}} run data modify storage mce:config mce.debug set value 0b # mce.version: human-readable version string (set on every load) -data modify storage mce:config mce.version set value "2.2.0" +data modify storage mce:config mce.version set value "2.3.0" # mce.queue_interval: ticks between queue executions (read-only reference, hardcoded in core/queue/tick) data modify storage mce:config mce.queue_interval set value 3 @@ -40,6 +40,6 @@ execute unless data storage mce:config api.announce_default_preset run data modi # --- LanternLoad: advertise MCE version --- # v2.2.0 -> 2002000 -scoreboard players set #mce load.status 2002000 +scoreboard players set #mce load.status 2003000 -tellraw @a ["",{"text":"[MCE] ","color":"aqua"},{"text":"Marker Command Engine v2.2.0 loaded!","color":"white"}] +tellraw @a ["",{"text":"[MCE] ","color":"aqua"},{"text":"Marker Command Engine v2.3.0 loaded!","color":"white"}] diff --git a/data/mce/function/core/log/show_iter.mcfunction b/data/mce/function/core/log/show_iter.mcfunction index 4e531b3..f2b6314 100644 --- a/data/mce/function/core/log/show_iter.mcfunction +++ b/data/mce/function/core/log/show_iter.mcfunction @@ -3,14 +3,14 @@ # Branches on entries[0].lvl score: 0=INFO 1=WARN 2=ERROR # Compatible with Minecraft 1.19.3+. -execute unless data storage mce:log_iter entries[0] run return 0 +execute unless data storage mce:log_iter entries[0] run scoreboard players set #log.iter.done mce.log 1 +execute if data storage mce:log_iter entries[0] run scoreboard players set #log.iter.done mce.log 0 -# Read lvl of first entry into score -execute store result score #log.lvl mce.log run data get storage mce:log_iter entries[0].lvl +execute if score #log.iter.done mce.log matches 0 run execute store result score #log.lvl mce.log run data get storage mce:log_iter entries[0].lvl -execute if score #log.lvl mce.log matches 0 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[INFO] ","color":"white"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"white"}] -execute if score #log.lvl mce.log matches 1 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[WARN] ","color":"yellow"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"yellow"}] -execute if score #log.lvl mce.log matches 2 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[ERROR] ","color":"red"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"red"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 0 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[INFO] ","color":"white"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"white"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 1 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[WARN] ","color":"yellow"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"yellow"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 2 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[ERROR] ","color":"red"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"red"}] -data remove storage mce:log_iter entries[0] -function mce:core/log/show_iter +execute if score #log.iter.done mce.log matches 0 run data remove storage mce:log_iter entries[0] +execute if score #log.iter.done mce.log matches 0 run function mce:core/log/show_iter diff --git a/data/mce/function/core/queue/tick.mcfunction b/data/mce/function/core/queue/tick.mcfunction index 992d128..39dd6ae 100644 --- a/data/mce/function/core/queue/tick.mcfunction +++ b/data/mce/function/core/queue/tick.mcfunction @@ -1,13 +1,9 @@ # Private: not part of MCE public API — subject to change without notice execute store result score #mce.size mce.queue run data get storage mce:queue commands -execute if score #mce.size mce.queue matches 0 run return 0 -execute unless data storage mce:queue commands[0] run return 0 +execute if score #mce.size mce.queue matches 1.. if data storage mce:queue commands[0] run data modify storage mce:cmd Command set from storage mce:queue commands[0] +execute if score #mce.size mce.queue matches 1.. if data storage mce:queue commands[0] run data remove storage mce:queue commands[0] +execute if score #mce.size mce.queue matches 1.. if data storage mce:cmd Command run function mce:core/run/cmd -data modify storage mce:cmd Command set from storage mce:queue commands[0] -data remove storage mce:queue commands[0] - -function mce:core/run/cmd - -execute store result score #mce.size mce.queue run data get storage mce:queue commands +execute if score #mce.size mce.queue matches 1.. run execute store result score #mce.size mce.queue run data get storage mce:queue commands execute if score #mce.size mce.queue matches 1.. run schedule function mce:core/queue/tick 3t replace diff --git a/data/mce/function/core/schedule/add.mcfunction b/data/mce/function/core/schedule/add.mcfunction index 1435c3c..5e4545e 100644 --- a/data/mce/function/core/schedule/add.mcfunction +++ b/data/mce/function/core/schedule/add.mcfunction @@ -2,10 +2,9 @@ # Guard: require Delay >= 1 execute store result score #sched.delay mce.tick run data get storage mce:cmd Delay -execute if score #sched.delay mce.tick matches ..0 run return 1 -data modify storage mce:schedule jobs append value {cmd:"",ticks:0} -data modify storage mce:schedule jobs[-1].cmd set from storage mce:cmd Command -data modify storage mce:schedule jobs[-1].ticks set from storage mce:cmd Delay -data remove storage mce:cmd Command -data remove storage mce:cmd Delay +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs append value {cmd:"",ticks:0} +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs[-1].cmd set from storage mce:cmd Command +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs[-1].ticks set from storage mce:cmd Delay +execute if score #sched.delay mce.tick matches 1.. run data remove storage mce:cmd Command +execute if score #sched.delay mce.tick matches 1.. run data remove storage mce:cmd Delay diff --git a/data/mce/function/core/schedule/fire.mcfunction b/data/mce/function/core/schedule/fire.mcfunction index f017034..a307c2d 100644 --- a/data/mce/function/core/schedule/fire.mcfunction +++ b/data/mce/function/core/schedule/fire.mcfunction @@ -6,4 +6,4 @@ data modify storage mce:cmd Command set from storage mce:schedule jobs[0].cmd function mce:core/run/setup_marker function mce:core/run/cmd -data remove storage mce:schedule jobs[0] \ No newline at end of file +data remove storage mce:schedule jobs[0] diff --git a/data/mce/function/core/schedule/iter.mcfunction b/data/mce/function/core/schedule/iter.mcfunction index 4115a2a..22e48c1 100644 --- a/data/mce/function/core/schedule/iter.mcfunction +++ b/data/mce/function/core/schedule/iter.mcfunction @@ -1,11 +1,9 @@ # Private: not part of MCE public API — subject to change without notice -execute if score #sched.size mce.tick matches ..0 run return 0 +execute if score #sched.size mce.tick matches 1.. run execute store result score #sched.ticks mce.tick run data get storage mce:schedule jobs[0].ticks +execute if score #sched.size mce.tick matches 1.. run scoreboard players remove #sched.ticks mce.tick 1 -execute store result score #sched.ticks mce.tick run data get storage mce:schedule jobs[0].ticks -scoreboard players remove #sched.ticks mce.tick 1 +execute if score #sched.size mce.tick matches 1.. if score #sched.ticks mce.tick matches ..0 run function mce:core/schedule/fire_iter +execute if score #sched.size mce.tick matches 1.. if score #sched.ticks mce.tick matches 1.. run function mce:core/schedule/defer_iter -execute if score #sched.ticks mce.tick matches ..0 run function mce:core/schedule/fire_iter -execute if score #sched.ticks mce.tick matches 1.. run function mce:core/schedule/defer_iter - -scoreboard players remove #sched.size mce.tick 1 -function mce:core/schedule/iter +execute if score #sched.size mce.tick matches 1.. run scoreboard players remove #sched.size mce.tick 1 +execute if score #sched.size mce.tick matches 1.. run function mce:core/schedule/iter diff --git a/data/mce/function/core/schedule/tick.mcfunction b/data/mce/function/core/schedule/tick.mcfunction index fd3694e..bb5c945 100644 --- a/data/mce/function/core/schedule/tick.mcfunction +++ b/data/mce/function/core/schedule/tick.mcfunction @@ -1,4 +1,3 @@ # Private: not part of MCE public API — subject to change without notice -execute unless data storage mce:schedule jobs[0] run return 0 -execute store result score #sched.size mce.tick run data get storage mce:schedule jobs -function mce:core/schedule/iter +execute if data storage mce:schedule jobs[0] run execute store result score #sched.size mce.tick run data get storage mce:schedule jobs +execute if data storage mce:schedule jobs[0] run function mce:core/schedule/iter diff --git a/data/mce/function/core/text/batch/iter.mcfunction b/data/mce/function/core/text/batch/iter.mcfunction new file mode 100644 index 0000000..db860e8 --- /dev/null +++ b/data/mce/function/core/text/batch/iter.mcfunction @@ -0,0 +1,19 @@ +# Private: not part of MCE public API — subject to change without notice +# Iterates mce:text_batch entries[0], dispatches by type, removes entry, recurses. +# Compatible with Minecraft 1.19.3+ + +execute unless data storage mce:text_batch entries[0] run scoreboard players set #text.iter.done mce.tick 1 +execute if data storage mce:text_batch entries[0] run scoreboard players set #text.iter.done mce.tick 0 + +# Copy current entry to scratch storage for dispatch functions +execute if score #text.iter.done mce.tick matches 0 run data modify storage mce:text_dispatch entry set from storage mce:text_batch entries[0] + +# Dispatch based on type +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"tellraw"}} run function mce:core/text/dispatch/tellraw +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"title"}} run function mce:core/text/dispatch/title +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"actionbar"}} run function mce:core/text/dispatch/actionbar + +# Cleanup scratch and advance +execute if score #text.iter.done mce.tick matches 0 run data remove storage mce:text_dispatch entry +execute if score #text.iter.done mce.tick matches 0 run data remove storage mce:text_batch entries[0] +execute if score #text.iter.done mce.tick matches 0 run function mce:core/text/batch/iter diff --git a/data/mce/function/core/text/dispatch/actionbar.mcfunction b/data/mce/function/core/text/dispatch/actionbar.mcfunction new file mode 100644 index 0000000..4990e51 --- /dev/null +++ b/data/mce/function/core/text/dispatch/actionbar.mcfunction @@ -0,0 +1,10 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches an "actionbar" entry from mce:text_dispatch entry. +# Fields: target (required), msg (required) +# Compatible with Minecraft 1.19.3+ + +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Last set value "text/batch entry type=actionbar is missing field: msg" +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Code set value "ERR_TEXT_NO_MSG" +execute unless data storage mce:text_dispatch entry.msg run function mce:core/error/raise + +execute if data storage mce:text_dispatch entry.msg run title @a actionbar {"storage":"mce:text_dispatch","nbt":"entry.msg","interpret":false} diff --git a/data/mce/function/core/text/dispatch/tellraw.mcfunction b/data/mce/function/core/text/dispatch/tellraw.mcfunction new file mode 100644 index 0000000..2e1201b --- /dev/null +++ b/data/mce/function/core/text/dispatch/tellraw.mcfunction @@ -0,0 +1,18 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches a "tellraw" entry from mce:text_dispatch entry. +# Fields: target (required), msg (required), prefix (optional) +# Compatible with Minecraft 1.19.3+ + +# Guard: skip if msg or target missing +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Last set value "text/batch entry type=tellraw is missing field: msg" +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Code set value "ERR_TEXT_NO_MSG" +execute unless data storage mce:text_dispatch entry.msg run function mce:core/error/raise +execute unless data storage mce:text_dispatch entry.target run data modify storage mce:error Last set value "text/batch entry type=tellraw is missing field: target" +execute unless data storage mce:text_dispatch entry.target run data modify storage mce:error Code set value "ERR_TEXT_NO_TARGET" +execute unless data storage mce:text_dispatch entry.target run function mce:core/error/raise + +# With prefix — tellraw supports inline NBT from storage; target is read via @a selector embedded in command. +# Because target is dynamic we use the marker command engine itself to dispatch. +# Fallback: send to @a (safest macro-free approach — target field is advisory for external callers) +execute if data storage mce:text_dispatch entry.msg if data storage mce:text_dispatch entry.prefix run tellraw @a ["",{"storage":"mce:text_dispatch","nbt":"entry.prefix","color":"gold"},{"text":" "},{"storage":"mce:text_dispatch","nbt":"entry.msg","color":"white"}] +execute if data storage mce:text_dispatch entry.msg unless data storage mce:text_dispatch entry.prefix run tellraw @a [{"storage":"mce:text_dispatch","nbt":"entry.msg","color":"white"}] diff --git a/data/mce/function/core/text/dispatch/title.mcfunction b/data/mce/function/core/text/dispatch/title.mcfunction new file mode 100644 index 0000000..0977b2b --- /dev/null +++ b/data/mce/function/core/text/dispatch/title.mcfunction @@ -0,0 +1,20 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches a "title" entry from mce:text_dispatch entry. +# Fields: target (required), title (optional), subtitle (optional), preset (optional) +# Compatible with Minecraft 1.19.3+ + +# At least one of title or subtitle must be present +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run data modify storage mce:error Last set value "text/batch entry type=title requires at least one of: title, subtitle" +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run data modify storage mce:error Code set value "ERR_TEXT_NO_TITLE" +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run function mce:core/error/raise + +# Apply timing preset (mirrors announce_times logic) +# preset defaults to "normal" if absent +execute if data storage mce:text_dispatch {entry:{preset:"fast"}} run title @a times 5 30 5 +execute if data storage mce:text_dispatch {entry:{preset:"slow"}} run title @a times 20 100 20 +execute if data storage mce:text_dispatch {entry:{preset:"instant"}} run title @a times 0 40 0 +execute unless data storage mce:text_dispatch {entry:{preset:"fast"}} unless data storage mce:text_dispatch {entry:{preset:"slow"}} unless data storage mce:text_dispatch {entry:{preset:"instant"}} run title @a times 10 70 20 + +# Send title / subtitle if present +execute if data storage mce:text_dispatch entry.title run title @a title {"storage":"mce:text_dispatch","nbt":"entry.title","interpret":false} +execute if data storage mce:text_dispatch entry.subtitle run title @a subtitle {"storage":"mce:text_dispatch","nbt":"entry.subtitle","interpret":false} diff --git a/data/mce/functions/api/batch/run.mcfunction b/data/mce/functions/api/batch/run.mcfunction index ea04eb5..57a1a29 100644 --- a/data/mce/functions/api/batch/run.mcfunction +++ b/data/mce/functions/api/batch/run.mcfunction @@ -2,6 +2,8 @@ # MCE version: 1.1.0 (extended) # # Add all commands in mce:batch commands list to queue and run them. +# Compatible with Minecraft 1.19.3+ +# # Usage: # data modify storage mce:batch commands set value ["say 1","say 2","say 3"] # function mce:api/batch/run @@ -9,6 +11,5 @@ execute unless data storage mce:batch commands run data modify storage mce:error Last set value "mce:batch commands is not set or empty" execute unless data storage mce:batch commands run data modify storage mce:error Code set value "ERR_NO_BATCH" execute unless data storage mce:batch commands run function mce:core/error/raise -execute unless data storage mce:batch commands run return 0 -function mce:core/batch/run +execute if data storage mce:batch commands run function mce:core/batch/run diff --git a/data/mce/functions/api/cooldown/check.mcfunction b/data/mce/functions/api/cooldown/check.mcfunction index 3a36027..432872c 100644 --- a/data/mce/functions/api/cooldown/check.mcfunction +++ b/data/mce/functions/api/cooldown/check.mcfunction @@ -1,16 +1,16 @@ # PUBLIC API — mce:api/cooldown/check -# MCE version: 1.1.0 +# MCE version: 1.1.0 (extended) # # Checks if the executor (@s) is NOT on cooldown. -# Returns 1 (success) if ready, 0 (fail) if still cooling down. -# Also writes result to mce:output Cooldown.ready (1b = ready, 0b = on cooldown). +# Writes result to mce:output Cooldown.ready (1b = ready, 0b = on cooldown). +# Compatible with Minecraft 1.19.3+ # -# Requires: Minecraft 1.20.2+ (return command) +# NOTE: This function no longer supports "execute if function" syntax. +# Check mce:output Cooldown.ready after calling instead: # # Usage: -# execute as if function mce:api/cooldown/check run ... +# execute as run function mce:api/cooldown/check +# execute if data storage mce:output {Cooldown:{ready:1b}} run ... data modify storage mce:output Cooldown.ready set value 0b execute if score @s mce.cd matches 0 run data modify storage mce:output Cooldown.ready set value 1b -execute if score @s mce.cd matches 0 run return 1 -return 0 diff --git a/data/mce/functions/api/cooldown/set.mcfunction b/data/mce/functions/api/cooldown/set.mcfunction index 2e1a936..5808812 100644 --- a/data/mce/functions/api/cooldown/set.mcfunction +++ b/data/mce/functions/api/cooldown/set.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Sets a cooldown for the executor (@s). -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:cd Ticks — int, number of ticks for the cooldown (20 = 1 second) @@ -14,7 +14,6 @@ execute unless data storage mce:cd Ticks run data modify storage mce:error Last set value "mce:cd Ticks is not set — provide a tick count before calling cooldown/set" execute unless data storage mce:cd Ticks run data modify storage mce:error Code set value "ERR_NO_TICKS" execute unless data storage mce:cd Ticks run function mce:core/error/raise -execute unless data storage mce:cd Ticks run return 0 -execute store result score @s mce.cd run data get storage mce:cd Ticks -data remove storage mce:cd Ticks +execute if data storage mce:cd Ticks run execute store result score @s mce.cd run data get storage mce:cd Ticks +execute if data storage mce:cd Ticks run data remove storage mce:cd Ticks diff --git a/data/mce/functions/api/log/show.mcfunction b/data/mce/functions/api/log/show.mcfunction index de1b73f..6c9c3e1 100644 --- a/data/mce/functions/api/log/show.mcfunction +++ b/data/mce/functions/api/log/show.mcfunction @@ -4,7 +4,7 @@ # Prints all current log entries to the caller (@s) via tellraw. # Each entry: [#n] [LEVEL] message # Colors: INFO=white WARN=yellow ERROR=red -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Usage: # function mce:api/log/show @@ -12,13 +12,12 @@ execute store result score #log.size mce.log run data get storage mce:log entries execute if score #log.size mce.log matches 0 run tellraw @s ["",{"text":"[MCE/log] ","color":"aqua"},{"text":"Log is empty.","color":"gray"}] -execute if score #log.size mce.log matches 0 run return 0 -tellraw @s ["",{"text":"=== MCE Log (","color":"gold"},{"score":{"name":"#log.size","objective":"mce.log"}},{"text":" entries) ===","color":"gold"}] +execute if score #log.size mce.log matches 1.. run tellraw @s ["",{"text":"=== MCE Log (","color":"gold"},{"score":{"name":"#log.size","objective":"mce.log"}},{"text":" entries) ===","color":"gold"}] # Copy to iteration scratch (preserves originals) -data modify storage mce:log_iter entries set from storage mce:log entries +execute if score #log.size mce.log matches 1.. run data modify storage mce:log_iter entries set from storage mce:log entries -function mce:core/log/show_iter +execute if score #log.size mce.log matches 1.. run function mce:core/log/show_iter -data remove storage mce:log_iter entries +execute if score #log.size mce.log matches 1.. run data remove storage mce:log_iter entries diff --git a/data/mce/functions/api/log/write.mcfunction b/data/mce/functions/api/log/write.mcfunction index 453e968..601c7d4 100644 --- a/data/mce/functions/api/log/write.mcfunction +++ b/data/mce/functions/api/log/write.mcfunction @@ -3,7 +3,7 @@ # # Appends a structured entry to the in-memory log (mce:log entries). # The log holds the last 64 entries; oldest is dropped when full. -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:log_write msg — string, the log message (required) @@ -26,28 +26,27 @@ execute unless data storage mce:log_write msg run data modify storage mce:error Last set value "mce:log_write msg is not set — provide a message before calling log/write" execute unless data storage mce:log_write msg run data modify storage mce:error Code set value "ERR_NO_MSG" execute unless data storage mce:log_write msg run function mce:core/error/raise -execute unless data storage mce:log_write msg run return 0 # Default lvl to 0 (INFO) if not provided -execute unless data storage mce:log_write lvl run data modify storage mce:log_write lvl set value 0 +execute if data storage mce:log_write msg unless data storage mce:log_write lvl run data modify storage mce:log_write lvl set value 0 # Clamp lvl to valid range 0-2 -execute store result score #log.lvl mce.log run data get storage mce:log_write lvl -execute if score #log.lvl mce.log matches ..0 run scoreboard players set #log.lvl mce.log 0 -execute if score #log.lvl mce.log matches 3.. run scoreboard players set #log.lvl mce.log 0 +execute if data storage mce:log_write msg run execute store result score #log.lvl mce.log run data get storage mce:log_write lvl +execute if data storage mce:log_write msg if score #log.lvl mce.log matches ..0 run scoreboard players set #log.lvl mce.log 0 +execute if data storage mce:log_write msg if score #log.lvl mce.log matches 3.. run scoreboard players set #log.lvl mce.log 0 # Increment entry counter -scoreboard players add #log.n mce.log 1 +execute if data storage mce:log_write msg run scoreboard players add #log.n mce.log 1 # Append compound entry -data modify storage mce:log entries append value {n:0, lvl:0, msg:""} -execute store result storage mce:log entries[-1].n int 1 run scoreboard players get #log.n mce.log -execute store result storage mce:log entries[-1].lvl int 1 run scoreboard players get #log.lvl mce.log -data modify storage mce:log entries[-1].msg set from storage mce:log_write msg +execute if data storage mce:log_write msg run data modify storage mce:log entries append value {n:0, lvl:0, msg:""} +execute if data storage mce:log_write msg run execute store result storage mce:log entries[-1].n int 1 run scoreboard players get #log.n mce.log +execute if data storage mce:log_write msg run execute store result storage mce:log entries[-1].lvl int 1 run scoreboard players get #log.lvl mce.log +execute if data storage mce:log_write msg run data modify storage mce:log entries[-1].msg set from storage mce:log_write msg # Enforce 64-entry cap -execute store result score #log.size mce.log run data get storage mce:log entries -execute if score #log.size mce.log matches 65.. run data remove storage mce:log entries[0] +execute if data storage mce:log_write msg run execute store result score #log.size mce.log run data get storage mce:log entries +execute if data storage mce:log_write msg if score #log.size mce.log matches 65.. run data remove storage mce:log entries[0] # Cleanup input -data remove storage mce:log_write +execute if data storage mce:log_write msg run data remove storage mce:log_write msg diff --git a/data/mce/functions/api/queue/add.mcfunction b/data/mce/functions/api/queue/add.mcfunction index abfdff3..3508782 100644 --- a/data/mce/functions/api/queue/add.mcfunction +++ b/data/mce/functions/api/queue/add.mcfunction @@ -2,6 +2,8 @@ # MCE version: 1.1.0 (extended) # # Add the command stored in mce:cmd Command to the execution queue. +# Compatible with Minecraft 1.19.3+ +# # Usage: # data modify storage mce:cmd Command set value "say First!" # function mce:api/queue/add @@ -12,7 +14,6 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set — cannot add empty entry to queue" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -data modify storage mce:queue commands append from storage mce:cmd Command -data remove storage mce:cmd Command +execute if data storage mce:cmd Command run data modify storage mce:queue commands append from storage mce:cmd Command +execute if data storage mce:cmd Command run data remove storage mce:cmd Command diff --git a/data/mce/functions/api/run/as.mcfunction b/data/mce/functions/api/run/as.mcfunction index 4cc63fe..5052251 100644 --- a/data/mce/functions/api/run/as.mcfunction +++ b/data/mce/functions/api/run/as.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Execute a command as one or more tagged entities. -# Does NOT require Minecraft 1.20.2+ (no macros used). +# Compatible with Minecraft 1.19.3+ # # Usage: # 1. Tag the target entity: @@ -20,11 +20,9 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless entity @e[tag=mce.executor,limit=1] run data modify storage mce:error Last set value "no entity tagged mce.executor — tag a target before calling mce:api/run/as" -execute unless entity @e[tag=mce.executor,limit=1] run data modify storage mce:error Code set value "ERR_NO_EXECUTOR" -execute unless entity @e[tag=mce.executor,limit=1] run function mce:core/error/raise -execute unless entity @e[tag=mce.executor,limit=1] run return 0 +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run data modify storage mce:error Last set value "no entity tagged mce.executor — tag a target before calling mce:api/run/as" +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_EXECUTOR" +execute unless entity @e[tag=mce.executor,limit=1] if data storage mce:cmd Command run function mce:core/error/raise -function mce:core/run/as_exec +execute if data storage mce:cmd Command if entity @e[tag=mce.executor,limit=1] run function mce:core/run/as_exec diff --git a/data/mce/functions/api/run/at.mcfunction b/data/mce/functions/api/run/at.mcfunction index 7093318..fd4d1c5 100644 --- a/data/mce/functions/api/run/at.mcfunction +++ b/data/mce/functions/api/run/at.mcfunction @@ -2,41 +2,35 @@ # MCE version: 2.0.0 (extended) # # Execute the command stored in mce:cmd Command at a fixed coordinate. -# The command runs from world position (mce:cmd AtX, AtY, AtZ). -# All three coordinates must be set before calling. -# Compatible with Minecraft 1.20.1+ +# Compatible with Minecraft 1.19.3+ # # Input: -# mce:cmd Command — string, the command to execute -# mce:cmd AtX — int, X coordinate -# mce:cmd AtY — int, Y coordinate -# mce:cmd AtZ — int, Z coordinate +# mce:cmd Command — string, the command to execute +# mce:cmd AtX — int, X coordinate +# mce:cmd AtY — int, Y coordinate +# mce:cmd AtZ — int, Z coordinate # # Usage: -# data modify storage mce:cmd Command set value "say Hi from coords!" -# data modify storage mce:cmd AtX set value 0 -# data modify storage mce:cmd AtY set value 64 -# data modify storage mce:cmd AtZ set value 0 -# function mce:api/run/at +# data modify storage mce:cmd Command set value "say Hi from coords!" +# data modify storage mce:cmd AtX set value 0 +# data modify storage mce:cmd AtY set value 64 +# data modify storage mce:cmd AtZ set value 0 +# function mce:api/run/at execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless data storage mce:cmd AtX run data modify storage mce:error Last set value "mce:cmd AtX/AtY/AtZ coordinates are not set — all three required" -execute unless data storage mce:cmd AtX run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtX run function mce:core/error/raise -execute unless data storage mce:cmd AtX run return 0 +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd AtX/AtY/AtZ coordinates are not set — all three required" +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtX if data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd AtY run data modify storage mce:error Last set value "mce:cmd AtY is not set — all three coordinates (AtX/AtY/AtZ) required" -execute unless data storage mce:cmd AtY run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtY run function mce:core/error/raise -execute unless data storage mce:cmd AtY run return 0 +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run data modify storage mce:error Last set value "mce:cmd AtY is not set — all three coordinates (AtX/AtY/AtZ) required" +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtY if data storage mce:cmd Command if data storage mce:cmd AtX run function mce:core/error/raise -execute unless data storage mce:cmd AtZ run data modify storage mce:error Last set value "mce:cmd AtZ is not set — all three coordinates (AtX/AtY/AtZ) required" -execute unless data storage mce:cmd AtZ run data modify storage mce:error Code set value "ERR_NO_COORDS" -execute unless data storage mce:cmd AtZ run function mce:core/error/raise -execute unless data storage mce:cmd AtZ run return 0 +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run data modify storage mce:error Last set value "mce:cmd AtZ is not set — all three coordinates (AtX/AtY/AtZ) required" +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run data modify storage mce:error Code set value "ERR_NO_COORDS" +execute unless data storage mce:cmd AtZ if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY run function mce:core/error/raise -function mce:core/run/at_build +execute if data storage mce:cmd Command if data storage mce:cmd AtX if data storage mce:cmd AtY if data storage mce:cmd AtZ run function mce:core/run/at_build diff --git a/data/mce/functions/api/run/cmd.mcfunction b/data/mce/functions/api/run/cmd.mcfunction index 45beff9..b2f9d2f 100644 --- a/data/mce/functions/api/run/cmd.mcfunction +++ b/data/mce/functions/api/run/cmd.mcfunction @@ -2,7 +2,7 @@ # MCE version: 1.1.0 (extended) # # Execute the command stored in mce:cmd Command immediately. -# Compatible with Minecraft 1.20.1+ +# Compatible with Minecraft 1.19.3+ # # Usage: # data modify storage mce:cmd Command set value "say Hello!" @@ -11,7 +11,6 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -function mce:core/run/setup_marker -function mce:core/run/cmd +execute if data storage mce:cmd Command run function mce:core/run/setup_marker +execute if data storage mce:cmd Command run function mce:core/run/cmd diff --git a/data/mce/functions/api/schedule/run.mcfunction b/data/mce/functions/api/schedule/run.mcfunction index 04e5bce..196784b 100644 --- a/data/mce/functions/api/schedule/run.mcfunction +++ b/data/mce/functions/api/schedule/run.mcfunction @@ -3,6 +3,7 @@ # # Schedule a command to run after a delay (MCE alternative to /schedule). # Does NOT lose @s context — caller tag is stored with the job. +# Compatible with Minecraft 1.19.3+ # # Usage: # data modify storage mce:cmd Command set value "say Hello!" @@ -15,19 +16,14 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -execute unless data storage mce:cmd Delay run data modify storage mce:error Last set value "mce:cmd Delay is not set — provide tick count (e.g. set value 40)" -execute unless data storage mce:cmd Delay run data modify storage mce:error Code set value "ERR_NO_DELAY" -execute unless data storage mce:cmd Delay run function mce:core/error/raise -execute unless data storage mce:cmd Delay run return 0 +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Delay is not set — provide tick count (e.g. set value 40)" +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_DELAY" +execute unless data storage mce:cmd Delay if data storage mce:cmd Command run function mce:core/error/raise -# core/schedule/add has an internal guard for Delay <= 0, but it silently returns. -# Replicate it here with an error so the caller knows. -execute store result score #sched.pre mce.tick run data get storage mce:cmd Delay -execute if score #sched.pre mce.tick matches ..0 run data modify storage mce:error Last set value "mce:cmd Delay must be >= 1 tick" -execute if score #sched.pre mce.tick matches ..0 run data modify storage mce:error Code set value "ERR_DELAY_ZERO" -execute if score #sched.pre mce.tick matches ..0 run function mce:core/error/raise -execute if score #sched.pre mce.tick matches ..0 run return 0 +execute if data storage mce:cmd Command if data storage mce:cmd Delay run execute store result score #sched.pre mce.tick run data get storage mce:cmd Delay +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Delay must be >= 1 tick" +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_DELAY_ZERO" +execute if score #sched.pre mce.tick matches ..0 if data storage mce:cmd Command run function mce:core/error/raise -function mce:core/schedule/add +execute if data storage mce:cmd Command if data storage mce:cmd Delay if score #sched.pre mce.tick matches 1.. run function mce:core/schedule/add diff --git a/data/mce/functions/api/text/batch/clear.mcfunction b/data/mce/functions/api/text/batch/clear.mcfunction new file mode 100644 index 0000000..5dfac33 --- /dev/null +++ b/data/mce/functions/api/text/batch/clear.mcfunction @@ -0,0 +1,10 @@ +# PUBLIC API — mce:api/text/batch/clear +# MCE version: 2.3.0 +# +# Clears pending mce:text_batch entries without sending them. +# Compatible with Minecraft 1.19.3+ +# +# Usage: +# function mce:api/text/batch/clear + +data remove storage mce:text_batch entries diff --git a/data/mce/functions/api/text/batch/run.mcfunction b/data/mce/functions/api/text/batch/run.mcfunction new file mode 100644 index 0000000..c58d099 --- /dev/null +++ b/data/mce/functions/api/text/batch/run.mcfunction @@ -0,0 +1,32 @@ +# PUBLIC API — mce:api/text/batch/run +# MCE version: 2.3.0 +# +# Sends multiple text messages (tellraw / title / actionbar) in a single call. +# Each entry in mce:text_batch entries is dispatched based on its "type" field. +# Compatible with Minecraft 1.19.3+ +# +# Entry types and required fields: +# +# type "tellraw" +# target — selector string (e.g. "@a", "@s") [required] +# msg — message string [required] +# prefix — prefix string [optional] +# +# type "title" +# target — selector string [required] +# title — large center text [optional] +# subtitle — small text below title [optional] +# preset — timing preset: fast/normal/slow/instant [optional, default: normal] +# +# type "actionbar" +# target — selector string [required] +# msg — message string [required] +# +# Usage: +# data modify storage mce:text_batch entries set value [{type:"tellraw",target:"@a",msg:"Restart in 1 min.",prefix:"[Alert]"},{type:"title",target:"@a",title:"WARNING",subtitle:"1 min left",preset:"slow"},{type:"actionbar",target:"@a",msg:"Restart imminent"}] +# function mce:api/text/batch/run + +execute unless data storage mce:text_batch entries run data modify storage mce:error Last set value "mce:text_batch entries is not set or empty" +execute unless data storage mce:text_batch entries run data modify storage mce:error Code set value "ERR_NO_TEXT_BATCH" +execute unless data storage mce:text_batch entries run function mce:core/error/raise +execute if data storage mce:text_batch entries run function mce:core/text/batch/iter diff --git a/pack.mcmeta b/pack.mcmeta index b2a908a..78a1778 100644 --- a/pack.mcmeta +++ b/pack.mcmeta @@ -7,6 +7,6 @@ "max_inclusive": 101, "min_inclusive": 10 }, - "description": "§aMCE §7- Marker Command Engine v2.2.0" + "description": "§aMCE §7- Marker Command Engine v2.3.0" } } From 704ef5eadfc55185dea111f243f0209416b0ff9e Mon Sep 17 00:00:00 2001 From: IronCrest <234182831+asn44nb@users.noreply.github.com> Date: Sun, 24 May 2026 13:57:51 +0000 Subject: [PATCH 2/3] 2.3.0 --- .../functions/api/util/broadcast.mcfunction | 11 +++++----- data/mce/functions/api/util/help.mcfunction | 4 ++-- data/mce/functions/api/util/log.mcfunction | 9 ++++----- .../mce/functions/api/util/version.mcfunction | 6 +++--- data/mce/functions/core/load.mcfunction | 6 +++--- .../functions/core/log/show_iter.mcfunction | 16 +++++++-------- data/mce/functions/core/queue/tick.mcfunction | 12 ++++------- .../functions/core/schedule/add.mcfunction | 11 +++++----- .../core/schedule/fire_iter.mcfunction | 2 +- .../functions/core/schedule/iter.mcfunction | 14 ++++++------- .../functions/core/schedule/tick.mcfunction | 5 ++--- .../functions/core/text/batch/iter.mcfunction | 19 ++++++++++++++++++ .../core/text/dispatch/actionbar.mcfunction | 10 ++++++++++ .../core/text/dispatch/tellraw.mcfunction | 18 +++++++++++++++++ .../core/text/dispatch/title.mcfunction | 20 +++++++++++++++++++ data/mce/functions/tutorial/page4.mcfunction | 2 +- 16 files changed, 111 insertions(+), 54 deletions(-) create mode 100644 data/mce/functions/core/text/batch/iter.mcfunction create mode 100644 data/mce/functions/core/text/dispatch/actionbar.mcfunction create mode 100644 data/mce/functions/core/text/dispatch/tellraw.mcfunction create mode 100644 data/mce/functions/core/text/dispatch/title.mcfunction diff --git a/data/mce/functions/api/util/broadcast.mcfunction b/data/mce/functions/api/util/broadcast.mcfunction index 948677c..e33db31 100644 --- a/data/mce/functions/api/util/broadcast.mcfunction +++ b/data/mce/functions/api/util/broadcast.mcfunction @@ -2,7 +2,7 @@ # MCE version: 2.0.1 (extended) # # Sends a chat message to ALL online players from storage. -# Macro-free. Compatible with Minecraft 1.19.3+. +# Compatible with Minecraft 1.19.3+ # # Input: # mce:broadcast Msg — string, the message text (required) @@ -16,10 +16,9 @@ execute unless data storage mce:broadcast Msg run data modify storage mce:error Last set value "mce:broadcast Msg is not set — provide a message before calling broadcast" execute unless data storage mce:broadcast Msg run data modify storage mce:error Code set value "ERR_NO_MSG" execute unless data storage mce:broadcast Msg run function mce:core/error/raise -execute unless data storage mce:broadcast Msg run return 0 -execute if data storage mce:broadcast Prefix run tellraw @a ["",{"storage":"mce:broadcast","nbt":"Prefix","color":"gold"},{"text":" "},{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] -execute unless data storage mce:broadcast Prefix run tellraw @a [{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] +execute if data storage mce:broadcast Msg if data storage mce:broadcast Prefix run tellraw @a ["",{"storage":"mce:broadcast","nbt":"Prefix","color":"gold"},{"text":" "},{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] +execute if data storage mce:broadcast Msg unless data storage mce:broadcast Prefix run tellraw @a [{"storage":"mce:broadcast","nbt":"Msg","color":"white"}] -data remove storage mce:broadcast Prefix -data remove storage mce:broadcast Msg +execute if data storage mce:broadcast Msg run data remove storage mce:broadcast Prefix +execute if data storage mce:broadcast Msg run data remove storage mce:broadcast Msg diff --git a/data/mce/functions/api/util/help.mcfunction b/data/mce/functions/api/util/help.mcfunction index 61d3c21..b501f80 100644 --- a/data/mce/functions/api/util/help.mcfunction +++ b/data/mce/functions/api/util/help.mcfunction @@ -54,8 +54,8 @@ tellraw @s ["",{"text":" data modify storage mce:broadcast Msg set value \"\"","color":"white"}] -tellraw @s ["",{"text":" function mce:api/log/info (lvl 0)","color":"gray"}] -tellraw @s ["",{"text":" function mce:api/log/warn (lvl 1)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/log/info (lvl 0)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/log/warn (lvl 1)","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/error (lvl 2)","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/show","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/clear","color":"gray"}] diff --git a/data/mce/functions/api/util/log.mcfunction b/data/mce/functions/api/util/log.mcfunction index 31118fb..8a6f89d 100644 --- a/data/mce/functions/api/util/log.mcfunction +++ b/data/mce/functions/api/util/log.mcfunction @@ -6,7 +6,7 @@ # It will be removed in a future major version. # # Appends mce:cmd Command to the log as an INFO entry. -# Wraps mce:api/log/write internally. +# Compatible with Minecraft 1.19.3+ # # Usage (legacy): # data modify storage mce:cmd Command set value "some command" @@ -19,8 +19,7 @@ execute unless data storage mce:cmd Command run data modify storage mce:error Last set value "mce:cmd Command is not set — nothing to log" execute unless data storage mce:cmd Command run data modify storage mce:error Code set value "ERR_NO_CMD" execute unless data storage mce:cmd Command run function mce:core/error/raise -execute unless data storage mce:cmd Command run return 0 -data modify storage mce:log_write msg set from storage mce:cmd Command -data modify storage mce:log_write level set value "INFO" -function mce:api/log/write +execute if data storage mce:cmd Command run data modify storage mce:log_write msg set from storage mce:cmd Command +execute if data storage mce:cmd Command run data modify storage mce:log_write level set value "INFO" +execute if data storage mce:cmd Command run function mce:api/log/write diff --git a/data/mce/functions/api/util/version.mcfunction b/data/mce/functions/api/util/version.mcfunction index 0d70904..4c56794 100644 --- a/data/mce/functions/api/util/version.mcfunction +++ b/data/mce/functions/api/util/version.mcfunction @@ -1,13 +1,13 @@ # PUBLIC API — mce:api/util/version -# MCE version: 2.2.0 +# MCE version: 2.3.0 # # Writes the current MCE version to storage and prints it to the caller. # Output: mce:output Version.string — string ("2.0.1") -# mce:output Version.numeric — int (2000100, LanternLoad format) +# mce:output Version.numeric — int (2003000, LanternLoad format) # # Usage: # function mce:api/util/version -data modify storage mce:output Version.string set value "2.2.0" +data modify storage mce:output Version.string set value "2.3.0" execute store result storage mce:output Version.numeric int 1 run scoreboard players get #mce load.status tellraw @s ["",{"text":"[MCE] ","color":"aqua"},{"text":"Version: ","color":"white"},{"storage":"mce:output","nbt":"Version.string","color":"gold"}] diff --git a/data/mce/functions/core/load.mcfunction b/data/mce/functions/core/load.mcfunction index 7e49418..258631d 100644 --- a/data/mce/functions/core/load.mcfunction +++ b/data/mce/functions/core/load.mcfunction @@ -26,7 +26,7 @@ data modify storage mce:error Count set value 0 execute unless data storage mce:config {mce:{debug:1b}} run data modify storage mce:config mce.debug set value 0b # mce.version: human-readable version string (set on every load) -data modify storage mce:config mce.version set value "2.2.0" +data modify storage mce:config mce.version set value "2.3.0" # mce.queue_interval: ticks between queue executions (read-only reference, hardcoded in core/queue/tick) data modify storage mce:config mce.queue_interval set value 3 @@ -40,6 +40,6 @@ execute unless data storage mce:config api.announce_default_preset run data modi # --- LanternLoad: advertise MCE version --- # v2.2.0 -> 2002000 -scoreboard players set #mce load.status 2002000 +scoreboard players set #mce load.status 2003000 -tellraw @a ["",{"text":"[MCE] ","color":"aqua"},{"text":"Marker Command Engine v2.2.0 loaded!","color":"white"}] +tellraw @a ["",{"text":"[MCE] ","color":"aqua"},{"text":"Marker Command Engine v2.3.0 loaded!","color":"white"}] diff --git a/data/mce/functions/core/log/show_iter.mcfunction b/data/mce/functions/core/log/show_iter.mcfunction index 4e531b3..f2b6314 100644 --- a/data/mce/functions/core/log/show_iter.mcfunction +++ b/data/mce/functions/core/log/show_iter.mcfunction @@ -3,14 +3,14 @@ # Branches on entries[0].lvl score: 0=INFO 1=WARN 2=ERROR # Compatible with Minecraft 1.19.3+. -execute unless data storage mce:log_iter entries[0] run return 0 +execute unless data storage mce:log_iter entries[0] run scoreboard players set #log.iter.done mce.log 1 +execute if data storage mce:log_iter entries[0] run scoreboard players set #log.iter.done mce.log 0 -# Read lvl of first entry into score -execute store result score #log.lvl mce.log run data get storage mce:log_iter entries[0].lvl +execute if score #log.iter.done mce.log matches 0 run execute store result score #log.lvl mce.log run data get storage mce:log_iter entries[0].lvl -execute if score #log.lvl mce.log matches 0 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[INFO] ","color":"white"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"white"}] -execute if score #log.lvl mce.log matches 1 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[WARN] ","color":"yellow"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"yellow"}] -execute if score #log.lvl mce.log matches 2 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[ERROR] ","color":"red"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"red"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 0 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[INFO] ","color":"white"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"white"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 1 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[WARN] ","color":"yellow"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"yellow"}] +execute if score #log.iter.done mce.log matches 0 if score #log.lvl mce.log matches 2 run tellraw @s ["",{"text":"[","color":"dark_gray"},{"storage":"mce:log_iter","nbt":"entries[0].n","color":"dark_gray"},{"text":"] ","color":"dark_gray"},{"text":"[ERROR] ","color":"red"},{"storage":"mce:log_iter","nbt":"entries[0].msg","color":"red"}] -data remove storage mce:log_iter entries[0] -function mce:core/log/show_iter +execute if score #log.iter.done mce.log matches 0 run data remove storage mce:log_iter entries[0] +execute if score #log.iter.done mce.log matches 0 run function mce:core/log/show_iter diff --git a/data/mce/functions/core/queue/tick.mcfunction b/data/mce/functions/core/queue/tick.mcfunction index 992d128..39dd6ae 100644 --- a/data/mce/functions/core/queue/tick.mcfunction +++ b/data/mce/functions/core/queue/tick.mcfunction @@ -1,13 +1,9 @@ # Private: not part of MCE public API — subject to change without notice execute store result score #mce.size mce.queue run data get storage mce:queue commands -execute if score #mce.size mce.queue matches 0 run return 0 -execute unless data storage mce:queue commands[0] run return 0 +execute if score #mce.size mce.queue matches 1.. if data storage mce:queue commands[0] run data modify storage mce:cmd Command set from storage mce:queue commands[0] +execute if score #mce.size mce.queue matches 1.. if data storage mce:queue commands[0] run data remove storage mce:queue commands[0] +execute if score #mce.size mce.queue matches 1.. if data storage mce:cmd Command run function mce:core/run/cmd -data modify storage mce:cmd Command set from storage mce:queue commands[0] -data remove storage mce:queue commands[0] - -function mce:core/run/cmd - -execute store result score #mce.size mce.queue run data get storage mce:queue commands +execute if score #mce.size mce.queue matches 1.. run execute store result score #mce.size mce.queue run data get storage mce:queue commands execute if score #mce.size mce.queue matches 1.. run schedule function mce:core/queue/tick 3t replace diff --git a/data/mce/functions/core/schedule/add.mcfunction b/data/mce/functions/core/schedule/add.mcfunction index 1435c3c..5e4545e 100644 --- a/data/mce/functions/core/schedule/add.mcfunction +++ b/data/mce/functions/core/schedule/add.mcfunction @@ -2,10 +2,9 @@ # Guard: require Delay >= 1 execute store result score #sched.delay mce.tick run data get storage mce:cmd Delay -execute if score #sched.delay mce.tick matches ..0 run return 1 -data modify storage mce:schedule jobs append value {cmd:"",ticks:0} -data modify storage mce:schedule jobs[-1].cmd set from storage mce:cmd Command -data modify storage mce:schedule jobs[-1].ticks set from storage mce:cmd Delay -data remove storage mce:cmd Command -data remove storage mce:cmd Delay +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs append value {cmd:"",ticks:0} +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs[-1].cmd set from storage mce:cmd Command +execute if score #sched.delay mce.tick matches 1.. run data modify storage mce:schedule jobs[-1].ticks set from storage mce:cmd Delay +execute if score #sched.delay mce.tick matches 1.. run data remove storage mce:cmd Command +execute if score #sched.delay mce.tick matches 1.. run data remove storage mce:cmd Delay diff --git a/data/mce/functions/core/schedule/fire_iter.mcfunction b/data/mce/functions/core/schedule/fire_iter.mcfunction index 59c7883..4d1e00a 100644 --- a/data/mce/functions/core/schedule/fire_iter.mcfunction +++ b/data/mce/functions/core/schedule/fire_iter.mcfunction @@ -3,4 +3,4 @@ data modify storage mce:cmd Command set from storage mce:schedule jobs[0].cmd function mce:core/run/setup_marker function mce:core/run/cmd -data remove storage mce:schedule jobs[0] \ No newline at end of file +data remove storage mce:schedule jobs[0] diff --git a/data/mce/functions/core/schedule/iter.mcfunction b/data/mce/functions/core/schedule/iter.mcfunction index 4115a2a..22e48c1 100644 --- a/data/mce/functions/core/schedule/iter.mcfunction +++ b/data/mce/functions/core/schedule/iter.mcfunction @@ -1,11 +1,9 @@ # Private: not part of MCE public API — subject to change without notice -execute if score #sched.size mce.tick matches ..0 run return 0 +execute if score #sched.size mce.tick matches 1.. run execute store result score #sched.ticks mce.tick run data get storage mce:schedule jobs[0].ticks +execute if score #sched.size mce.tick matches 1.. run scoreboard players remove #sched.ticks mce.tick 1 -execute store result score #sched.ticks mce.tick run data get storage mce:schedule jobs[0].ticks -scoreboard players remove #sched.ticks mce.tick 1 +execute if score #sched.size mce.tick matches 1.. if score #sched.ticks mce.tick matches ..0 run function mce:core/schedule/fire_iter +execute if score #sched.size mce.tick matches 1.. if score #sched.ticks mce.tick matches 1.. run function mce:core/schedule/defer_iter -execute if score #sched.ticks mce.tick matches ..0 run function mce:core/schedule/fire_iter -execute if score #sched.ticks mce.tick matches 1.. run function mce:core/schedule/defer_iter - -scoreboard players remove #sched.size mce.tick 1 -function mce:core/schedule/iter +execute if score #sched.size mce.tick matches 1.. run scoreboard players remove #sched.size mce.tick 1 +execute if score #sched.size mce.tick matches 1.. run function mce:core/schedule/iter diff --git a/data/mce/functions/core/schedule/tick.mcfunction b/data/mce/functions/core/schedule/tick.mcfunction index fd3694e..bb5c945 100644 --- a/data/mce/functions/core/schedule/tick.mcfunction +++ b/data/mce/functions/core/schedule/tick.mcfunction @@ -1,4 +1,3 @@ # Private: not part of MCE public API — subject to change without notice -execute unless data storage mce:schedule jobs[0] run return 0 -execute store result score #sched.size mce.tick run data get storage mce:schedule jobs -function mce:core/schedule/iter +execute if data storage mce:schedule jobs[0] run execute store result score #sched.size mce.tick run data get storage mce:schedule jobs +execute if data storage mce:schedule jobs[0] run function mce:core/schedule/iter diff --git a/data/mce/functions/core/text/batch/iter.mcfunction b/data/mce/functions/core/text/batch/iter.mcfunction new file mode 100644 index 0000000..db860e8 --- /dev/null +++ b/data/mce/functions/core/text/batch/iter.mcfunction @@ -0,0 +1,19 @@ +# Private: not part of MCE public API — subject to change without notice +# Iterates mce:text_batch entries[0], dispatches by type, removes entry, recurses. +# Compatible with Minecraft 1.19.3+ + +execute unless data storage mce:text_batch entries[0] run scoreboard players set #text.iter.done mce.tick 1 +execute if data storage mce:text_batch entries[0] run scoreboard players set #text.iter.done mce.tick 0 + +# Copy current entry to scratch storage for dispatch functions +execute if score #text.iter.done mce.tick matches 0 run data modify storage mce:text_dispatch entry set from storage mce:text_batch entries[0] + +# Dispatch based on type +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"tellraw"}} run function mce:core/text/dispatch/tellraw +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"title"}} run function mce:core/text/dispatch/title +execute if score #text.iter.done mce.tick matches 0 if data storage mce:text_dispatch {entry:{type:"actionbar"}} run function mce:core/text/dispatch/actionbar + +# Cleanup scratch and advance +execute if score #text.iter.done mce.tick matches 0 run data remove storage mce:text_dispatch entry +execute if score #text.iter.done mce.tick matches 0 run data remove storage mce:text_batch entries[0] +execute if score #text.iter.done mce.tick matches 0 run function mce:core/text/batch/iter diff --git a/data/mce/functions/core/text/dispatch/actionbar.mcfunction b/data/mce/functions/core/text/dispatch/actionbar.mcfunction new file mode 100644 index 0000000..4990e51 --- /dev/null +++ b/data/mce/functions/core/text/dispatch/actionbar.mcfunction @@ -0,0 +1,10 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches an "actionbar" entry from mce:text_dispatch entry. +# Fields: target (required), msg (required) +# Compatible with Minecraft 1.19.3+ + +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Last set value "text/batch entry type=actionbar is missing field: msg" +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Code set value "ERR_TEXT_NO_MSG" +execute unless data storage mce:text_dispatch entry.msg run function mce:core/error/raise + +execute if data storage mce:text_dispatch entry.msg run title @a actionbar {"storage":"mce:text_dispatch","nbt":"entry.msg","interpret":false} diff --git a/data/mce/functions/core/text/dispatch/tellraw.mcfunction b/data/mce/functions/core/text/dispatch/tellraw.mcfunction new file mode 100644 index 0000000..2e1201b --- /dev/null +++ b/data/mce/functions/core/text/dispatch/tellraw.mcfunction @@ -0,0 +1,18 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches a "tellraw" entry from mce:text_dispatch entry. +# Fields: target (required), msg (required), prefix (optional) +# Compatible with Minecraft 1.19.3+ + +# Guard: skip if msg or target missing +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Last set value "text/batch entry type=tellraw is missing field: msg" +execute unless data storage mce:text_dispatch entry.msg run data modify storage mce:error Code set value "ERR_TEXT_NO_MSG" +execute unless data storage mce:text_dispatch entry.msg run function mce:core/error/raise +execute unless data storage mce:text_dispatch entry.target run data modify storage mce:error Last set value "text/batch entry type=tellraw is missing field: target" +execute unless data storage mce:text_dispatch entry.target run data modify storage mce:error Code set value "ERR_TEXT_NO_TARGET" +execute unless data storage mce:text_dispatch entry.target run function mce:core/error/raise + +# With prefix — tellraw supports inline NBT from storage; target is read via @a selector embedded in command. +# Because target is dynamic we use the marker command engine itself to dispatch. +# Fallback: send to @a (safest macro-free approach — target field is advisory for external callers) +execute if data storage mce:text_dispatch entry.msg if data storage mce:text_dispatch entry.prefix run tellraw @a ["",{"storage":"mce:text_dispatch","nbt":"entry.prefix","color":"gold"},{"text":" "},{"storage":"mce:text_dispatch","nbt":"entry.msg","color":"white"}] +execute if data storage mce:text_dispatch entry.msg unless data storage mce:text_dispatch entry.prefix run tellraw @a [{"storage":"mce:text_dispatch","nbt":"entry.msg","color":"white"}] diff --git a/data/mce/functions/core/text/dispatch/title.mcfunction b/data/mce/functions/core/text/dispatch/title.mcfunction new file mode 100644 index 0000000..0977b2b --- /dev/null +++ b/data/mce/functions/core/text/dispatch/title.mcfunction @@ -0,0 +1,20 @@ +# Private: not part of MCE public API — subject to change without notice +# Dispatches a "title" entry from mce:text_dispatch entry. +# Fields: target (required), title (optional), subtitle (optional), preset (optional) +# Compatible with Minecraft 1.19.3+ + +# At least one of title or subtitle must be present +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run data modify storage mce:error Last set value "text/batch entry type=title requires at least one of: title, subtitle" +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run data modify storage mce:error Code set value "ERR_TEXT_NO_TITLE" +execute unless data storage mce:text_dispatch entry.title unless data storage mce:text_dispatch entry.subtitle run function mce:core/error/raise + +# Apply timing preset (mirrors announce_times logic) +# preset defaults to "normal" if absent +execute if data storage mce:text_dispatch {entry:{preset:"fast"}} run title @a times 5 30 5 +execute if data storage mce:text_dispatch {entry:{preset:"slow"}} run title @a times 20 100 20 +execute if data storage mce:text_dispatch {entry:{preset:"instant"}} run title @a times 0 40 0 +execute unless data storage mce:text_dispatch {entry:{preset:"fast"}} unless data storage mce:text_dispatch {entry:{preset:"slow"}} unless data storage mce:text_dispatch {entry:{preset:"instant"}} run title @a times 10 70 20 + +# Send title / subtitle if present +execute if data storage mce:text_dispatch entry.title run title @a title {"storage":"mce:text_dispatch","nbt":"entry.title","interpret":false} +execute if data storage mce:text_dispatch entry.subtitle run title @a subtitle {"storage":"mce:text_dispatch","nbt":"entry.subtitle","interpret":false} diff --git a/data/mce/functions/tutorial/page4.mcfunction b/data/mce/functions/tutorial/page4.mcfunction index 7bfc1a6..079dae9 100644 --- a/data/mce/functions/tutorial/page4.mcfunction +++ b/data/mce/functions/tutorial/page4.mcfunction @@ -1 +1 @@ -tellraw @s [{"text":"Page 4: Schedule, Cooldown, GitHub\n\n","color":"gold","bold":true},{"text":"[Set Delay Cmd] ","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cmd Command set value \"say Delayed!\""}},{"text":"[Set 40 Ticks]\n","color":"dark_red","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cmd Delay set value 40"}},{"text":"[Schedule Run] ","color":"yellow","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/schedule/run"}},{"text":"[Cooldown Set] ","color":"light_purple","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cd Ticks set value 100"}},{"text":"[Apply]\n","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/set"}},{"text":"[Cooldown Get] ","color":"blue","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/get"}},{"text":"[Cooldown Clear]\n","color":"dark_purple","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/clear"}},{"text":"[Open Repository]","color":"aqua","bold":true,"underlined":true,"clickEvent":{"action":"open_url","value":"https://github.com/runtoolkit/marker-command-engine/tree/main"}},{"text":" ","color":"white"},{"text":"[Open License]","color":"gray","underlined":true,"clickEvent":{"action":"open_url","value":"https://github.com/runtoolkit/marker-command-engine/blob/main/LICENSE"}},{"text":"\n\n[◀ Prev]","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:tutorial/page3"}}] +tellraw @s [{"text":"Page 4: Schedule, Cooldown, GitHub\n\n","color":"gold","bold":true},{"text":"[Set Delay Cmd] ","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cmd Command set value \"say Delayed!\""}},{"text":"[Set 40 Ticks]\n","color":"dark_red","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cmd Delay set value 40"}},{"text":"[Schedule Run] ","color":"yellow","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/schedule/run"}},{"text":"[Cooldown Set] ","color":"light_purple","bold":true,"clickEvent":{"action":"run_command","value":"/data modify storage mce:cd Ticks set value 100"}},{"text":"[Apply]\n","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/set"}},{"text":"[Cooldown Get] ","color":"blue","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/get"}},{"text":"[Cooldown Clear]\n","color":"dark_purple","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:api/cooldown/clear"}},{"text":"[Open Repository]","color":"aqua","bold":true,"underlined":true,"clickEvent":{"action":"open_url","value":"https://github.com/runtoolkit/marker-command-engine/tree/main"}},{"text":" ","color":"white"},{"text":"[Open License]","color":"gray","underlined":true,"clickEvent":{"action":"open_url","value":"https://github.com/runtoolkit/marker-command-engine/blob/main/LICENSE"}},{"text":"\n\n[◀ Prev]","color":"red","bold":true,"clickEvent":{"action":"run_command","value":"/function mce:tutorial/page3"}}] From 36fd9a6990ad3817ce8f9f89cad7ecc845bbdfe9 Mon Sep 17 00:00:00 2001 From: IronCrest <234182831+asn44nb@users.noreply.github.com> Date: Sun, 24 May 2026 13:58:15 +0000 Subject: [PATCH 3/3] 2.3.0 --- data/mce/tags/function/api/text/batch/clear.json | 1 + data/mce/tags/function/api/text/batch/run.json | 1 + data/mce/tags/functions/api/text/batch/clear.json | 1 + data/mce/tags/functions/api/text/batch/run.json | 1 + 4 files changed, 4 insertions(+) create mode 100644 data/mce/tags/function/api/text/batch/clear.json create mode 100644 data/mce/tags/function/api/text/batch/run.json create mode 100644 data/mce/tags/functions/api/text/batch/clear.json create mode 100644 data/mce/tags/functions/api/text/batch/run.json diff --git a/data/mce/tags/function/api/text/batch/clear.json b/data/mce/tags/function/api/text/batch/clear.json new file mode 100644 index 0000000..f68752b --- /dev/null +++ b/data/mce/tags/function/api/text/batch/clear.json @@ -0,0 +1 @@ +{ "values": ["mce:api/text/batch/clear"] } diff --git a/data/mce/tags/function/api/text/batch/run.json b/data/mce/tags/function/api/text/batch/run.json new file mode 100644 index 0000000..249b951 --- /dev/null +++ b/data/mce/tags/function/api/text/batch/run.json @@ -0,0 +1 @@ +{ "values": ["mce:api/text/batch/run"] } diff --git a/data/mce/tags/functions/api/text/batch/clear.json b/data/mce/tags/functions/api/text/batch/clear.json new file mode 100644 index 0000000..f68752b --- /dev/null +++ b/data/mce/tags/functions/api/text/batch/clear.json @@ -0,0 +1 @@ +{ "values": ["mce:api/text/batch/clear"] } diff --git a/data/mce/tags/functions/api/text/batch/run.json b/data/mce/tags/functions/api/text/batch/run.json new file mode 100644 index 0000000..249b951 --- /dev/null +++ b/data/mce/tags/functions/api/text/batch/run.json @@ -0,0 +1 @@ +{ "values": ["mce:api/text/batch/run"] }