Fix writer part aspects not activating during network initialization - #1710
Open
rubensworks wants to merge 1 commit into
Open
Fix writer part aspects not activating during network initialization#1710rubensworks wants to merge 1 commit into
rubensworks wants to merge 1 commit into
Conversation
ba6dd95 moved the aspect (de)activation of PartStateWriterBase#triggerAspectInfoUpdate inside the `!isNetworkInitializing` branch, to stop beforeNetworkKill from clearing the active aspect and persisting that null after a world restart. That guard however also disabled the other half of the lifecycle: afterNetworkAlive activates parts via updateActivation without a player, which makes isNetworkInitializing true. So since then, the active aspect was never assigned and IAspectWrite#onActivate was never called when a network is built, which happens on every world load and on every network rebuild. Integrated Dynamics' own writers survive this because their active aspect is restored from NBT, but add-ons rely on onActivate to register their parts with the network. All Integrated Tunnels importers, exporters and interfaces therefore stopped working (146 of its game tests failed, and they all pass again with this change). The two halves are now separated again: * Aspects are activated and deactivated at most once, tracked by a non-persisted flag, so that killing and reviving a network doesn't deactivate an aspect twice or skip its reactivation. * The active aspect is only forgotten outside of network initialization, which is what the original fix needed. Also adds a game test that configures a writer without a player, which is the path that add-ons and network initialization use.
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 a regression from ba6dd95 (1.34.1) that breaks all Integrated Tunnels parts.
The regression
That commit moved the aspect (de)activation of
PartStateWriterBase#triggerAspectInfoUpdateinside the!isNetworkInitializingbranch:The goal was to stop
beforeNetworkKill(which passesnewAspect = null, isNetworkInitializing = true) from clearing the active aspect, as that null would then be persisted, which is what #1628 and #1697 were about.But the guard also disabled the other half of the lifecycle.
afterNetworkAliveactivates parts throughupdateActivation(target, state, null), andisNetworkInitializingis derived fromplayer == null, so it is true there as well. Since 1.34.1, the active aspect is therefore never assigned, andIAspectWrite#onActivateis never called, when a network is built. That happens on every world load and on every network rebuild (placing or breaking any cable).Integrated Dynamics' own writers keep working because their active aspect is restored from NBT, and their aspects don't need
onActivate. Add-ons do:onActivateis what registers their parts with the positioned addons network. All Integrated Tunnels importers, exporters and interfaces stop working as a result.The reason this was not caught is that the same commit changed the
placeVariableInWritergame test helper to passhelper.makeMockPlayer(...), which makesisNetworkInitializingfalse. Add-ons configure their parts without a player, so they take the broken path.The fix
The two halves are separated again:
activeAspectActivatedflag. Networks are killed and revived without the aspect itself changing, so this prevents both deactivating an aspect twice and skipping its reactivation.onVariableContentsUpdatedkeeps being skipped during network init, as before.Verification
Both suites were run against the same build.
runGameTestServerrunGameTestServerThe Integrated Tunnels runs used
master-1.21-ltspublished to Maven local, with NeoForge, CyclopsCore and CommonCapabilities held constant, so the ID jar was the only difference. For reference, Integrated Tunnels also passes 146/146 against the released 1.32.0, which is from before the regression.testCombinedAspectsWriterPersistsAfterNetworkRebuild, the regression test that ba6dd95 added for #1628, still passes.This PR also adds
testCombinedAspectsWriterActivatesWithoutPlayer, which configures a writer without a player, the path that add-ons and network initialization use. Without the fix it fails withAspect was not activated without a player, but was null.Branches
master-1.20-ltsandmaster-1.19-ltsare not affected: ba6dd95 is only contained inmaster-1.21-lts, and both older branches still have the activation outside theisNetworkInitializingguard. So this targetsmaster-1.21-ltsonly, and there is nothing to up-merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01ULVbUmc3Uk3ek3d3T4sB9V
Generated by Claude Code