Defensive null checks for Chain Conveyor renderer to prevent NPE during package rendering #9067
  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.
  
    
  
    
Summary
This patch prevents a client crash that happened while rendering
ChainConveyorBlockEntitypackages by adding defensive null checks and safer model lookups. Instead of attempting to render when required data is missing, the renderer now skips the problematic work gracefully.Stacktrace (excerpt)
Problem
Rendering sometimes tried to build buffers for package models while required inputs were missing. That led to a null-path inside the buffer creation/caching flow and caused an NPE during block entity rendering.
What changed
Early null checks in
renderSafebe), itsLevel, or itsBlockStateare null.levelandstatein local variables and reuse them.Guarded package model resolution in
renderBoxphysicsData.modelKeyis present before use.rigModelandboxModelfromAllPartialModelsonce and check for null.Use validated
statefor wheel/guard buffer creationbe.getBlockState()with the validatedstatevariable.Null check inside chain rendering loop
levelinside the connections loop to skip iterations if not present.Formatting and comments
Why this fixes it
The renderer no longer attempts to create buffers or query partial models when the required inputs (level, state, or partial model entries) are missing. Missing input is handled by skipping the render of that package or guard, preventing the null-path that caused the crash.
Tests / Verification
Follow-ups / suggestions
Files changed
src/main/java/com/simibubi/create/content/kinetics/chainConveyor/ChainConveyorRenderer.javastatefor model buffer calls.levelcheck inside the chain rendering loop.