From af54883fd358b42a8fdbacfcb01dcdc763b458a3 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Wed, 2 Nov 2016 20:44:40 +0100 Subject: [PATCH] Fixes #2558: Make Sky Stone Chest TESR more robust against odd world state, as Vanilla also does. --- .../client/render/tesr/SkyChestTESR.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java index 264c15f3b..513db7349 100644 --- a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java +++ b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java @@ -19,6 +19,7 @@ package appeng.client.render.tesr; +import net.minecraft.block.Block; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; @@ -70,14 +71,8 @@ public class SkyChestTESR extends TileEntitySpecialRenderer } else { - if( te != null ) - { - this.bindTexture( ( (BlockSkyChest) te.getBlockType() ).type == SkyChestType.STONE ? TEXTURE_STONE : TEXTURE_BLOCK ); - } - else - { - this.bindTexture( TEXTURE_BLOCK ); - } + SkyChestType chestType = getChestType( te ); + this.bindTexture( chestType == SkyChestType.STONE ? TEXTURE_STONE : TEXTURE_BLOCK ); } GlStateManager.pushMatrix(); @@ -128,4 +123,20 @@ public class SkyChestTESR extends TileEntitySpecialRenderer } } + // Defensively determine the sky chest type + private static SkyChestType getChestType( TileSkyChest te ) + { + if( te == null ) + { + return SkyChestType.BLOCK; + } + + Block blockType = te.getBlockType(); + if( blockType instanceof BlockSkyChest ) + { + return ( (BlockSkyChest) blockType ).type; + } + return SkyChestType.BLOCK; + } + }