-
Notifications
You must be signed in to change notification settings - Fork 329
Fixes machines becoming invisible when breaking or replacing multiblock parts #4303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
Fixes GregTechCEu#4276 Addresses an issue where multiblocks sometimes fail to render correctly after initial chunk loading due to the block entity not being fully initialized when the chunk is first rendered. Forces a model data refresh on the client side when a block entity finishes loading to ensure correct rendering of multiblocks, especially in cases where the chunk was rendered before the block entity was fully available. Also, it avoids returning null model render types, which could cause the block to be invisible, by instead returning the render types of the default model.
…ck parts The Root Cause was MachineRenderState relying on identity-based lookups (IdentityHashMap in model rendering, IdMapper in network sync). However, StateHolder.setValue() only returns interned instances when called on an already-interned state. When non-interned states entered the system via deserialization or network sync, identity lookups failed, causing blocks to render nothing. The Fix: - MachineRenderState - Added intern() method that looks up the canonical state instance from StateDefinition.getPossibleStates(), and wired it into the CODEC via xmap() so deserialized states are always interned - MetaMachineBlockEntity - setRenderState() now validates the state belongs to the correct definition and interns it; onLoad() also validates since @persisted bypasses the setter. - MachineRenderStatePayload - Interns state before registry ID lookup during network write - MultiblockControllerMachine - onPartUnload() now immediately invalidates the structure when a part is removed, ensuring all remaining parts have their render state updated to unformed - MachineModel - Added fallback rendering that searches by property values when identity lookup fails, preventing invisible blocks if a non-interned state slips through and is mostly a failsafe
Fixes dedicated server crash caused by client-side class loading. MachineRenderState was in client/model/machine but used by server-side code (MetaMachineBlockEntity, MachineRenderStatePayload, etc.). When the dedicated server loaded these classes, it triggered loading of other client-only classes in that package, causing LDLRegisterClient and GuiGraphics class loading errors.
src/main/java/com/gregtechceu/gtceu/api/machine/MachineRenderState.java
Outdated
Show resolved
Hide resolved
- Added @persisted to controllerPositions in MultiblockPartMachine so controller references are available immediately on load - Add onLoad() to rebuild controllers from persisted positions and clear IS_FORMED if controllers can't be resolved (prevents inconsistent visual state with overlays but no texture overrides) - Fix MetaMachineBlockEntity.onLoad() to always intern() the render state after NBT load, ensuring it matches modelsByState keys
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
1.21
Release: Patch - 0.0.X
Smaller changes that either are bug fixes or very minor tweaks.
type: bugfix
General bug fixes
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.
What
The Root Cause was MachineRenderState relying on identity-based lookups (IdentityHashMap in model rendering, IdMapper in network sync).
However, StateHolder.setValue() only returns interned instances when called on an already-interned state. When non-interned states entered the system via deserialization or network sync, identity lookups failed, causing blocks to render nothing.
Implementation Details
Outcome