Skip to content

Conversation

serverside-swzo
Copy link

Summary

This patch prevents a client crash that happened while rendering ChainConveyorBlockEntity packages 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)

Description: Rendering Block Entity

java.lang.NullPointerException: Rendering Block Entity
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:889)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3965)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4863)
	at net.createmod.catnip.render.SuperByteBufferCache.get(SuperByteBufferCache.java:43)
	at net.createmod.catnip.render.CachedBuffers.partial(CachedBuffers.java:49)
	at com.simibubi.create.content.kinetics.chainConveyor.ChainConveyorRenderer.renderBox(ChainConveyorRenderer.java:104)
	at com.simibubi.create.content.kinetics.chainConveyor.ChainConveyorRenderer.renderSafe(ChainConveyorRenderer.java:67)
	at com.simibubi.create.content.kinetics.chainConveyor.ChainConveyorRenderer.renderSafe(ChainConveyorRenderer.java:41)
	at com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer.m_6922_(SafeBlockEntityRenderer.java:24)
	at net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher.m_112284_(BlockEntityRenderDispatcher.java:90)
	... (render loop frames)

Block Entity Details:
Name: create:chain_conveyor // com.simibubi.create.content.kinetics.chainConveyor.ChainConveyorBlockEntity
Block location: World: (366,-17,-9)

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 renderSafe

    • Return early if the block entity (be), its Level, or its BlockState are null.
    • Store level and state in local variables and reuse them.
  • Guarded package model resolution in renderBox

    • Ensure physicsData.modelKey is present before use.
    • Resolve rigModel and boxModel from AllPartialModels once and check for null.
    • If either model is missing, skip rendering that package.
  • Use validated state for wheel/guard buffer creation

    • Replace direct calls to be.getBlockState() with the validated state variable.
  • Null check inside chain rendering loop

    • Added a check for level inside the connections loop to skip iterations if not present.
  • Formatting and comments

    • Small clarity improvements and comments for future maintainers.

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

  • Reproduced the original crash scenario and confirmed the client no longer crashes. Packages with missing models are skipped cleanly.
  • Verified normal conveyor visuals (chain, wheel, guard) still render correctly for valid packages.
  • No regressions observed during manual playtesting.

Follow-ups / suggestions

  • Optionally add debug/warn logging when a model key is present but there is no registered partial model to aid modpack debugging.
  • Consider adding a generic fallback partial model so packages always display in a basic form instead of being skipped.
  • The change is intentionally minimal and defensive to avoid touching buffer/cache internals.

Files changed

src/main/java/com/simibubi/create/content/kinetics/chainConveyor/ChainConveyorRenderer.java

  • Added defensive null checks for BE, level, and state.
  • Added guarded model resolution before invoking buffer creation.
  • Re-used validated state for model buffer calls.
  • Added level check inside the chain rendering loop.

…esolution before buffer creation; re-used validated state; added level check in chain rendering loop.
@IThundxr
Copy link
Member

IThundxr commented Aug 9, 2025

Can you post the entire log

@serverside-swzo
Copy link
Author

https://mclo.gs/sPjEJAZ

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.

3 participants