2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client.render;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import appeng.block.AEBaseBlock;
|
2014-02-07 21:37:22 +01:00
|
|
|
import appeng.core.AELog;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.tile.AEBaseTile;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.util.Platform;
|
2014-02-07 06:51:19 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-07 06:51:19 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-12-27 23:59:59 +01:00
|
|
|
public class TESRWrapper extends TileEntitySpecialRenderer
|
|
|
|
{
|
|
|
|
|
|
|
|
final public RenderBlocks rbinstance = new RenderBlocks();
|
|
|
|
|
|
|
|
final BaseBlockRender blkRender;
|
|
|
|
final double MAX_DISTANCE;
|
|
|
|
|
|
|
|
public TESRWrapper(BaseBlockRender render) {
|
|
|
|
blkRender = render;
|
|
|
|
MAX_DISTANCE = blkRender.getTesrRenderDistance();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
final public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f)
|
|
|
|
{
|
2014-02-06 05:36:10 +01:00
|
|
|
if ( te instanceof AEBaseTile )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
Block b = te.getBlockType();
|
|
|
|
|
2014-02-06 05:36:10 +01:00
|
|
|
if ( b instanceof AEBaseBlock && ((AEBaseTile) te).requiresTESR() )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-06 05:36:10 +01:00
|
|
|
if ( Math.abs( x ) > MAX_DISTANCE || Math.abs( y ) > MAX_DISTANCE || Math.abs( z ) > MAX_DISTANCE )
|
|
|
|
return;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-06 05:36:10 +01:00
|
|
|
Tessellator tess = Tessellator.instance;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( Platform.isDrawing( tess ) )
|
2014-02-06 05:36:10 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
rbinstance.blockAccess = te.getWorldObj();
|
2014-02-06 05:36:10 +01:00
|
|
|
blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, rbinstance );
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
if ( Platform.isDrawing( tess ) )
|
2014-02-06 05:36:10 +01:00
|
|
|
throw new RuntimeException( "Error durring rendering." );
|
|
|
|
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.severe( "Hi, Looks like there was a crash while rendering something..." );
|
2014-02-06 05:36:10 +01:00
|
|
|
t.printStackTrace();
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.severe( "MC will now crash ( probobly )!" );
|
2014-02-06 05:36:10 +01:00
|
|
|
throw new RuntimeException( t );
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|