Skip to content

Fix WorldStorage crashing on clients connected to a server - #264

Merged
rubensworks merged 2 commits into
master-26-ltsfrom
claude/optimistic-dijkstra-8eju8x
Nov 19, 2026
Merged

rubensworks merged 2 commits into
master-26-ltsfrom
claude/optimistic-dijkstra-8eju8x

Conversation

@rubensworks

@rubensworks rubensworks commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Problem

Reported in CyclopsMC/IntegratedDynamics#1793: on a dedicated server, putting the Omni-Directional Connector recipe into an AE2 pattern encoding terminal disconnects the client with "Network Protocol Error". Because the grid contents persist, the client is kicked again every time it reopens the terminal.

AE2 calls recipe.assemble() on the client to show the output. ID's omni connector recipe uses a RecipeCraftingShapedCustomOutput output transformer that calls IntegratedDynamics.globalCounters.get(). WorldStorage.Access#get() assumes ServerLifecycleHooks.getCurrentServer() is non-null, which is not the case on a client connected to a remote server:

java.lang.NullPointerException: Cannot invoke "net.minecraft.server.MinecraftServer.getLevel(net.minecraft.resources.ResourceKey)" because "server" is null
	at org.cyclops.cyclopscore.persist.world.WorldStorage$Access.get(WorldStorage.java:44)
	at org.cyclops.cyclopscore.persist.world.WorldStorage$Access.get(WorldStorage.java:48)
	at org.cyclops.integrateddynamics.part.PartTypeConnectorOmniDirectional.generateGroupId(PartTypeConnectorOmniDirectional.java:120)
	at org.cyclops.integrateddynamics.part.PartTypeConnectorOmniDirectional.transformCraftingOutput(PartTypeConnectorOmniDirectional.java:169)
	at org.cyclops.cyclopscore.recipe.type.RecipeCraftingShapedCustomOutput.assemble(RecipeCraftingShapedCustomOutput.java:42)
	at appeng.menu.me.items.PatternEncodingTermMenu.getAndUpdateOutput(PatternEncodingTermMenu.java:250)
	...
	at appeng.menu.me.items.PatternEncodingTermMenu.setItem(PatternEncodingTermMenu.java:210)
	at net.minecraft.client.multiplayer.ClientPacketListener.handleContainerSetSlot(ClientPacketListener.java:1427)

Singleplayer is not affected, since the integrated server is present. Only the 26.x branches have this bug: on master-1.20-lts and master-1.21-lts, GlobalCounters is a plain object that does not look up the server when accessed. So this targets master-26-lts.

Change

When no server is running, WorldStorage.Access#get() now returns a lazily created transient instance (from the SavedDataType factory with a null level) instead of throwing. It is not persisted nor synced. For the omni connector, this only affects the client-side preview: the group id there is a throwaway, and the real id is still generated server-side when crafting. ID's LabelsWorldStorage.Access already keeps its own client instance by overriding get(), so it is unaffected.

Behaviour while a server is running (dedicated or integrated) is unchanged.

Limitations:

  • A WorldStorage whose factory dereferences the level would still throw on a remote client, as before. None of the ones I found (GlobalCounters, ID's labels) do.
  • EvilCraft's ItemEntangledChalice also calls globalCounters.get(). I did not check whether that path can run client-side.

Testing

Setup: dedicated dev server (NeoForge 26.1.2.126, ID 1.37.1, AE2 26.1.13-beta) with a dev client driven by clientdevbridge.

  • Without this change: filling the pattern encoding terminal grid with the omni connector recipe disconnects the client with the same stack trace as in the report.
  • With this change, the full flow works:
    • Reopening the terminal on the persisted recipe grid and re-placing the recipe keeps the client connected. The preview shows 2 Omni-Directional Connectors.
    • Encoding the pattern works (server-side, result omnidirectional_group=2).
    • Autocrafting it through a pattern provider, molecular assembler and 1k crafting CPU completes. It yields 2 connectors sharing a new server-generated group (4), which AE2 accepts.
    • Extracted from the terminal, the item tooltip shows "Group: 4".
    • Placed on two ID cable segments 20 blocks apart, each with a block reader, the connectors keep groupId:4. ID network diagnostics show two separate networks before the second connector is placed, and one network (4 cables, both readers, both connectors) after. Right-clicking a placed connector reports "Group: 4".
    • No errors in the client or server logs.
  • ./gradlew build and ./gradlew runGameTestServer: pass.

Note: the group shown in the client-side preview, the encoded pattern's output, and the actual crafted item all differ (2, 2 and 4 here), because each assemble() call generates a new id. That is how ID's recipe works (it also happens in singleplayer) and is not changed by this PR.

Closes CyclopsMC/IntegratedDynamics#1793

🤖 Generated with Claude Code

https://claude.ai/code/session_01UeSuG81BxHPwYueMgjzZz3

WorldStorage.Access#get() assumed a server was always running, so calling
it on a client connected to a dedicated server threw an NPE. This happens
when other mods assemble crafting recipes client-side, such as AE2's
pattern encoding terminal assembling Integrated Dynamics' omni-directional
connector recipe, which disconnected the client.

When no server is running, a transient non-persisted instance is now
returned instead.

Closes CyclopsMC/IntegratedDynamics#1793

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeSuG81BxHPwYueMgjzZz3
@coveralls

coveralls commented Nov 19, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 31.637% (-0.02%) from 31.656% — claude/optimistic-dijkstra-8eju8x into master-26-lts

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

Copy link
Copy Markdown

@rubensworks
rubensworks merged commit 93ec269 into master-26-lts Nov 19, 2026
7 checks passed
@rubensworks
rubensworks deleted the claude/optimistic-dijkstra-8eju8x branch November 19, 2026 16:02
@cyclopsmc-release-bot cyclopsmc-release-bot Bot added the released Included in a published release label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Included in a published release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Omni-Directional Connector and AE2 crafter encoding

3 participants