Skip to content

Fix DimPos being persisted under a hardcoded NBT key - #235

Merged
rubensworks merged 1 commit into
master-26-ltsfrom
claude/cyclopscore-dimpos-nbt-key
Aug 25, 2026
Merged

Fix DimPos being persisted under a hardcoded NBT key#235
rubensworks merged 1 commit into
master-26-ltsfrom
claude/cyclopscore-dimpos-nbt-key

Conversation

@rubensworks

Copy link
Copy Markdown
Member

Problem

The ValueInput/ValueOutput migration left the DimPos NBT type in NBTClassTypesNeoForge asymmetric — it writes to a hardcoded "dim" child but reads a child named after the field:

public void writePersistedField(String name, DimPos object, ValueOutput tag) {
    ValueOutput dimPos = tag.child("dim");   // <- hardcoded
    ...
}

public DimPos readPersistedField(String name, ValueInput tag) {
    ValueInput dimPos = tag.child(name).orElseThrow();   // <- by field name
    ...
}

So no persisted DimPos ever round-trips; reading always throws. master-1.21-lts and earlier are correct (tag.put(name, dimPos) / tag.getCompound(name)), so this is a regression limited to the ValueOutput-based branches. A second consequence: two DimPos fields written into the same tag under different names clobber each other.

This is what crashes IntegratedDynamics clients in CyclopsMC/IntegratedDynamics#1703, via ValueTypeListProxyPositioned:

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.orElseThrow(Optional.java:377)
	at NBTClassTypesNeoForge$2.readPersistedField(NBTClassTypesNeoForge.java:52)
	at NBTClassTypesNeoForge$2.readPersistedField(NBTClassTypesNeoForge.java:39)
	at NBTClassType.readNbt(NBTClassType.java:498)
	at ValueTypeListProxyPositioned.readGeneratedFieldsFromNBT(...)

PositionedOperator and anything else persisting a DimPos hit the same thing.

Changes

  • Write to tag.child(name) instead of tag.child("dim").
  • Reading falls back to the old hardcoded "dim" key when the named child is absent, so data already written by affected versions stays readable instead of throwing.

Testing

loader-neoforge's own build does not resolve here (the commoncapabilities API dependency is unreachable from this environment, and it fails identically on a clean checkout), so I type-checked the changed file against the locally built loader-common classes plus the patched Minecraft jar, and drove a round-trip through TagValueOutput/TagValueInput:

Before:

serialized keys: [dim]
Exception in thread "main" java.util.NoSuchElementException: No value present
	at NBTClassTypesNeoForge$2.readPersistedField(NBTClassTypesNeoForge.java:52)

(the reporter's exact frames)

After:

serialized keys: [pos]
read: minecraft:overworld BlockPos{x=1, y=2, z=3}
legacy read: minecraft:overworld BlockPos{x=1, y=2, z=3}
OK

where legacy read feeds in a tag whose DimPos sits under the old "dim" key.

Branch

Affected branches are master-1.21.8, master-1.21.10, master-26-lts and master-26. The two 1.21.x branches look dormant (last commits Nov/Dec 2025), so this targets master-26-lts for upmerging — happy to retarget if you want it lower.


Generated by Claude Code

The ValueOutput migration made the DimPos NBT type write its data to a
hardcoded "dim" child, while it is read back from a child named after
the field.
As a result, every persisted DimPos failed to deserialize with a
"NoSuchElementException: No value present", and multiple DimPos fields
in the same tag overwrote each other.

Reading falls back to the old hardcoded key, so data written by affected
versions remains readable.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QoinY4GW1gaXggj3WxDUcF
@sonarqubecloud

Copy link
Copy Markdown

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 31.028% (-0.004%) from 31.032% — claude/cyclopscore-dimpos-nbt-key into master-26-lts

@rubensworks
rubensworks merged commit c98b31b into master-26-lts Aug 25, 2026
7 checks passed
@rubensworks
rubensworks deleted the claude/cyclopscore-dimpos-nbt-key branch August 25, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants