Description
Game crashes with java.lang.IllegalStateException: Pose stack not empty
during world rendering when an NPC using a Geckolib model holds an item.
Root cause
In RenderCustomModel.renderItem(), poseStack.pushPose() and
poseStack.popPose() are not exception-safe:
poseStack.pushPose();
... transforms ...
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ...);
poseStack.popPose();
If renderStatic(...) throws for any reason (broken/unsupported item
render, etc.), popPose() is skipped, leaving the frame's PoseStack
unbalanced. Minecraft's own end-of-frame check in LevelRenderer then
throws "Pose stack not empty" and crashes the whole game — not just
the NPC render.
Suggested fix
Wrap the push/pop in try/finally so the stack is always balanced,
even if item rendering fails:
poseStack.pushPose();
try {
... transforms ...
Minecraft.getInstance().getItemRenderer().renderStatic(stack, ...);
} catch (Throwable t) {
// don't let one broken item crash the whole render frame
} finally {
poseStack.popPose();
}
This has zero effect on the normal render path — it only prevents a
single failed item render from taking down the entire game.
Crash report
(прикрепи файл crash-2026-07-26_09.50.09-client.txt или вставь ключевую часть —
особенно стектрейс "IllegalStateException: Pose stack not empty" и Mod List)
Environment
- Minecraft 1.20.1, Forge 47.4.10
crashReport.txt
- CNPC-Gecko-Addon 1.20.1-1.0.6
- CustomNPCs GBPort Unofficial 1.20.1.20260227
Description
Game crashes with
java.lang.IllegalStateException: Pose stack not emptyduring world rendering when an NPC using a Geckolib model holds an item.
Root cause
In
RenderCustomModel.renderItem(),poseStack.pushPose()andposeStack.popPose()are not exception-safe:If
renderStatic(...)throws for any reason (broken/unsupported itemrender, etc.),
popPose()is skipped, leaving the frame's PoseStackunbalanced. Minecraft's own end-of-frame check in LevelRenderer then
throws "Pose stack not empty" and crashes the whole game — not just
the NPC render.
Suggested fix
Wrap the push/pop in try/finally so the stack is always balanced,
even if item rendering fails:
This has zero effect on the normal render path — it only prevents a
single failed item render from taking down the entire game.
Crash report
(прикрепи файл crash-2026-07-26_09.50.09-client.txt или вставь ключевую часть —
особенно стектрейс "IllegalStateException: Pose stack not empty" и Mod List)
Environment
crashReport.txt