2013-12-27 23:59:59 +01:00
|
|
|
package appeng.client.render.blocks;
|
|
|
|
|
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2014-04-14 09:39:14 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
2014-05-26 03:58:44 +02:00
|
|
|
import appeng.client.texture.ExtraBlockTextures;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.tile.networking.TileController;
|
|
|
|
|
|
|
|
public class RenderBlockController extends BaseBlockRender
|
|
|
|
{
|
|
|
|
|
|
|
|
public RenderBlockController() {
|
|
|
|
super( false, 20 );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean renderInWorld(AEBaseBlock blk, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
|
|
|
|
{
|
|
|
|
|
2014-04-14 09:39:14 +02:00
|
|
|
boolean xx = getTileEntity( world, x - 1, y, z ) instanceof TileController && getTileEntity( world, x + 1, y, z ) instanceof TileController;
|
|
|
|
boolean yy = getTileEntity( world, x, y - 1, z ) instanceof TileController && getTileEntity( world, x, y + 1, z ) instanceof TileController;
|
|
|
|
boolean zz = getTileEntity( world, x, y, z - 1 ) instanceof TileController && getTileEntity( world, x, y, z + 1 ) instanceof TileController;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
int meta = world.getBlockMetadata( x, y, z );
|
|
|
|
boolean hasPower = meta > 0;
|
|
|
|
boolean isConflict = meta == 2;
|
|
|
|
|
2014-05-26 03:58:44 +02:00
|
|
|
ExtraBlockTextures lights = null;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
if ( xx && !yy && !zz )
|
|
|
|
{
|
|
|
|
if ( hasPower )
|
|
|
|
{
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isConflict )
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderer.uvRotateEast = 1;
|
|
|
|
renderer.uvRotateWest = 1;
|
|
|
|
renderer.uvRotateTop = 1;
|
|
|
|
renderer.uvRotateBottom = 1;
|
|
|
|
}
|
|
|
|
else if ( !xx && yy && !zz )
|
|
|
|
{
|
|
|
|
if ( hasPower )
|
|
|
|
{
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isConflict )
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderer.uvRotateEast = 0;
|
|
|
|
renderer.uvRotateNorth = 0;
|
|
|
|
}
|
|
|
|
else if ( !xx && !yy && zz )
|
|
|
|
{
|
|
|
|
if ( hasPower )
|
|
|
|
{
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isConflict )
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnConflict;
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerColumnLights;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
renderer.uvRotateNorth = 1;
|
|
|
|
renderer.uvRotateSouth = 1;
|
|
|
|
renderer.uvRotateTop = 0;
|
|
|
|
}
|
|
|
|
else if ( (xx ? 1 : 0) + (yy ? 1 : 0) + (zz ? 1 : 0) >= 2 )
|
|
|
|
{
|
|
|
|
int v = (Math.abs( x ) + Math.abs( y ) + Math.abs( z )) % 2;
|
|
|
|
renderer.uvRotateEast = renderer.uvRotateBottom = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
|
|
|
|
|
|
|
if ( v == 0 )
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideA.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideB.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( hasPower )
|
|
|
|
{
|
2014-05-26 03:58:44 +02:00
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerPowered.getIcon() );
|
2013-12-27 23:59:59 +01:00
|
|
|
if ( isConflict )
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerConflict;
|
2013-12-27 23:59:59 +01:00
|
|
|
else
|
2014-05-26 03:58:44 +02:00
|
|
|
lights = ExtraBlockTextures.BlockControllerLights;
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean out = renderer.renderStandardBlock( blk, x, y, z );
|
|
|
|
if ( lights != null )
|
|
|
|
{
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
|
|
|
|
Tessellator.instance.setBrightness( 14 << 20 | 14 << 4 );
|
|
|
|
renderer.renderFaceXNeg( blk, x, y, z, lights.getIcon() );
|
|
|
|
renderer.renderFaceXPos( blk, x, y, z, lights.getIcon() );
|
|
|
|
renderer.renderFaceYNeg( blk, x, y, z, lights.getIcon() );
|
|
|
|
renderer.renderFaceYPos( blk, x, y, z, lights.getIcon() );
|
|
|
|
renderer.renderFaceZNeg( blk, x, y, z, lights.getIcon() );
|
|
|
|
renderer.renderFaceZPos( blk, x, y, z, lights.getIcon() );
|
|
|
|
}
|
|
|
|
|
|
|
|
blk.getRendererInstance().setTemporaryRenderIcon( null );
|
|
|
|
renderer.uvRotateEast = renderer.uvRotateBottom = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
|
|
|
|
return out;
|
|
|
|
}
|
2014-04-14 09:39:14 +02:00
|
|
|
|
|
|
|
private TileEntity getTileEntity(IBlockAccess world, int x, int y, int z)
|
|
|
|
{
|
|
|
|
if ( y >= 0 )
|
|
|
|
return world.getTileEntity( x, y, z );
|
|
|
|
return null;
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|