Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

fix: restore missing zprivate/replace function files#30

Merged
IronCrest-sudo merged 1 commit into
mainfrom
develop
Jul 20, 2026
Merged

fix: restore missing zprivate/replace function files#30
IronCrest-sudo merged 1 commit into
mainfrom
develop

Conversation

@IronCrest-sudo

Copy link
Copy Markdown
Collaborator

Bug

stringlib:util/replace (and datalib:core/lib/string/replace, which wraps it) always returned the original string unchanged and a return value of 0, regardless of input.

Root cause

zprivate/replace/ (8 files) was deleted in 43b8bc5 ("refactor: replace old datapack with the new modular structure") along with the rest of data/stringlib/. When fd4d15c ("Organize code") later restored data/stringlib/util/, zprivate/concat/, zprivate/find/, zprivate/split/, etc. — zprivate/replace/ was not included.

util/replace.mcfunction still calls stringlib:zprivate/replace/main, check_word_start_loop, and the reversed/ equivalents. Minecraft's function command no-ops silently on an unknown function reference rather than erroring, so the datapack loaded without any "failed to load function" errors — the bug was silent.

Fix

Restored the 8 files from 43b8bc5^ (last known-good state, one commit before the deletion):

zprivate/replace/check_word_rest.mcfunction
zprivate/replace/check_word_start_loop.mcfunction
zprivate/replace/main.mcfunction
zprivate/replace/replace.mcfunction
zprivate/replace/reversed/check_word_rest.mcfunction
zprivate/replace/reversed/check_word_start_loop.mcfunction
zprivate/replace/reversed/main.mcfunction
zprivate/replace/reversed/replace.mcfunction

Verification

Tested against a live 26.2 server via RCON, not just static analysis:

  • datalib:core/lib/string/replace with string="Hello World", find="World", replace="Everyone" → output "Hello Everyone" (previously "Hello World", unchanged)
  • Regression check: removed zprivate/replace/ again on the live server → bug reproduced ("Hello World"). Restored → fixed again ("Hello Everyone"). Confirms these files are the actual root cause, not a coincidental fix.
  • stringlib:util/replace called directly with n=1 on "aXbXcX" → "a-bXcX" (only first match replaced, n param works)
  • stringlib:util/replace called directly with n=unset on "aXbXcX" → "a-b-c-", return value 3 (correct match count, was always 0 before)
  • stringlib:util/find unaffected (regression check on separate function)

Not in scope

datalib:core/lib/string/replace.mcfunction itself does not propagate a return value from stringlib:util/replace (its last line is a tellraw, no return). stringlib:util/replace's own return value is correct after this fix. Leaving the wrapper as-is since it's unrelated to the reported bug — happy to open a separate PR if wanted.

zprivate/replace/ was deleted in 43b8bc5 (refactor: replace old
datapack with the new modular structure) and never re-added when
fd4d15c (Organize code) restored the rest of data/stringlib/.

util/replace.mcfunction still calls stringlib:zprivate/replace/main
and check_word_start_loop (plus reversed/ variants), which silently
no-op when missing, so replace() always returned the original
string unchanged and a return value of 0.

Restored the 8 files from 43b8bc5^ (their last known-good state).
Verified against a live 26.2 server via RCON: replace() now returns
correct output and correct match count; find() unaffected (regression
check).
@IronCrest-sudo
IronCrest-sudo merged commit 4230cb2 into main Jul 20, 2026
5 checks passed
@tickwarden
tickwarden deleted the develop branch July 20, 2026 10:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants