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>.
|
|
|
|
*/
|
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
package appeng.client.render.blocks;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
import java.util.Collection;
|
2014-09-24 02:26:27 +02:00
|
|
|
import java.util.EnumSet;
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
import net.minecraft.block.Block;
|
2014-09-24 02:26:27 +02:00
|
|
|
import net.minecraft.client.renderer.RenderBlocks;
|
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IBlocks;
|
|
|
|
import appeng.api.definitions.IDefinitions;
|
|
|
|
import appeng.api.definitions.IParts;
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.api.util.AEColor;
|
|
|
|
import appeng.block.AEBaseBlock;
|
|
|
|
import appeng.client.render.BaseBlockRender;
|
|
|
|
import appeng.client.texture.ExtraBlockTextures;
|
|
|
|
import appeng.tile.qnb.TileQuantumBridge;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
public class RenderQNB extends BaseBlockRender
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public void renderInventory( AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] obj )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
float minPx = 2.0f / 16.0f;
|
|
|
|
float maxPx = 14.0f / 16.0f;
|
|
|
|
renderer.setRenderBounds( minPx, minPx, minPx, maxPx, maxPx, maxPx );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
super.renderInventory( block, item, renderer, type, obj );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-03 08:54:31 +02:00
|
|
|
public boolean renderInWorld( AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
|
|
|
TileQuantumBridge tqb = block.getTileEntity( world, x, y, z );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tqb == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
return false;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
renderer.renderAllFaces = true;
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
final IDefinitions definitions = AEApi.instance().definitions();
|
|
|
|
final IBlocks blocks = definitions.blocks();
|
|
|
|
final IParts parts = definitions.parts();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( Block linkBlock : blocks.quantumLink().maybeBlock().asSet() )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tqb.getBlockType() == linkBlock )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tqb.isFormed() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
EnumSet<ForgeDirection> sides = tqb.getConnections();
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
Item transGlassCable = parts.cableGlass().item( AEColor.Transparent );
|
|
|
|
this.renderCableAt( 0.11D, world, x, y, z, block, renderer, transGlassCable.getIconIndex( parts.cableGlass().stack( AEColor.Transparent, 1 ) ), 0.141D, sides );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
Item transCoveredCable = parts.cableCovered().item( AEColor.Transparent );
|
|
|
|
this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transCoveredCable.getIconIndex( parts.cableCovered().stack( AEColor.Transparent, 1 ) ), 0.1875D, sides );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
float renderMin = 2.0f / 16.0f;
|
|
|
|
float renderMax = 14.0f / 16.0f;
|
|
|
|
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
|
2014-09-24 02:26:27 +02:00
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
else
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( !tqb.isFormed() )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
float renderMin = 2.0f / 16.0f;
|
|
|
|
float renderMax = 14.0f / 16.0f;
|
2014-09-28 11:47:17 +02:00
|
|
|
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
else if( tqb.isCorner() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
Item transCoveredCable = parts.cableCovered().item( AEColor.Transparent );
|
2015-04-03 08:54:31 +02:00
|
|
|
this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transCoveredCable.getIconIndex( parts.cableCovered().stack( AEColor.Transparent, 1 ) ), 0.05D, tqb.getConnections() );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
float renderMin = 4.0f / 16.0f;
|
|
|
|
float renderMax = 12.0f / 16.0f;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tqb.isPowered() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
renderMin = 3.9f / 16.0f;
|
|
|
|
renderMax = 12.1f / 16.0f;
|
|
|
|
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
int bn = 15;
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
|
|
|
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
float renderMin = 2.0f / 16.0f;
|
|
|
|
float renderMax = 14.0f / 16.0f;
|
|
|
|
renderer.setRenderBounds( 0, renderMin, renderMin, 1, renderMax, renderMax );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
|
|
|
|
renderer.setRenderBounds( renderMin, 0, renderMin, renderMax, 1, renderMax );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
|
|
|
|
renderer.setRenderBounds( renderMin, renderMin, 0, renderMax, renderMax, 1 );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( tqb.isPowered() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
|
|
|
renderMin = -0.01f / 16.0f;
|
|
|
|
renderMax = 16.01f / 16.0f;
|
|
|
|
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
|
|
|
|
|
|
|
|
int bn = 15;
|
|
|
|
Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
|
|
|
|
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
renderer.renderAllFaces = false;
|
|
|
|
return true;
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
|
|
|
|
public void renderCableAt( double thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, IIcon texture, double pull, Collection<ForgeDirection> connections )
|
|
|
|
{
|
|
|
|
block.getRendererInstance().setTemporaryRenderIcon( texture );
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.UNKNOWN ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.5D - thickness, 0.5D + thickness, 0.5D + thickness, 0.5D + thickness );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.WEST ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.0D, 0.5D - thickness, 0.5D - thickness, 0.5D - thickness - pull, 0.5D + thickness, 0.5D + thickness );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.EAST ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D + thickness + pull, 0.5D - thickness, 0.5D - thickness, 1.0D, 0.5D + thickness, 0.5D + thickness );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.NORTH ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.0D, 0.5D + thickness, 0.5D + thickness, 0.5D - thickness - pull );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.SOUTH ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D - thickness, 0.5D - thickness, 0.5D + thickness + pull, 0.5D + thickness, 0.5D + thickness, 1.0D );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.DOWN ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D - thickness, 0.0D, 0.5D - thickness, 0.5D + thickness, 0.5D - thickness - pull, 0.5D + thickness );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( connections.contains( ForgeDirection.UP ) )
|
|
|
|
{
|
|
|
|
renderer.setRenderBounds( 0.5D - thickness, 0.5D + thickness + pull, 0.5D - thickness, 0.5D + thickness, 1.0D, 0.5D + thickness );
|
|
|
|
renderer.renderStandardBlock( block, x, y, z );
|
|
|
|
}
|
|
|
|
|
|
|
|
block.getRendererInstance().setTemporaryRenderIcon( null );
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|