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
199 changes: 100 additions & 99 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,63 @@
# ============================================
# Minecraft Datapack – Force LF
# ============================================
*.mcfunction text eol=lf
*.json text eol=lf diff=json
*.mcmeta text eol=lf diff=json
*.snbt text eol=lf
*.md text eol=lf
*.txt text eol=lf
*.nbt binary
*.mcfunction text eol=lf
*.json text eol=lf diff=json
*.mcmeta text eol=lf diff=json
*.snbt text eol=lf
*.md text eol=lf
*.txt text eol=lf
*.nbt binary
*.mcstructure binary
*.dat binary
*.dat_old binary
*.mca binary
*.mcc binary
*.region binary
*.dat binary
*.dat_old binary
*.mca binary
*.mcc binary
*.region binary

# ============================================
# Shader Files (Resource Pack compatibility)
# ============================================
*.glsl text eol=lf
*.vsh text eol=lf
*.fsh text eol=lf
*.vert text eol=lf
*.frag text eol=lf
*.geom text eol=lf
*.comp text eol=lf
*.hlsl text eol=lf
*.glsl text eol=lf
*.vsh text eol=lf
*.fsh text eol=lf
*.vert text eol=lf
*.frag text eol=lf
*.geom text eol=lf
*.comp text eol=lf
*.hlsl text eol=lf

# ============================================
# Config & Build Files
# ============================================
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
*.properties text eol=lf
*.env text eol=lf
*.ini text eol=lf
*.cfg text eol=lf
.gitignore text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.toml text eol=lf
*.properties text eol=lf
*.env text eol=lf
*.ini text eol=lf
*.cfg text eol=lf
.gitignore text eol=lf
.gitattributes text eol=lf
Makefile text eol=lf
Dockerfile text eol=lf
Makefile text eol=lf
Dockerfile text eol=lf

# ============================================
# Script & Web Files
# ============================================
*.py text eol=lf
*.sh text eol=lf
*.bash text eol=lf
*.js text eol=lf
*.ts text eol=lf
*.jsx text eol=lf
*.tsx text eol=lf
*.html text eol=lf
*.css text eol=lf
*.scss text eol=lf
*.xml text eol=lf diff=xml
*.svg text eol=lf
*.py text eol=lf
*.sh text eol=lf
*.java text eol=lf
*.bash text eol=lf
*.js text eol=lf
*.ts text eol=lf
*.jsx text eol=lf
*.tsx text eol=lf
*.html text eol=lf
*.css text eol=lf
*.scss text eol=lf
*.xml text eol=lf diff=xml
*.svg text eol=lf

# ============================================
# Windows-specific (optional)
Expand All @@ -74,87 +75,87 @@ Dockerfile text eol=lf
# ============================================
# Document & Office Files
# ============================================
*.pdf binary
*.doc binary
*.docx binary
*.xls binary
*.xlsx binary
*.ppt binary
*.pptx binary
*.odt binary
*.ods binary
*.odp binary
*.csv text eol=lf
*.pdf binary
*.doc binary
*.docx binary
*.xls binary
*.xlsx binary
*.ppt binary
*.pptx binary
*.odt binary
*.ods binary
*.odp binary
*.csv text eol=lf

# ============================================
# Binary Assets – Images
# ============================================
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.webp binary
*.ico binary
*.bmp binary
*.tga binary
*.tiff binary
*.psd binary
*.xcf binary
*.hdr binary
*.exr binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.webp binary
*.ico binary
*.bmp binary
*.tga binary
*.tiff binary
*.psd binary
*.xcf binary
*.hdr binary
*.exr binary

# ============================================
# Audio & Video
# ============================================
*.ogg binary
*.mp3 binary
*.wav binary
*.flac binary
*.aac binary
*.opus binary
*.mp4 binary
*.webm binary
*.avi binary
*.mkv binary
*.ogg binary
*.mp3 binary
*.wav binary
*.flac binary
*.aac binary
*.opus binary
*.mp4 binary
*.webm binary
*.avi binary
*.mkv binary

# ============================================
# 3D / Font Assets
# ============================================
*.obj binary
*.mtl binary
*.fbx binary
*.gltf text eol=lf diff=json
*.glb binary
*.ttf binary
*.otf binary
*.woff binary
*.obj binary
*.mtl binary
*.fbx binary
*.gltf text eol=lf diff=json
*.glb binary
*.ttf binary
*.otf binary
*.woff binary
*.woff2 binary

# ============================================
# Archives & Compiled
# ============================================
*.zip binary
*.rar binary
*.7z binary
*.tar binary
*.gz binary
*.jar binary
*.exe binary
*.dll binary
*.so binary
*.dylib binary
*.class binary
*.pyc binary
*.mcpack binary
*.zip binary
*.rar binary
*.7z binary
*.tar binary
*.gz binary
*.jar binary
*.exe binary
*.dll binary
*.so binary
*.dylib binary
*.class binary
*.pyc binary
*.mcpack binary
*.mcworld binary
*.mcaddon binary

# ============================================
# Lock files – text, diffable
# ============================================
*.lock text eol=lf
*.lock text eol=lf
package-lock.json text eol=lf diff=json
yarn.lock text eol=lf
yarn.lock text eol=lf

# ============================================
# Git diff drivers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

execute if data storage datalib:engine {global:{loaded:1b}} run return 0

function #load:_private/load
function #load:_private/load
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# Runs with @s bound to a single player holding the marked written_book.
# Extracts SelectedItem.components."minecraft:writable_book_content".pages[0].raw
# into datalib:input storage. Read-only capture, no execution.
#
# book.raw is a RAW, UNVALIDATED string — same contract as cbm.command and
# dialog.raw. If the caller needs it as a number/bool/tag-safe literal,
# run it through datalib:input/validate/check first:
# function datalib:input/validate/check with storage <yourpath> {source:"book.raw", type:"int"}
# ======================================================================================

data modify storage datalib:input book.player set from entity @s UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ data modify storage datalib:input cbm.pos set from entity @s Pos
# must run this through datalib:core/security/sanitize and
# datalib:debug/tools/utils/input_check before ever treating it as
# runnable, and running it there stays optional, never mandatory.
#
# Separately, if a caller wants cbm.command as a number/bool/tag-safe
# literal (not as a runnable command), use datalib:input/validate/check:
# function datalib:input/validate/check with storage <yourpath> {source:"cbm.command", type:"int"}
data modify storage datalib:input cbm.executed set value 0b
execute if data storage datalib:input cbm{executed:0b} run function #datalib:input/command_block_minecart

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# asked to avoid — no field here is ever run as a command, only stored.
# ======================================================================================

# dialog.raw is RAW, UNVALIDATED text. Run it through
# datalib:input/validate/check before treating it as a number/bool/tag-safe
# literal: function datalib:input/validate/check with storage <yourpath> {source:"dialog.raw", type:"int"}
data modify storage datalib:input dialog.raw set value "$(value)"
data modify storage datalib:input dialog.executed set value 0b
execute if data storage datalib:input dialog{executed:0b} run function #datalib:input/dialog
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
kill @e[type=minecraft:minecart,tag=datalib_input,sort=nearest,limit=1,distance=..2]
kill @e[type=minecraft:interaction,tag=datalib_input,sort=nearest,limit=1,distance=..2]
execute as @s at @s run summon minecraft:interaction ~ ~ ~ {width:1.0f,height:1.0f,Tags:["datalib_input"],Passengers:[{id:"minecraft:command_block_minecart",Tags:["datalib_input"]}]}
summon minecraft:command_block_minecart ~ ~ ~ {OnGround:1b,UpdateLastExecution:1b,Command:"",Tags:["datalib_input"],TrackOutput:1b}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ======================================================================================
# datalib:input/validate/_private/check_bool [INTERNAL]
# ======================================================================================
# Requires scratch.value to be the exact string "true" or "false". No
# case-folding — "True"/"TRUE" are rejected on purpose, since silently
# accepting them just moves the ambiguity one step further down instead
# of resolving it.
# ======================================================================================

execute if data storage datalib:input_validate {scratch:{value:"true"}} run data modify storage datalib:input_validate result.valid set value 1b
execute if data storage datalib:input_validate {scratch:{value:"false"}} run data modify storage datalib:input_validate result.valid set value 1b

execute unless data storage datalib:input_validate {result:{valid:1b}} run data modify storage datalib:input_validate result.error set value "expected exactly \"true\" or \"false\""
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ======================================================================================
# datalib:input/validate/_private/check_float [INTERNAL]
# ======================================================================================
# Same digit-counting strategy as check_int, but first strips at most one
# '.' (anywhere after a possible leading '-', not at position 0 of rest,
# not as the last character either — "1." and ".5" are rejected as
# ambiguous rather than guessed at).
# ======================================================================================

data modify storage datalib:input_validate scratch.rest set from storage datalib:input_validate scratch.value

execute store result score #DL.Len dl.tmp run data get storage datalib:input_validate scratch.rest
execute if score #DL.Len dl.tmp matches 0 run data modify storage datalib:input_validate result.error set value "empty input"
execute if score #DL.Len dl.tmp matches 0 run return 0

# Count the dots via replace() — its return value is a real match count,
# unlike find()'s (see count_one_digit for why find()'s own return isn't
# usable as a count).
data modify storage stringlib:input replace.String set from storage datalib:input_validate scratch.rest
data modify storage stringlib:input replace.Find set value "."
data modify storage stringlib:input replace.Replace set value ""
data modify storage stringlib:input replace.n set value 0

scoreboard players set #DL.DotHits dl.tmp 0
execute store result score #DL.DotHits dl.tmp run function stringlib:util/replace

execute if score #DL.DotHits dl.tmp matches 2.. run data modify storage datalib:input_validate result.error set value "more than one '.'"
execute if score #DL.DotHits dl.tmp matches 2.. run return 0

# Exactly one dot: find its position (find()'s OUTPUT LIST is trustworthy —
# only its own return value isn't) and reject if it's first/last char.
execute if score #DL.DotHits dl.tmp matches 1 run data modify storage stringlib:input find.String set from storage datalib:input_validate scratch.rest
execute if score #DL.DotHits dl.tmp matches 1 run data modify storage stringlib:input find.Find set value "."
execute if score #DL.DotHits dl.tmp matches 1 run data modify storage stringlib:input find.n set value 1
execute if score #DL.DotHits dl.tmp matches 1 run function stringlib:util/find
execute if score #DL.DotHits dl.tmp matches 1 run function datalib:input/validate/_private/check_float_dot_position
execute if score #DL.DotHits dl.tmp matches 1 if data storage datalib:input_validate {result:{error:"malformed decimal point"}} run return 0

# Strip leading '-' the same way check_int does.
data modify storage datalib:input_validate scratch.first set string storage datalib:input_validate scratch.rest 0 1
execute if data storage datalib:input_validate {scratch:{first:"-"}} run data modify storage datalib:input_validate scratch.rest set string storage datalib:input_validate scratch.rest 1
data remove storage datalib:input_validate scratch.first

# Remove the single '.' itself before counting digits (it's not a digit,
# but it's the one non-digit char we're intentionally allowing).
execute if score #DL.DotHits dl.tmp matches 1 run function datalib:input/validate/_private/strip_one_dot

execute store result score #DL.Len dl.tmp run data get storage datalib:input_validate scratch.rest
execute if score #DL.Len dl.tmp matches 0 run data modify storage datalib:input_validate result.error set value "no digits"
execute if score #DL.Len dl.tmp matches 0 run return 0

function datalib:input/validate/_private/count_digits

execute if score #DL.DigitCount dl.tmp = #DL.Len dl.tmp run data modify storage datalib:input_validate result.valid set value 1b
execute unless score #DL.DigitCount dl.tmp = #DL.Len dl.tmp run data modify storage datalib:input_validate result.error set value "contains a non-digit character"

data remove storage datalib:input_validate scratch.rest
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ======================================================================================
# datalib:input/validate/_private/check_float_dot_position [INTERNAL]
# ======================================================================================
# stringlib:output find holds a one-element list [idx] for the '.' just
# located by check_float. Rejects idx == 0 (leading dot, e.g. ".5") and
# idx == len-1 (trailing dot, e.g. "1.") as malformed rather than
# guessing an implied leading/trailing zero.
# ======================================================================================

execute store result score #DL.DotIdx dl.tmp run data get storage stringlib:output find[0]
execute store result score #DL.Len dl.tmp run data get storage datalib:input_validate scratch.rest

scoreboard players operation #DL.LastIdx dl.tmp = #DL.Len dl.tmp
scoreboard players remove #DL.LastIdx dl.tmp 1

execute if score #DL.DotIdx dl.tmp matches 0 run data modify storage datalib:input_validate result.error set value "malformed decimal point"
execute if score #DL.DotIdx dl.tmp = #DL.LastIdx dl.tmp run data modify storage datalib:input_validate result.error set value "malformed decimal point"
Loading