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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions .github/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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` |

Expand Down Expand Up @@ -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...
```
Expand All @@ -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

Expand All @@ -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 |
Expand All @@ -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`) |
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions data/mce/function/api/batch/run.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# 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

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
14 changes: 7 additions & 7 deletions data/mce/function/api/cooldown/check.mcfunction
Original file line number Diff line number Diff line change
@@ -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 <player> if function mce:api/cooldown/check run ...
# execute as <player> 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
7 changes: 3 additions & 4 deletions data/mce/function/api/cooldown/set.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
11 changes: 5 additions & 6 deletions data/mce/function/api/log/show.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
# 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

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
27 changes: 13 additions & 14 deletions data/mce/function/api/log/write.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
7 changes: 4 additions & 3 deletions data/mce/function/api/queue/add.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
12 changes: 5 additions & 7 deletions data/mce/function/api/run/as.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
46 changes: 20 additions & 26 deletions data/mce/function/api/run/at.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading