diff --git a/.gitignore b/.gitignore index 85daa02..f24b58d 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,14 @@ rad.json *.bclicense *.flf #Test results file -TestResults.xml \ No newline at end of file +TestResults.xml + +# Cache +usercache.json + +# Minecraft +./ +saves/ +ops.json +whitelist.json +world/data/*.dat \ No newline at end of file diff --git a/data/mce/functions/api/cooldown/add.mcfunction b/data/mce/functions/api/cooldown/add.mcfunction new file mode 100644 index 0000000..da69a35 --- /dev/null +++ b/data/mce/functions/api/cooldown/add.mcfunction @@ -0,0 +1,22 @@ +# PUBLIC API — mce:api/cooldown/add +# MCE version: 1.1.0 (extended) +# +# Adds ticks to the executor's (@s) existing cooldown instead of overwriting it. +# Unlike cooldown/set, this stacks on top of any remaining cooldown. +# If @s has no active cooldown, this behaves like cooldown/set. +# Compatible with Minecraft 1.19.3+ +# +# Input: +# mce:cd Ticks — int, number of ticks to add (20 = 1 second) +# +# Usage: +# data modify storage mce:cd Ticks set value 40 +# function mce:api/cooldown/add + +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/add" +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 if data storage mce:cd Ticks run execute store result score #cd.add mce.cd run data get storage mce:cd Ticks +execute if data storage mce:cd Ticks run scoreboard players operation @s mce.cd += #cd.add mce.cd +execute if data storage mce:cd Ticks run data remove storage mce:cd Ticks diff --git a/data/mce/functions/api/log/count.mcfunction b/data/mce/functions/api/log/count.mcfunction new file mode 100644 index 0000000..3acc209 --- /dev/null +++ b/data/mce/functions/api/log/count.mcfunction @@ -0,0 +1,12 @@ +# PUBLIC API — mce:api/log/count +# MCE version: 2.2.0 +# +# Reads the current number of entries stored in the in-memory log. +# Output: mce:output Log.count (int, number of entries currently held; max 64) +# Macro-free. Compatible with Minecraft 1.19.3+ +# +# Usage: +# function mce:api/log/count +# data get storage mce:output Log.count + +execute store result storage mce:output Log.count int 1 run data get storage mce:log entries diff --git a/data/mce/functions/api/util/help.mcfunction b/data/mce/functions/api/util/help.mcfunction index b501f80..37b538c 100644 --- a/data/mce/functions/api/util/help.mcfunction +++ b/data/mce/functions/api/util/help.mcfunction @@ -48,6 +48,7 @@ tellraw @s ["",{"text":" function mce:api/util/cancel","color":"gray"}] tellraw @s ["",{"text":" function mce:api/util/debug_toggle","color":"gray"}] tellraw @s ["",{"text":" function mce:api/util/log_clear","color":"gray"}] tellraw @s ["",{"text":" function mce:api/util/error_clear","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/util/ping (health-check, prints load status)","color":"gray"}] tellraw @s ["",{"text":"--- Broadcast ---","color":"yellow"}] tellraw @s ["",{"text":" data modify storage mce:broadcast Prefix set value \"[Tag]\"","color":"white"}] tellraw @s ["",{"text":" data modify storage mce:broadcast Msg set value \"\"","color":"white"}] @@ -58,7 +59,13 @@ 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/count (writes entry count to mce:output Log.count)","color":"gray"}] tellraw @s ["",{"text":" function mce:api/log/clear","color":"gray"}] +tellraw @s ["",{"text":"--- Cooldown ---","color":"yellow"}] +tellraw @s ["",{"text":" data modify storage mce:cd Ticks set value ","color":"white"}] +tellraw @s ["",{"text":" function mce:api/cooldown/set (overwrite)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/cooldown/add (stack on remaining cooldown)","color":"gray"}] +tellraw @s ["",{"text":" function mce:api/cooldown/get / check / clear","color":"gray"}] tellraw @s ["",{"text":"--- Error Handling ---","color":"yellow"}] tellraw @s ["",{"text":" data get storage mce:error Last","color":"white"}] tellraw @s ["",{"text":" data get storage mce:error Code","color":"white"}] diff --git a/data/mce/functions/api/util/ping.mcfunction b/data/mce/functions/api/util/ping.mcfunction new file mode 100644 index 0000000..483ad75 --- /dev/null +++ b/data/mce/functions/api/util/ping.mcfunction @@ -0,0 +1,23 @@ +# PUBLIC API — mce:api/util/ping +# MCE version: 2.3.0 (extended) +# +# Health-check: confirms MCE is loaded and its scoreboard objectives respond, +# and reports the current internal error count alongside the version string. +# Useful for server-side monitoring or startup verification scripts. +# Output: +# mce:output Ping.ok — 1b if load status score exists and is >= 1, else 0b +# mce:output Ping.errors — int, current value of mce:error Count +# Compatible with Minecraft 1.19.3+ +# +# Usage: +# function mce:api/util/ping +# data get storage mce:output Ping.ok + +data modify storage mce:output Ping.ok set value 0b +execute if score #mce load.status matches 1.. run data modify storage mce:output Ping.ok set value 1b + +execute unless data storage mce:error Count run data modify storage mce:output Ping.errors set value 0 +execute if data storage mce:error Count run data modify storage mce:output Ping.errors set from storage mce:error Count + +execute if data storage mce:output {Ping:{ok:1b}} run tellraw @s ["",{"text":"[MCE/ping] ","color":"aqua"},{"text":"OK — engine loaded, ","color":"green"},{"storage":"mce:output","nbt":"Ping.errors","color":"yellow"},{"text":" error(s) logged.","color":"green"}] +execute unless data storage mce:output {Ping:{ok:1b}} run tellraw @s ["",{"text":"[MCE/ping] ","color":"aqua"},{"text":"FAIL — engine not loaded (load.status missing or 0).","color":"red"}] diff --git a/data/mce/functions/core/lib/math/clamp_calc.mcfunction b/data/mce/functions/core/lib/math/clamp_calc.mcfunction new file mode 100644 index 0000000..a1a6afa --- /dev/null +++ b/data/mce/functions/core/lib/math/clamp_calc.mcfunction @@ -0,0 +1,11 @@ +# Private: not part of MCE public API — subject to change without notice + +execute store result score #math.val mce.log run data get storage mce:lib_math Value +execute store result score #math.min mce.log run data get storage mce:lib_math Min +execute store result score #math.max mce.log run data get storage mce:lib_math Max + +scoreboard players operation #math.result mce.log = #math.val mce.log +execute if score #math.result mce.log < #math.min mce.log run scoreboard players operation #math.result mce.log = #math.min mce.log +execute if score #math.result mce.log > #math.max mce.log run scoreboard players operation #math.result mce.log = #math.max mce.log + +execute store result storage mce:output Math.Clamp.result int 1 run scoreboard players get #math.result mce.log diff --git a/data/mce/functions/core/lib/math/max_calc.mcfunction b/data/mce/functions/core/lib/math/max_calc.mcfunction new file mode 100644 index 0000000..a6d9642 --- /dev/null +++ b/data/mce/functions/core/lib/math/max_calc.mcfunction @@ -0,0 +1,9 @@ +# Private: not part of MCE public API — subject to change without notice + +execute store result score #math.a mce.log run data get storage mce:lib_math A +execute store result score #math.b mce.log run data get storage mce:lib_math B + +scoreboard players operation #math.result mce.log = #math.a mce.log +execute if score #math.b mce.log > #math.result mce.log run scoreboard players operation #math.result mce.log = #math.b mce.log + +execute store result storage mce:output Math.Max.result int 1 run scoreboard players get #math.result mce.log diff --git a/data/mce/functions/core/lib/math/min_calc.mcfunction b/data/mce/functions/core/lib/math/min_calc.mcfunction new file mode 100644 index 0000000..56bdf5c --- /dev/null +++ b/data/mce/functions/core/lib/math/min_calc.mcfunction @@ -0,0 +1,9 @@ +# Private: not part of MCE public API — subject to change without notice + +execute store result score #math.a mce.log run data get storage mce:lib_math A +execute store result score #math.b mce.log run data get storage mce:lib_math B + +scoreboard players operation #math.result mce.log = #math.a mce.log +execute if score #math.b mce.log < #math.result mce.log run scoreboard players operation #math.result mce.log = #math.b mce.log + +execute store result storage mce:output Math.Min.result int 1 run scoreboard players get #math.result mce.log diff --git a/data/mce/functions/lib/list/is_empty.mcfunction b/data/mce/functions/lib/list/is_empty.mcfunction new file mode 100644 index 0000000..6518ac6 --- /dev/null +++ b/data/mce/functions/lib/list/is_empty.mcfunction @@ -0,0 +1,23 @@ +# PUBLIC API — mce:lib/list/is_empty +# MCE version: 2.4.0 (lib) +# +# Checks whether a list has zero elements (or the key is missing). +# No macros used. Compatible with Minecraft 1.20.1+. +# Internally reuses lib/list/length. +# +# Input: +# mce:lib_list Values — list (required; may be empty []) +# +# Output: +# mce:output List.IsEmpty.result — 1b if Values has 0 elements (or is missing), else 0b +# +# Usage: +# data modify storage mce:lib_list Values set value [] +# function mce:lib/list/is_empty +# data get storage mce:output List.IsEmpty.result + +data modify storage mce:output List.Length.result set value 0 +execute if data storage mce:lib_list Values store result storage mce:output List.Length.result int 1 run data get storage mce:lib_list Values + +data modify storage mce:output List.IsEmpty.result set value 0b +execute if data storage mce:output{List:{Length:{result:0}}} run data modify storage mce:output List.IsEmpty.result set value 1b diff --git a/data/mce/functions/lib/list/length.mcfunction b/data/mce/functions/lib/list/length.mcfunction new file mode 100644 index 0000000..9cb88f1 --- /dev/null +++ b/data/mce/functions/lib/list/length.mcfunction @@ -0,0 +1,25 @@ +# PUBLIC API — mce:lib/list/length +# MCE version: 2.4.0 (lib) +# +# Returns the number of elements in a list. No macros used. Uses the +# well-known vanilla trick: `execute store result` on a `data get` of a +# list stores its element count (not its NBT byte size) into a score. +# Compatible with Minecraft 1.20.1+. +# +# Input: +# mce:lib_list Values — list (required; may be empty []) +# +# Output: +# mce:output List.Length.result — int, number of elements +# +# Usage: +# data modify storage mce:lib_list Values set value ["a","b","c"] +# function mce:lib/list/length +# data get storage mce:output List.Length.result + +execute unless data storage mce:lib_list Values run data modify storage mce:error Last set value "mce:lib_list Values is not set — provide a list before calling lib/list/length" +execute unless data storage mce:lib_list Values run data modify storage mce:error Code set value "ERR_NO_VALUES" +execute unless data storage mce:lib_list Values run function mce:core/error/raise + +data modify storage mce:output List.Length.result set value 0 +execute if data storage mce:lib_list Values store result storage mce:output List.Length.result int 1 run data get storage mce:lib_list Values diff --git a/data/mce/functions/lib/math/clamp.mcfunction b/data/mce/functions/lib/math/clamp.mcfunction new file mode 100644 index 0000000..924a8a8 --- /dev/null +++ b/data/mce/functions/lib/math/clamp.mcfunction @@ -0,0 +1,35 @@ +# PUBLIC API — mce:lib/math/clamp +# MCE version: 2.4.0 (lib) +# +# Clamps an integer between Min and Max (inclusive) using pure scoreboard +# comparisons. No macros used. Compatible with Minecraft 1.20.1+ (and much +# earlier — scoreboard math predates macros entirely). +# +# Input: +# mce:lib_math Value — int (required) +# mce:lib_math Min — int (required) +# mce:lib_math Max — int (required, must be >= Min) +# +# Output: +# mce:output Math.Clamp.result — int, Value clamped into [Min, Max] +# +# Usage: +# data modify storage mce:lib_math Value set value 150 +# data modify storage mce:lib_math Min set value 0 +# data modify storage mce:lib_math Max set value 100 +# function mce:lib/math/clamp +# data get storage mce:output Math.Clamp.result + +execute unless data storage mce:lib_math Value run data modify storage mce:error Last set value "mce:lib_math Value is not set — provide an int before calling lib/math/clamp" +execute unless data storage mce:lib_math Value run data modify storage mce:error Code set value "ERR_NO_VALUE" +execute unless data storage mce:lib_math Value run function mce:core/error/raise + +execute unless data storage mce:lib_math Min run data modify storage mce:error Last set value "mce:lib_math Min is not set — provide an int before calling lib/math/clamp" +execute unless data storage mce:lib_math Min run data modify storage mce:error Code set value "ERR_NO_MIN" +execute unless data storage mce:lib_math Min run function mce:core/error/raise + +execute unless data storage mce:lib_math Max run data modify storage mce:error Last set value "mce:lib_math Max is not set — provide an int before calling lib/math/clamp" +execute unless data storage mce:lib_math Max run data modify storage mce:error Code set value "ERR_NO_MAX" +execute unless data storage mce:lib_math Max run function mce:core/error/raise + +execute if data storage mce:lib_math Value if data storage mce:lib_math Min if data storage mce:lib_math Max run function mce:core/lib/math/clamp_calc diff --git a/data/mce/functions/lib/math/max.mcfunction b/data/mce/functions/lib/math/max.mcfunction new file mode 100644 index 0000000..fa4fa2c --- /dev/null +++ b/data/mce/functions/lib/math/max.mcfunction @@ -0,0 +1,28 @@ +# PUBLIC API — mce:lib/math/max +# MCE version: 2.4.0 (lib) +# +# Returns the larger of A and B. No macros used. Compatible with +# Minecraft 1.20.1+. +# +# Input: +# mce:lib_math A — int (required) +# mce:lib_math B — int (required) +# +# Output: +# mce:output Math.Max.result — int, max(A, B) +# +# Usage: +# data modify storage mce:lib_math A set value 5 +# data modify storage mce:lib_math B set value 12 +# function mce:lib/math/max +# data get storage mce:output Math.Max.result + +execute unless data storage mce:lib_math A run data modify storage mce:error Last set value "mce:lib_math A is not set — provide an int before calling lib/math/max" +execute unless data storage mce:lib_math A run data modify storage mce:error Code set value "ERR_NO_A" +execute unless data storage mce:lib_math A run function mce:core/error/raise + +execute unless data storage mce:lib_math B run data modify storage mce:error Last set value "mce:lib_math B is not set — provide an int before calling lib/math/max" +execute unless data storage mce:lib_math B run data modify storage mce:error Code set value "ERR_NO_B" +execute unless data storage mce:lib_math B run function mce:core/error/raise + +execute if data storage mce:lib_math A if data storage mce:lib_math B run function mce:core/lib/math/max_calc diff --git a/data/mce/functions/lib/math/min.mcfunction b/data/mce/functions/lib/math/min.mcfunction new file mode 100644 index 0000000..6806e99 --- /dev/null +++ b/data/mce/functions/lib/math/min.mcfunction @@ -0,0 +1,28 @@ +# PUBLIC API — mce:lib/math/min +# MCE version: 2.4.0 (lib) +# +# Returns the smaller of A and B. No macros used. Compatible with +# Minecraft 1.20.1+. +# +# Input: +# mce:lib_math A — int (required) +# mce:lib_math B — int (required) +# +# Output: +# mce:output Math.Min.result — int, min(A, B) +# +# Usage: +# data modify storage mce:lib_math A set value 5 +# data modify storage mce:lib_math B set value 12 +# function mce:lib/math/min +# data get storage mce:output Math.Min.result + +execute unless data storage mce:lib_math A run data modify storage mce:error Last set value "mce:lib_math A is not set — provide an int before calling lib/math/min" +execute unless data storage mce:lib_math A run data modify storage mce:error Code set value "ERR_NO_A" +execute unless data storage mce:lib_math A run function mce:core/error/raise + +execute unless data storage mce:lib_math B run data modify storage mce:error Last set value "mce:lib_math B is not set — provide an int before calling lib/math/min" +execute unless data storage mce:lib_math B run data modify storage mce:error Code set value "ERR_NO_B" +execute unless data storage mce:lib_math B run function mce:core/error/raise + +execute if data storage mce:lib_math A if data storage mce:lib_math B run function mce:core/lib/math/min_calc diff --git a/data/mce/functions/lib/string/is_empty.mcfunction b/data/mce/functions/lib/string/is_empty.mcfunction new file mode 100644 index 0000000..2afeeac --- /dev/null +++ b/data/mce/functions/lib/string/is_empty.mcfunction @@ -0,0 +1,27 @@ +# PUBLIC API — mce:lib/string/is_empty +# MCE version: 2.4.0 (lib) +# +# Checks whether a string is exactly "" (empty). +# No macros used. Compatible with Minecraft 1.20.1+. +# +# Input: +# mce:lib_string Value — string (required key; value itself may be "") +# +# Output: +# mce:output String.IsEmpty.result — 1b if Value == "", else 0b +# mce:output String.IsEmpty.set — 1b if the Value key exists at all, else 0b +# +# Usage: +# data modify storage mce:lib_string Value set value "" +# function mce:lib/string/is_empty +# data get storage mce:output String.IsEmpty.result + +execute unless data storage mce:lib_string Value run data modify storage mce:error Last set value "mce:lib_string Value is not set — provide a (possibly empty) string before calling lib/string/is_empty" +execute unless data storage mce:lib_string Value run data modify storage mce:error Code set value "ERR_NO_VALUE" +execute unless data storage mce:lib_string Value run function mce:core/error/raise + +data modify storage mce:output String.IsEmpty.set set value 0b +execute if data storage mce:lib_string Value run data modify storage mce:output String.IsEmpty.set set value 1b + +data modify storage mce:output String.IsEmpty.result set value 0b +execute if data storage mce:lib_string{Value:""} run data modify storage mce:output String.IsEmpty.result set value 1b diff --git a/data/mce/tags/functions/api/cooldown/add.json b/data/mce/tags/functions/api/cooldown/add.json new file mode 100644 index 0000000..b043b10 --- /dev/null +++ b/data/mce/tags/functions/api/cooldown/add.json @@ -0,0 +1 @@ +{ "values": ["mce:api/cooldown/add"] } diff --git a/data/mce/tags/functions/api/log/count.json b/data/mce/tags/functions/api/log/count.json new file mode 100644 index 0000000..f92c2ad --- /dev/null +++ b/data/mce/tags/functions/api/log/count.json @@ -0,0 +1 @@ +{ "values": ["mce:api/log/count"] } diff --git a/data/mce/tags/functions/api/util/ping.json b/data/mce/tags/functions/api/util/ping.json new file mode 100644 index 0000000..69ff224 --- /dev/null +++ b/data/mce/tags/functions/api/util/ping.json @@ -0,0 +1 @@ +{ "values": ["mce:api/util/ping"] } diff --git a/data/mce/tags/functions/lib/list/is_empty.json b/data/mce/tags/functions/lib/list/is_empty.json new file mode 100644 index 0000000..5ecc241 --- /dev/null +++ b/data/mce/tags/functions/lib/list/is_empty.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/list/is_empty"] } diff --git a/data/mce/tags/functions/lib/list/length.json b/data/mce/tags/functions/lib/list/length.json new file mode 100644 index 0000000..a10981a --- /dev/null +++ b/data/mce/tags/functions/lib/list/length.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/list/length"] } diff --git a/data/mce/tags/functions/lib/math/clamp.json b/data/mce/tags/functions/lib/math/clamp.json new file mode 100644 index 0000000..092dcc1 --- /dev/null +++ b/data/mce/tags/functions/lib/math/clamp.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/math/clamp"] } diff --git a/data/mce/tags/functions/lib/math/max.json b/data/mce/tags/functions/lib/math/max.json new file mode 100644 index 0000000..49cdc43 --- /dev/null +++ b/data/mce/tags/functions/lib/math/max.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/math/max"] } diff --git a/data/mce/tags/functions/lib/math/min.json b/data/mce/tags/functions/lib/math/min.json new file mode 100644 index 0000000..e6a3a29 --- /dev/null +++ b/data/mce/tags/functions/lib/math/min.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/math/min"] } diff --git a/data/mce/tags/functions/lib/string/is_empty.json b/data/mce/tags/functions/lib/string/is_empty.json new file mode 100644 index 0000000..d189eea --- /dev/null +++ b/data/mce/tags/functions/lib/string/is_empty.json @@ -0,0 +1 @@ +{ "values": ["mce:lib/string/is_empty"] }