2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client.render;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
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;
|
|
|
|
|
2014-12-29 21:59:05 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
@SideOnly( Side.CLIENT )
|
2013-12-27 23:59:59 +01:00
|
|
|
public class TESRWrapper extends TileEntitySpecialRenderer
|
|
|
|
{
|
|
|
|
|
2015-04-06 00:35:42 +02:00
|
|
|
public final RenderBlocks renderBlocksInstance = new RenderBlocks();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
final BaseBlockRender blkRender;
|
|
|
|
final double MAX_DISTANCE;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
public TESRWrapper( BaseBlockRender render )
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.blkRender = render;
|
|
|
|
this.MAX_DISTANCE = this.blkRender.getTesrRenderDistance();
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-06 00:35:42 +02:00
|
|
|
public final void renderTileEntityAt( TileEntity te, double x, double y, double z, float f )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( te instanceof AEBaseTile )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
Block b = te.getBlockType();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( b instanceof AEBaseBlock && ( (AEBaseTile) te ).requiresTESR() )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( Math.abs( x ) > this.MAX_DISTANCE || Math.abs( y ) > this.MAX_DISTANCE || Math.abs( z ) > this.MAX_DISTANCE )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-02-06 05:36:10 +01:00
|
|
|
return;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
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-06 05:36:10 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.renderBlocksInstance.blockAccess = te.getWorldObj();
|
|
|
|
this.blkRender.renderTile( (AEBaseBlock) b, (AEBaseTile) te, tess, x, y, z, f, this.renderBlocksInstance );
|
2014-02-06 05:36:10 +01:00
|
|
|
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( Throwable t )
|
2014-02-06 05:36:10 +01:00
|
|
|
{
|
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-09-21 00:43:48 +02:00
|
|
|
AELog.severe( "MC will now crash ( probably )!" );
|
2015-03-23 10:14:35 +01:00
|
|
|
throw new IllegalStateException( t );
|
2014-02-06 05:36:10 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|