Skip to content

fix: don't update the active state while loading a machine without a level - #33

Merged
Roelymole merged 1 commit into
TeamGalacticraft:minecraft/1.21from
olavjens777:fix/load-without-level
Oct 17, 2026
Merged

Roelymole merged 1 commit into
TeamGalacticraft:minecraft/1.21from
olavjens777:fix/load-without-level

Conversation

@olavjens777

Copy link
Copy Markdown
Contributor

Fixes #32

Problem

loadAdditional calls updateActiveState(this.level, ...) whenever the tag contains Active, and Active is always saved. When a chunk is loaded, the block entity doesn't have a level yet, so this throws a NullPointerException. Minecraft then skips the block entity, and the machine loses all of its data.

Fix

Only update the active state when there is a server level. That is the case when a machine is placed with block entity data, which is what bc454f5 was for. When a chunk is loaded, the block state stored in the chunk is already correct.

Testing

  • New gametest generator.loadWithoutLevel: it loads a generator with BlockEntity.loadStatic, like chunk loading does, and checks that its inventory is still there. It fails without the fix and passes with it.
  • ./gradlew build runGametest passes.
  • Checked in game with Galacticraft: machines keep their inventory and configuration after reloading the world.

@Roelymole Roelymole left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Roelymole
Roelymole merged commit 8a605c7 into TeamGalacticraft:minecraft/1.21 Oct 17, 2026
1 check passed
@olavjens777
olavjens777 deleted the fix/load-without-level branch October 18, 2026 00:32
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.

Machines lose all their data when a chunk is loaded

2 participants