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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Download on Modrinth](https://img.shields.io/badge/Download%20on-Modrinth-00AF5C?style=for-the-badge&logo=modrinth&logoColor=white)](https://modrinth.com/datapack/datalib)

---
> Current version: **v6.0.1**
> Current version: **v6.0.2**
---

> **This datapack is considered safe to use, but it is still actively receiving security improvements, bug fixes, and new features. Please keep it up to date.**
Expand Down Expand Up @@ -57,7 +57,7 @@ data modify storage datalib:engine global.loaded set value 1b
```
datalib:engine (persistent data)
├── global
│ ├── version: "v6.0.1"
│ ├── version: "v6.0.2"
│ ├── loaded: 1b
│ └── tick: <int>
├── players
Expand Down Expand Up @@ -89,7 +89,7 @@ Provides deterministic load order, version tracking, and pre/load/post-load hook
# Check if dataLib is loaded
execute if score #dataLib load.status matches 1.. run say dataLib is loaded

# Get version (major*10000 + minor*100 + patch → v6.0.1 = 601)
# Get version (major*10000 + minor*100 + patch → v6.0.2 = 601)
scoreboard players get dataLib load.status
```

Expand Down Expand Up @@ -128,4 +128,4 @@ function datalib:core/lib/string/replace

---

*dataLib v6.0.1 | MC Java 26.2 | Pure Datapack*
*dataLib v6.0.2 | MC Java 26.2 | Pure Datapack*
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ data modify storage stringlib:input replace.String set from storage datalib:inpu
data modify storage stringlib:input replace.Find set value " "
data modify storage stringlib:input replace.Replace set value "_"
function stringlib:util/replace
data modify storage datalib:input _gamerule_norm set from storage stringlib:output replace
data modify storage stringlib:input to_lowercase.String set from storage stringlib:output replace
data remove storage stringlib:input replace
function stringlib:util/to_lowercase/fast
data modify storage datalib:input _gamerule_norm set from storage stringlib:output to_lowercase

# Read from engine storage
data remove storage datalib:output gamerule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

execute unless function datalib:core/security/cmd_gate run return 0

# ── Normalize rule name: spaces → underscores via StringLib ──────────────────
# ── Normalize rule name: spaces → underscores, then lowercase ────────────────
data modify storage stringlib:input replace.String set from storage datalib:input rule
data modify storage stringlib:input replace.Find set value " "
data modify storage stringlib:input replace.Replace set value "_"
function stringlib:util/replace
data modify storage datalib:input _gamerule_norm set from storage stringlib:output replace
data modify storage stringlib:input to_lowercase.String set from storage stringlib:output replace
data remove storage stringlib:input replace
function stringlib:util/to_lowercase/fast
data modify storage datalib:input _gamerule_norm set from storage stringlib:output to_lowercase

# ── Persist value in engine storage ──────────────────────────────────────────
function datalib:core/internal/api/gamerule/persist with storage datalib:input {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
execute unless entity @s[tag=datalib.admin] run playsound datalib:perm.denied master @s ~ ~ ~ 1 1
execute unless entity @s[tag=datalib.admin] run return run tellraw @s ["",{"text":"\uE000","color":"#00AAAA"},{"text":" ","color":"#00AAAA"},{"text":"✘ ","color":"red"},{"translate":"datalib.msg.permission_denied","color":"red"}]
execute if entity @s unless entity @s[tag=datalib.admin] run playsound datalib:perm.denied master @s ~ ~ ~ 1 1
execute if entity @s unless entity @s[tag=datalib.admin] run return run tellraw @s ["",{"text":"\uE000","color":"#00AAAA"},{"text":" ","color":"#00AAAA"},{"text":"✘ ","color":"red"},{"translate":"datalib.msg.permission_denied","color":"red"}]

$data remove storage datalib:engine permissions.$(player).$(perm)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# datalib:core/lib/batch/internal/add_cmd [MACRO]
# INPUT: $(id), $(cmd)
# INPUT: $(id)cmd is NBT-copied from datalib:input, not macro-spliced
# Called with cmd field guaranteed.

$data modify storage datalib:engine batches.$(id).items append value {cmd:"$(cmd)"}
$data modify storage datalib:engine batches.$(id).items append value {cmd:""}
$data modify storage datalib:engine batches.$(id).items[-1].cmd set from storage datalib:input cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# datalib:core/lib/batch/internal/add_func [MACRO]
# INPUT: $(id), $(func)
# INPUT: $(id)func is NBT-copied from datalib:input, not macro-spliced
# Called with func field guaranteed.

$data modify storage datalib:engine batches.$(id).items append value {func:"$(func)"}
$data modify storage datalib:engine batches.$(id).items append value {func:""}
$data modify storage datalib:engine batches.$(id).items[-1].func set from storage datalib:input func
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# datalib:core/lib/batch/internal/flush_queue_cmd [MACRO]
# INPUT: $(cmd), $(delay) — from _bfl_cur; cmd field guaranteed.
# INPUT: $(delay) — cmd is NBT-copied from _bfl_cur, not macro-spliced

$data modify storage datalib:engine queue append value {cmd:"$(cmd)", delay:$(delay)}
$data modify storage datalib:engine queue append value {cmd:"", delay:$(delay)}
data modify storage datalib:engine queue[-1].cmd set from storage datalib:engine _bfl_cur.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# datalib:core/lib/batch/internal/flush_queue_func [MACRO]
# INPUT: $(func), $(delay) — _bfl_cur'dan; func field guaranteed.
# INPUT: $(delay) — func is NBT-copied from _bfl_cur, not macro-spliced

$data modify storage datalib:engine queue append value {func:"$(func)", delay:$(delay)}
$data modify storage datalib:engine queue append value {func:"", delay:$(delay)}
data modify storage datalib:engine queue[-1].func set from storage datalib:engine _bfl_cur.func
8 changes: 8 additions & 0 deletions datapacks/dataLib/data/datalib/predicate/is_freezing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"entity": "this",
"predicate": {
"nbt": "{FrozenTicks:1..}",
"entity_type": "minecraft:player"
},
"condition": "minecraft:entity_properties"
}
9 changes: 9 additions & 0 deletions datapacks/dataLib/data/datalib/predicate/is_invisible.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entity": "this",
"predicate": {
"flags": {
"is_invisible": true
}
},
"condition": "minecraft:entity_properties"
}
9 changes: 9 additions & 0 deletions datapacks/dataLib/data/datalib/predicate/is_swimming.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"entity": "this",
"predicate": {
"flags": {
"is_swimming": true
}
},
"condition": "minecraft:entity_properties"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scoreboard players set #dl.major dl.pre_version 6
scoreboard players set #dl.minor dl.pre_version 0
scoreboard players set #dl.patch dl.pre_version 1
scoreboard players set #dl.patch dl.pre_version 2
scoreboard players set #dl.pre dl.pre_version 0
scoreboard players set #dl.ver_set dl.pre_version 1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# dl_load:core/internal/load/version_warn
# Called when dl.pre_version scores don't match expected (v6.0.1).
# Called when dl.pre_version scores don't match expected (v6.0.2).
# Fires error sound + plain error message, load aborted.

playsound datalib:ui.error master @a ~ ~ ~ 0.7 0.8

tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"✘ ","color":"red"},{"text":"Version mismatch — expected ","color":"red"},{"text":"v6.0.1","color":"aqua"},{"text":". Load aborted.","color":"red"}]
tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"DEBUG ","color":"aqua"},{"text":"expected: v6.0.1 · got: ","color":"#555555"},{"score":{"name":"#dl.major","objective":"dl.pre_version"},"color":"yellow"},{"text":".","color":"#555555"},{"score":{"name":"#dl.minor","objective":"dl.pre_version"},"color":"yellow"},{"text":".","color":"#555555"},{"score":{"name":"#dl.patch","objective":"dl.pre_version"},"color":"yellow"}]
tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"✘ ","color":"red"},{"text":"Version mismatch — expected ","color":"red"},{"text":"v6.0.2","color":"aqua"},{"text":". Load aborted.","color":"red"}]
tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"DEBUG ","color":"aqua"},{"text":"expected: v6.0.2 · got: ","color":"#555555"},{"score":{"name":"#dl.major","objective":"dl.pre_version"},"color":"yellow"},{"text":".","color":"#555555"},{"score":{"name":"#dl.minor","objective":"dl.pre_version"},"color":"yellow"},{"text":".","color":"#555555"},{"score":{"name":"#dl.patch","objective":"dl.pre_version"},"color":"yellow"}]

data modify storage datalib:engine _log_error_tmp set value {message:"[Load] version_warn — version mismatch, load aborted"}
function datalib:systems/log/error with storage datalib:engine _log_error_tmp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tellraw @a ["",{"text":"❌ ","color":"red"},{"text":"[DL] ","color":"aqua","bold":true},{"text":"Version conflict! ","color":"red","bold":true},{"text":"Expected ","color":"gray"},{"text":"v6.0.1","color":"yellow","bold":true},{"text":" — stored scores do not match.","color":"gray"}]
tellraw @a ["",{"text":"❌ ","color":"red"},{"text":"[DL] ","color":"aqua","bold":true},{"text":"Version conflict! ","color":"red","bold":true},{"text":"Expected ","color":"gray"},{"text":"v6.0.2","color":"yellow","bold":true},{"text":" — stored scores do not match.","color":"gray"}]
tellraw @a ["",{"text":" ↳ ","color":"#555555"},{"text":"Run ","color":"gray"},{"text":"/reload","color":"white","underlined":true,"click_event": {"action": "run_command", "command": "/reload"}},{"text":" to reinitialize dataLib.","color":"gray"}]

tellraw @a[tag=datalib.debug] ["",{"text":"[DL/DEBUG] ","color":"aqua"},{"text":"dl.pre_version → ","color":"#555555"},{"text":"major=","color":"gray"},{"score":{"name":"#dl.major","objective":"dl.pre_version"},"color":"yellow"},{"text":" minor=","color":"gray"},{"score":{"name":"#dl.minor","objective":"dl.pre_version"},"color":"yellow"},{"text":" patch=","color":"gray"},{"score":{"name":"#dl.patch","objective":"dl.pre_version"},"color":"yellow"},{"text":" pre=","color":"gray"},{"score":{"name":"#dl.pre","objective":"dl.pre_version"},"color":"yellow"},{"text":" (expected: 6 0 1)","color":"red"}]
tellraw @a[tag=datalib.debug] ["",{"text":"[DL/DEBUG] ","color":"aqua"},{"text":"dl.pre_version → ","color":"#555555"},{"text":"major=","color":"gray"},{"score":{"name":"#dl.major","objective":"dl.pre_version"},"color":"yellow"},{"text":" minor=","color":"gray"},{"score":{"name":"#dl.minor","objective":"dl.pre_version"},"color":"yellow"},{"text":" patch=","color":"gray"},{"score":{"name":"#dl.patch","objective":"dl.pre_version"},"color":"yellow"},{"text":" pre=","color":"gray"},{"score":{"name":"#dl.pre","objective":"dl.pre_version"},"color":"yellow"},{"text":" (expected: 6 0 2)","color":"red"}]

data modify storage datalib:engine _log_add_tmp.message set value "❌ Version mismatch — expected v6.0.1. Load aborted."
data modify storage datalib:engine _log_add_tmp.message set value "❌ Version mismatch — expected v6.0.2. Load aborted."
function datalib:systems/log/warn with storage datalib:engine _log_add_tmp
data remove storage datalib:engine _log_add_tmp.message
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# dl_load:loader/scoreboards
# (moved from dl_load:load/scoreboards in v6.0.1 — load/ vs loader/
# (moved from dl_load:load/scoreboards in v6.0.2 — load/ vs loader/
# separates gate/confirmation logic from the actual init routines)

scoreboard objectives add dl.tmp dummy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dl_load:loader/storages
# Initializes datalib:engine storage fields that do not yet exist.
# (moved from dl_load:load/storages in v6.0.1 — load/ vs loader/
# (moved from dl_load:load/storages in v6.0.2 — load/ vs loader/
# separates gate/confirmation logic from the actual init routines)
#
# SAFETY DESIGN
Expand Down Expand Up @@ -108,7 +108,7 @@ data modify storage datalib:engine batches set value {}
execute unless data storage datalib:engine wand_cooldowns run data modify storage datalib:engine wand_cooldowns set value {}

# ─────────────────────────────────────────────────────────────────
# Security module init (v6.0.1+)
# Security module init (v6.0.2+)
# BREAKING CHANGE: trust_players defaults to 0b — players must have
# dl.perm_level explicitly set. datalib.admin tag alone gives no access.
#
Expand All @@ -123,7 +123,7 @@ execute unless data storage datalib:engine wand_cooldowns run data modify storag
# every tick (default, legacy behavior). 0b =
# admins must be given datalib.debug explicitly
# via /function datalib:debug/tools/admin/debug_tag/*
# (v6.0.1, see admin_systems.mcfunction)
# (v6.0.2, see admin_systems.mcfunction)
# debug_log 0b = test-block console logging disabled (default).
# 1b = every systems/log/add call also pulses the
# configured test_block, so the message text lands
Expand All @@ -132,7 +132,7 @@ execute unless data storage datalib:engine wand_cooldowns run data modify storag
# ─────────────────────────────────────────────────────────────────
execute unless data storage datalib:engine security run data modify storage datalib:engine security set value {trust_players:0b,cmd_min_level:3,sandbox_cmd_min_level:4,admin_min_level:2,admin_can_override:0b,sandbox_allowlist:{},auto_debug_tag:1b,debug_log:0b}
# ─────────────────────────────────────────────────────────────────
# Security module v6.0.1+ additions
# Security module v6.0.2+ additions
# BREAKING CHANGE: sandbox_allowlist is now a compound {} (was list []).
# Empty compound {} = all sandbox commands blocked.
# multi_type_allowlist: compound of permitted multiCommands.type values.
Expand All @@ -143,7 +143,7 @@ execute if data storage datalib:engine security.sandbox_allowlist[] run data mod
execute unless data storage datalib:engine security run data modify storage datalib:engine security set value {trust_players:0b,cmd_min_level:3,sandbox_cmd_min_level:4,admin_min_level:2,admin_can_override:0b,sandbox_allowlist:{},auto_debug_tag:1b,debug_log:0b}
execute unless data storage datalib:engine security.sandbox_allowlist run data modify storage datalib:engine security.sandbox_allowlist set value {}
execute unless data storage datalib:engine security.multi_type_allowlist run data modify storage datalib:engine security.multi_type_allowlist set value {multi_cmd:1b,multi_cmd_adv:1b}
# Migration: packs upgraded from pre-v6.0.1 will have a security
# Migration: packs upgraded from pre-v6.0.2 will have a security
# compound already present without auto_debug_tag — backfill it so the
# 'unless data storage ... security run ...' guard above (which only
# fires when the whole compound is absent) doesn't skip existing worlds.
Expand Down
2 changes: 1 addition & 1 deletion datapacks/dataLib/data/dl_load/function/main.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# clickable confirmation prompt, then returns. Nothing in datalib:engine
# storage is touched here.
#
# v6.0.1: renamed from dl_load:_ to dl_load:main, and dropped the
# v6.0.2: renamed from dl_load:_ to dl_load:main, and dropped the
# marker-entity + 'say' broadcast pattern entirely.
# - The marker/say pattern existed because 'say' has no @a[tag=...]
# filter and, historically, tellraw/clickEvent rendering was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# Returns 1 → validation passed, load continues.
# Returns 0 → validation failed, load aborted.
#
# v6.0.1: split out of the old monolithic
# v6.0.2: split out of the old monolithic
# core/internal/load/validate.mcfunction into dl_load:resolve/* —
# version compatibility and dependency resolution are distinct
# concerns and are now separately testable/callable:
# dl_load:resolve/version — stale-scoreboard version match
# dl_load:resolve/dependencies — rt_origin/fork + StringLib

# ── Init storage if fresh ────────────────────────────────────────
execute unless data storage datalib:engine global run data modify storage datalib:engine global set value {version:"v6.0.1"}
data modify storage datalib:engine global.version set value "v6.0.1"
execute unless data storage datalib:engine global run data modify storage datalib:engine global set value {version:"v6.0.2"}
data modify storage datalib:engine global.version set value "v6.0.2"

execute unless data storage datalib:engine log_display run data modify storage datalib:engine log_display set value []
execute unless score #dl.log_count dl.tmp matches 0.. run scoreboard players set #dl.log_count dl.tmp 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# expected version. Returns 1 → match / not yet set (proceed).
# Returns 0 → mismatch (version_warn fired, load aborted upstream).
#
# EXPECTED (v6.0.1): major=6 minor=0 patch=1 pre=2
# EXPECTED (v6.0.1): major=6 minor=0 patch=2 pre=0 (stable, not a pre-release)
#
# BUGFIX (v6.0.1): the previous check compared #dl.pre against
# "matches 1.." (i.e. "any pre >= 1 counts as mismatch"), which made
Expand All @@ -20,8 +20,8 @@ scoreboard players set #dl.mismatch dl.pre_version 0
# (#dl.ver_set is set by core/internal/load/version_set).
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.major dl.pre_version matches 6 run scoreboard players set #dl.mismatch dl.pre_version 1
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.minor dl.pre_version matches 0 run scoreboard players set #dl.mismatch dl.pre_version 1
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.patch dl.pre_version matches 1 run scoreboard players set #dl.mismatch dl.pre_version 1
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.pre dl.pre_version matches 2 run scoreboard players set #dl.mismatch dl.pre_version 1
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.patch dl.pre_version matches 2 run scoreboard players set #dl.mismatch dl.pre_version 1
execute if score #dl.ver_set dl.pre_version matches 1 run execute unless score #dl.pre dl.pre_version matches 0 run scoreboard players set #dl.mismatch dl.pre_version 1

execute if score #dl.mismatch dl.pre_version matches 1 run function dl_load:core/internal/load/version_warn
execute if score #dl.mismatch dl.pre_version matches 1 run return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ tellraw @a ["",{"text":"[DL SAFE GATE] =========================================
# Delegate to regular load/yes
function dl_load:load/yes


# Enable sandbox mode
data modify storage datalib:engine sandbox set value 1b

# Leave players unsafe by default (v6.0.1 default is already 0b)
# Leave players unsafe by default (v6.0.2 default is already 0b)
data modify storage datalib:engine security set value {trust_players:0b,cmd_min_level:3,sandbox_cmd_min_level:4,admin_min_level:2,admin_can_override:0b,sandbox_allowlist:{}}
2 changes: 1 addition & 1 deletion datapacks/dataLib/pack.mcmeta
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
]
},
{
"text": " | v6.0.1",
"text": " | v6.0.2",
"color": "#ffaa00",
"bold": false,
"italic": false
Expand Down
2 changes: 1 addition & 1 deletion migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ def get_mcmeta(title, desc_extra=""):
"features": {"enabled": ["minecraft:vanilla"]}
}

(DST_BASE / "datalib-core/pack.mcmeta").write_text(json.dumps(get_mcmeta("D.L. Core", " | v6.0.1"), indent=2, ensure_ascii=False))
(DST_BASE / "datalib-core/pack.mcmeta").write_text(json.dumps(get_mcmeta("D.L. Core", " | v6.0.2"), indent=2, ensure_ascii=False))
for m in module_list:
p_dir = DST_BASE / f"datalib-{m}-module"
(p_dir / "pack.mcmeta").write_text(json.dumps(get_mcmeta(f"D.L. -- {m}", " | requires datalib-core"), indent=2, ensure_ascii=False))
Expand Down
Loading