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
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ rad.json
*.bclicense
*.flf
#Test results file
TestResults.xml
TestResults.xml

# Cache
usercache.json

# Minecraft
./
saves/
ops.json
whitelist.json
world/data/*.dat
22 changes: 22 additions & 0 deletions data/mce/functions/api/cooldown/add.mcfunction
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions data/mce/functions/api/log/count.mcfunction
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions data/mce/functions/api/util/help.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -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 \"<text>\"","color":"white"}]
Expand All @@ -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 <ticks>","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"}]
Expand Down
23 changes: 23 additions & 0 deletions data/mce/functions/api/util/ping.mcfunction
Original file line number Diff line number Diff line change
@@ -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"}]
11 changes: 11 additions & 0 deletions data/mce/functions/core/lib/math/clamp_calc.mcfunction
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions data/mce/functions/core/lib/math/max_calc.mcfunction
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions data/mce/functions/core/lib/math/min_calc.mcfunction
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions data/mce/functions/lib/list/is_empty.mcfunction
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions data/mce/functions/lib/list/length.mcfunction
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions data/mce/functions/lib/math/clamp.mcfunction
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions data/mce/functions/lib/math/max.mcfunction
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions data/mce/functions/lib/math/min.mcfunction
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions data/mce/functions/lib/string/is_empty.mcfunction
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions data/mce/tags/functions/api/cooldown/add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:api/cooldown/add"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/api/log/count.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:api/log/count"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/api/util/ping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:api/util/ping"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/list/is_empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/list/is_empty"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/list/length.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/list/length"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/math/clamp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/math/clamp"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/math/max.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/math/max"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/math/min.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/math/min"] }
1 change: 1 addition & 0 deletions data/mce/tags/functions/lib/string/is_empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "values": ["mce:lib/string/is_empty"] }