Translate script values back to NBT when an operator expects NBT - #73
Merged
rubensworks merged 1 commit intoSep 3, 2026
Merged
Conversation
Only compound tags keep their type when they are translated to a script: all other tags become plain script values, and an absent NBT value becomes null. Passing such a value to an operator again therefore failed, because it was translated back to the value type it looked like. A list tag that came out of an NBT path filter expression came back as a list, so nbtAsTagList(idContext.ops.stringNbtPathMatchFirst(...)) failed with a wrong type error instead of listing the matches, and null values did not translate at all. Operator arguments are now translated against the value type the operator expects for them, so script values reaching an NBT input are converted to NBT, and null becomes an absent NBT value. Related to #67 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JCW1HmWhLT27jh57t9d7B6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the first half of #67: values that came out of an NBT operator could not be passed into another one. Targeted at
master-1.20-ltsfor upmerging, since the affected code is identical on 1.20, 1.21 and 26 (and on 1.19).Problem
Only compound tags keep their NBT type when they are translated to a script (they become an
NbtCompoundTagProxyObject). Every other tag becomes a plain script value: a list tag or array tag becomes a JS array, primitives become numbers and strings, and an absent NBT value becomesnull.When such a value is passed to an operator again, it is translated back to whatever value type it looks like, so an NBT input receives a list or a number, and
OperatorBase.validateTypesrejects it:A filter expression always matches into a list tag, so this hits every script that post-processes an NBT path match, which is what the reporter ran into.
nullwas worse: no translator handles it, so it failed withvaluetype.integratedscripting.error.translation.unknown_from_graal.Fix
OperatorProxyExecutablenow translates each argument against the value type the operator declares for it (CurriedOperatorreports the remaining input types, so methods on value proxies work the same way). For an NBT input, a script value that is not NBT is converted with the existingtranslateToNbtpath, andnullbecomes an absent NBT value. Arguments of every other type keep going through the same translation as before.Tests
NbtOperatorArgumentsJavaScriptTestscovers the list tag round trip, a plain script array,null, and, as controls, a compound tag and a non-NBT argument. Verified that the three NBT tests fail onmaster-1.20-ltswithout the fix:./gradlew buildpasses with the fix.Note
The reporter's original call,
nbtAsIntListon a filter match, no longer errors but still yields an empty list. That part is on the Integrated Dynamics side:ValueTypeListProxyNbtAsListIntonly acceptsIntArrayTag, andValueTypeListProxyNbtAsListGenericswallows theClassCastExceptionand reports length 0, so a list tag silently yields nothing.nbtAsTagListis the operator that works for these. Worth a separate look there.🤖 Generated with Claude Code
https://claude.ai/code/session_01JCW1HmWhLT27jh57t9d7B6
Generated by Claude Code