#1012 Crash with TE texture

This commit is contained in:
CrazyPants committed 2014-09-16 14:11:46 +08:00
1 parent d8e46394d7
commit 7d110ad811
1 file changed
+16 -6
@@ -3,10 +3,12 @@ package crazypants.enderio.machine.painter;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import crazypants.render.CubeRenderer;
import crazypants.render.IconUtil;
public class PaintedBlockRenderer implements ISimpleBlockRenderingHandler {
@@ -44,13 +46,21 @@ public class PaintedBlockRenderer implements ISimpleBlockRenderingHandler {
}
IBlockAccess origBa = rb.blockAccess;
rb.blockAccess = new PaintedBlockAccessWrapper(origBa);
if(srcBlk == block) {
rb.renderStandardBlock(srcBlk, x, y, z);
} else {
rb.renderBlockByRenderType(srcBlk, x, y, z);
try {
rb.blockAccess = new PaintedBlockAccessWrapper(origBa);
if(srcBlk == block) {
rb.renderStandardBlock(srcBlk, x, y, z);
} else {
rb.renderBlockByRenderType(srcBlk, x, y, z);
}
} catch (Exception e) {
//just in case the paint source wont render safely in this way
rb.setOverrideBlockTexture(IconUtil.errorTexture);
rb.renderStandardBlock(Blocks.stone, x, y, z);
rb.setOverrideBlockTexture(null);
} finally {
rb.blockAccess = origBa;
}
rb.blockAccess = origBa;
return true;
}