Fix attrib stack overflow from world-less TESR item renderers (#2159)

This commit is contained in:
micvog authored and GitHub committed 2026-09-28 07:05:46 -07:00
1 parent af599f292e
commit 9814a96b10
2 files changed
+14 -3

No files matched your search

@@ -21,7 +21,17 @@ public final class TesrProviderDispatch {
if (matches == null) return 0;
final Int2IntMap metaMap = matches.get(block);
if (metaMap == null) return 0;
return Math.max(0, metaMap.get(te.getBlockMetadata()));
return Math.max(0, metaMap.get(blockMetadata(te)));
}
/**
* Item renderers often hand a world-less dummy TE to the dispatcher, and some mods override getBlockMetadata()
* to read the world unconditionally (e.g. EFR shulker boxes), so don't call it without a world.
*/
public static int blockMetadata(TileEntity te) {
if (te == null) return 0;
if (te.getWorldObj() == null) return Math.max(0, te.blockMetadata);
return te.getBlockMetadata();
}
public static boolean tryRender(Object renderer, TileEntity te, double x, double y, double z) {
@@ -30,7 +40,7 @@ public final class TesrProviderDispatch {
if (key == null) return false;
CapturedRenderingState.INSTANCE.pushCurrentBlockEntity();
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(te == null ? null : te.getBlockType(), te == null ? 0 : te.getBlockMetadata());
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(te == null ? null : te.getBlockType(), blockMetadata(te));
GLStateManager.glPushMatrix();
try {
provider.angelica$transform(te, x, y, z);