Fixes #675 No disabled feature should log spam or crash anymore.

Deprecates the old usage of the AEItemDefinitions via the direct method access of

* blocks()
* parts()
* items()
* materials()

and thus use the new re-direct via definitions().

All definitions are now initialized, no matter what. But SubItems, Items and Blocks are not registered, if by chance are disabled.
This commit is contained in:
thatsIch
2015-01-03 02:53:14 +01:00
parent 3dd81433ac
commit 9986ffc458
385 changed files with 12477 additions and 8292 deletions
@@ -51,47 +51,29 @@ import appeng.client.texture.ExtraBlockTextures;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
@SideOnly(Side.CLIENT)
@SideOnly( Side.CLIENT )
public class BaseBlockRender
{
final int ORIENTATION_BITS = 7;
final static int FLIP_H_BIT = 8;
final static int FLIP_V_BIT = 16;
final double MAX_DISTANCE;
final public boolean hasTESR;
private static final int ORIENTATION_BITS = 7;
private static final int FLIP_H_BIT = 8;
private static final int FLIP_V_BIT = 16;
private static final byte[][][] ORIENTATION_MAP = new byte[6][6][6];
protected int adjustBrightness(int v, double d)
private final boolean hasTESR;
private final double renderDistance;
private final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 );
public BaseBlockRender()
{
int r = 0xff & (v >> 16);
int g = 0xff & (v >> 8);
int b = 0xff & ( v );
r *= d;
g *= d;
b *= d;
r = Math.min( 255, Math.max( 0, r ) );
g = Math.min( 255, Math.max( 0, g ) );
b = Math.min( 255, Math.max( 0, b ) );
return (r << 16) | (g << 8) | b;
this( false, 20 );
}
static public int getOrientation(ForgeDirection in, ForgeDirection forward, ForgeDirection up)
public BaseBlockRender( boolean enableTESR, double tileEntitySpecialRendererRange )
{
if ( in == null || in == ForgeDirection.UNKNOWN // 1
|| forward == null || forward == ForgeDirection.UNKNOWN // 2
|| up == null || up == ForgeDirection.UNKNOWN )
return 0;
int a = in.ordinal();
int b = forward.ordinal();
int c = up.ordinal();
return ORIENTATION_MAP[a][b][c];
this.hasTESR = enableTESR;
this.renderDistance = tileEntitySpecialRendererRange;
setOriMap();
}
static public void setOriMap()
@@ -271,30 +253,76 @@ public class BaseBlockRender
ORIENTATION_MAP[5][2][4] = 1 | FLIP_H_BIT;
}
public BaseBlockRender() {
this( false, 20 );
public boolean hasTESR()
{
return this.hasTESR;
}
public BaseBlockRender(boolean enableTESR, double tileEntitySpecialRendererRange) {
this.hasTESR = enableTESR;
this.MAX_DISTANCE = tileEntitySpecialRendererRange;
setOriMap();
protected int adjustBrightness( int v, double d )
{
int r = 0xff & ( v >> 16 );
int g = 0xff & ( v >> 8 );
int b = 0xff & ( v );
r *= d;
g *= d;
b *= d;
r = Math.min( 255, Math.max( 0, r ) );
g = Math.min( 255, Math.max( 0, g ) );
b = Math.min( 255, Math.max( 0, b ) );
return ( r << 16 ) | ( g << 8 ) | b;
}
public double getTesrRenderDistance()
{
return this.MAX_DISTANCE;
return this.renderDistance;
}
public IIcon firstNotNull(IIcon... s)
public void renderInventory( AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data )
{
for (IIcon o : s)
if ( o != null )
return o;
return ExtraBlockTextures.getMissing();
Tessellator tess = Tessellator.instance;
BlockRenderInfo info = block.getRendererInstance();
if ( info.isValid() )
{
if ( block.hasSubtypes() )
block.setRenderStateByMeta( item.getItemDamage() );
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
}
this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer );
if ( block.hasSubtypes() )
info.setTemporaryRenderIcon( null );
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
}
public void renderInvBlock(EnumSet<ForgeDirection> sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer)
static public int getOrientation( ForgeDirection in, ForgeDirection forward, ForgeDirection up )
{
if ( in == null || in == ForgeDirection.UNKNOWN // 1
|| forward == null || forward == ForgeDirection.UNKNOWN // 2
|| up == null || up == ForgeDirection.UNKNOWN )
return 0;
int a = in.ordinal();
int b = forward.ordinal();
int c = up.ordinal();
return ORIENTATION_MAP[a][b][c];
}
public void renderInvBlock( EnumSet<ForgeDirection> sides, AEBaseBlock block, ItemStack item, Tessellator tess, int color, RenderBlocks renderer )
{
if ( Platform.isDrawing( tess ) )
tess.draw();
@@ -308,13 +336,7 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( 0.0F, -1.0F, 0.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceYNeg(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ),
block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) );
renderer.renderFaceYNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.DOWN ), block.getIcon( ForgeDirection.DOWN.ordinal(), meta ) ) );
tess.draw();
}
@@ -323,13 +345,7 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( 0.0F, 1.0F, 0.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceYPos(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ),
block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) );
renderer.renderFaceYPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.UP ), block.getIcon( ForgeDirection.UP.ordinal(), meta ) ) );
tess.draw();
}
@@ -338,13 +354,7 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( 0.0F, 0.0F, -1.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceZNeg(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ),
block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) );
renderer.renderFaceZNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.NORTH ), block.getIcon( ForgeDirection.NORTH.ordinal(), meta ) ) );
tess.draw();
}
@@ -353,13 +363,7 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( 0.0F, 0.0F, 1.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceZPos(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ),
block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) );
renderer.renderFaceZPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.SOUTH ), block.getIcon( ForgeDirection.SOUTH.ordinal(), meta ) ) );
tess.draw();
}
@@ -368,13 +372,7 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( -1.0F, 0.0F, 0.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceXNeg(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ),
block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) );
renderer.renderFaceXNeg( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.WEST ), block.getIcon( ForgeDirection.WEST.ordinal(), meta ) ) );
tess.draw();
}
@@ -383,60 +381,30 @@ public class BaseBlockRender
tess.startDrawingQuads();
tess.setNormal( 1.0F, 0.0F, 0.0F );
tess.setColorOpaque_I( color );
renderer.renderFaceXPos(
block,
0.0D,
0.0D,
0.0D,
this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ),
block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) );
renderer.renderFaceXPos( block, 0.0D, 0.0D, 0.0D, this.firstNotNull( renderer.overrideBlockTexture, block.getRendererInstance().getTexture( ForgeDirection.EAST ), block.getIcon( ForgeDirection.EAST.ordinal(), meta ) ) );
tess.draw();
}
}
public void renderInventory(AEBaseBlock block, ItemStack item, RenderBlocks renderer, ItemRenderType type, Object[] data)
public IIcon firstNotNull( IIcon... s )
{
Tessellator tess = Tessellator.instance;
BlockRenderInfo info = block.getRendererInstance();
if ( info.isValid() )
{
if ( block.hasSubtypes() )
block.setRenderStateByMeta( item.getItemDamage() );
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip(
getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip(
getOrientation( ForgeDirection.EAST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip(
getOrientation( ForgeDirection.WEST, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip(
getOrientation( ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip(
getOrientation( ForgeDirection.SOUTH, ForgeDirection.SOUTH, ForgeDirection.UP ) );
}
this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer );
if ( block.hasSubtypes() )
info.setTemporaryRenderIcon( null );
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
for ( IIcon o : s )
if ( o != null )
return o;
return ExtraBlockTextures.getMissing();
}
public IOrientable getOrientable(AEBaseBlock block, IBlockAccess w, int x, int y, int z)
public boolean renderInWorld( AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
{
if ( block.hasBlockTileEntity() )
return (AEBaseTile) block.getTileEntity( w, x, y, z );
else if ( block instanceof IOrientableBlock )
return ((IOrientableBlock) block).getOrientable( w, x, y, z );
return null;
this.preRenderInWorld( block, world, x, y, z, renderer );
boolean o = renderer.renderStandardBlock( block, x, y, z );
this.postRenderInWorld( renderer );
return o;
}
public void preRenderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
public void preRenderInWorld( AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer )
{
ForgeDirection forward = ForgeDirection.SOUTH;
ForgeDirection up = ForgeDirection.UP;
@@ -457,80 +425,34 @@ public class BaseBlockRender
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( getOrientation( ForgeDirection.NORTH, forward, up ) );
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( getOrientation( ForgeDirection.SOUTH, forward, up ) );
}
}
public void postRenderInWorld(RenderBlocks renderer)
public void postRenderInWorld( RenderBlocks renderer )
{
renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0;
}
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
public IOrientable getOrientable( AEBaseBlock block, IBlockAccess w, int x, int y, int z )
{
this.preRenderInWorld( block, world, x, y, z, renderer );
boolean o = renderer.renderStandardBlock( block, x, y, z );
this.postRenderInWorld( renderer );
return o;
if ( block.hasBlockTileEntity() )
return (AEBaseTile) block.getTileEntity( w, x, y, z );
else if ( block instanceof IOrientableBlock )
return ( (IOrientableBlock) block ).getOrientable( w, x, y, z );
return null;
}
final FloatBuffer rotMat = BufferUtils.createFloatBuffer( 16 );
protected void applyTESRRotation(double x, double y, double z, ForgeDirection forward, ForgeDirection up)
{
if ( forward != null && up != null )
{
if ( forward == ForgeDirection.UNKNOWN )
forward = ForgeDirection.SOUTH;
if ( up == ForgeDirection.UNKNOWN )
up = ForgeDirection.UP;
ForgeDirection west = Platform.crossProduct( forward, up );
this.rotMat.put( 0, west.offsetX );
this.rotMat.put( 1, west.offsetY );
this.rotMat.put( 2, west.offsetZ );
this.rotMat.put( 3, 0 );
this.rotMat.put( 4, up.offsetX );
this.rotMat.put( 5, up.offsetY );
this.rotMat.put( 6, up.offsetZ );
this.rotMat.put( 7, 0 );
this.rotMat.put( 8, forward.offsetX );
this.rotMat.put( 9, forward.offsetY );
this.rotMat.put( 10, forward.offsetZ );
this.rotMat.put( 11, 0 );
this.rotMat.put( 12, 0 );
this.rotMat.put( 13, 0 );
this.rotMat.put( 14, 0 );
this.rotMat.put( 15, 1 );
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
GL11.glMultMatrix( this.rotMat );
GL11.glTranslated( -0.5, -0.5, -0.5 );
GL11.glCullFace( GL11.GL_FRONT );
}
else
{
GL11.glTranslated( x, y, z );
}
}
protected void setInvRenderBounds(RenderBlocks renderer, int i, int j, int k, int l, int m, int n)
protected void setInvRenderBounds( RenderBlocks renderer, int i, int j, int k, int l, int m, int n )
{
renderer.setRenderBounds( i / 16.0, j / 16.0, k / 16.0, l / 16.0, m / 16.0, n / 16.0 );
}
protected void renderBlockBounds(RenderBlocks renderer,
protected void renderBlockBounds( RenderBlocks renderer,
double minX, double minY, double minZ,
double minX, double minY, double minZ,
double maxX, double maxY, double maxZ,
double maxX, double maxY, double maxZ,
ForgeDirection x, ForgeDirection y, ForgeDirection z)
ForgeDirection x, ForgeDirection y, ForgeDirection z )
{
minX /= 16.0;
minY /= 16.0;
@@ -573,36 +495,8 @@ public class BaseBlockRender
renderer.renderMaxZ = Math.max( aZ, bZ );
}
@SideOnly(Side.CLIENT)
private void renderFace(Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz,
double ua, double ub, double va, double vb, IIcon ico, boolean flip)
{
if ( flip )
{
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ),
ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ),
ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ),
ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ),
ico.getInterpolatedV( va * 16.0 ) );
}
else
{
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ),
ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ),
ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ),
ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ),
ico.getInterpolatedV( vb * 16.0 ) );
}
}
@SideOnly(Side.CLIENT)
protected void renderCutoutFace(Block block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness)
@SideOnly( Side.CLIENT )
protected void renderCutoutFace( Block block, IIcon ico, int x, int y, int z, RenderBlocks renderer, ForgeDirection orientation, float edgeThickness )
{
Tessellator tess = Tessellator.instance;
@@ -617,52 +511,52 @@ public class BaseBlockRender
double layerBZ = 0.0;
boolean flip = false;
switch (orientation)
switch ( orientation )
{
case NORTH:
case NORTH:
layerAX = 1.0;
layerBY = 1.0;
flip = true;
layerAX = 1.0;
layerBY = 1.0;
flip = true;
break;
case SOUTH:
break;
case SOUTH:
layerAX = 1.0;
layerBY = 1.0;
offsetZ = 1.0;
layerAX = 1.0;
layerBY = 1.0;
offsetZ = 1.0;
break;
case EAST:
break;
case EAST:
flip = true;
layerAZ = 1.0;
layerBY = 1.0;
offsetX = 1.0;
flip = true;
layerAZ = 1.0;
layerBY = 1.0;
offsetX = 1.0;
break;
case WEST:
break;
case WEST:
layerAZ = 1.0;
layerBY = 1.0;
layerAZ = 1.0;
layerBY = 1.0;
break;
case UP:
break;
case UP:
flip = true;
layerAX = 1.0;
layerBZ = 1.0;
offsetY = 1.0;
flip = true;
layerAX = 1.0;
layerBZ = 1.0;
offsetY = 1.0;
break;
case DOWN:
break;
case DOWN:
layerAX = 1.0;
layerBZ = 1.0;
layerAX = 1.0;
layerBZ = 1.0;
break;
default:
break;
break;
default:
break;
}
offsetX += x;
@@ -670,82 +564,101 @@ public class BaseBlockRender
offsetZ += z;
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
// u -> u
// u -> u
0, 1.0,
// v -> v
0, edgeThickness, ico, flip );
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
// u -> u
// u -> u
0.0, edgeThickness,
// v -> v
edgeThickness, 1.0 - edgeThickness, ico, flip );
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
// u -> u
// u -> u
1.0 - edgeThickness, 1.0,
// v -> v
edgeThickness, 1.0 - edgeThickness, ico, flip );
this.renderFace( tess, offsetX, offsetY, offsetZ, layerAX, layerAY, layerAZ, layerBX, layerBY, layerBZ,
// u -> u
// u -> u
0, 1.0,
// v -> v
1.0 - edgeThickness, 1.0, ico, flip );
}
@SideOnly(Side.CLIENT)
protected void renderFace(int x, int y, int z, Block block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation)
@SideOnly( Side.CLIENT )
private void renderFace( Tessellator tess, double offsetX, double offsetY, double offsetZ, double ax, double ay, double az, double bx, double by, double bz, double ua, double ub, double va, double vb, IIcon ico, boolean flip )
{
switch (orientation)
if ( flip )
{
case NORTH:
renderer.renderFaceZNeg( block, x, y, z, ico );
break;
case SOUTH:
renderer.renderFaceZPos( block, x, y, z, ico );
break;
case EAST:
renderer.renderFaceXPos( block, x, y, z, ico );
break;
case WEST:
renderer.renderFaceXNeg( block, x, y, z, ico );
break;
case UP:
renderer.renderFaceYPos( block, x, y, z, ico );
break;
case DOWN:
renderer.renderFaceYNeg( block, x, y, z, ico );
break;
default:
break;
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
}
else
{
tess.addVertexWithUV( offsetX + ax * ua + bx * va, offsetY + ay * ua + by * va, offsetZ + az * ua + bz * va, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * va, offsetY + ay * ub + by * va, offsetZ + az * ub + bz * va, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( va * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ub + bx * vb, offsetY + ay * ub + by * vb, offsetZ + az * ub + bz * vb, ico.getInterpolatedU( ub * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
tess.addVertexWithUV( offsetX + ax * ua + bx * vb, offsetY + ay * ua + by * vb, offsetZ + az * ua + bz * vb, ico.getInterpolatedU( ua * 16.0 ), ico.getInterpolatedV( vb * 16.0 ) );
}
}
public void selectFace(RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2)
@SideOnly( Side.CLIENT )
protected void renderFace( int x, int y, int z, Block block, IIcon ico, RenderBlocks renderer, ForgeDirection orientation )
{
switch ( orientation )
{
case NORTH:
renderer.renderFaceZNeg( block, x, y, z, ico );
break;
case SOUTH:
renderer.renderFaceZPos( block, x, y, z, ico );
break;
case EAST:
renderer.renderFaceXPos( block, x, y, z, ico );
break;
case WEST:
renderer.renderFaceXNeg( block, x, y, z, ico );
break;
case UP:
renderer.renderFaceYPos( block, x, y, z, ico );
break;
case DOWN:
renderer.renderFaceYNeg( block, x, y, z, ico );
break;
default:
break;
}
}
public void selectFace( RenderBlocks renderer, ForgeDirection west, ForgeDirection up, ForgeDirection forward, int u1, int u2, int v1, int v2 )
{
v1 = 16 - v1;
v2 = 16 - v2;
double minX = (forward.offsetX > 0 ? 1 : 0) + this.mapFaceUV( west.offsetX, u1 ) + this.mapFaceUV( up.offsetX, v1 );
double minY = (forward.offsetY > 0 ? 1 : 0) + this.mapFaceUV( west.offsetY, u1 ) + this.mapFaceUV( up.offsetY, v1 );
double minZ = (forward.offsetZ > 0 ? 1 : 0) + this.mapFaceUV( west.offsetZ, u1 ) + this.mapFaceUV( up.offsetZ, v1 );
double minX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u1 ) + this.mapFaceUV( up.offsetX, v1 );
double minY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u1 ) + this.mapFaceUV( up.offsetY, v1 );
double minZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u1 ) + this.mapFaceUV( up.offsetZ, v1 );
double maxX = (forward.offsetX > 0 ? 1 : 0) + this.mapFaceUV( west.offsetX, u2 ) + this.mapFaceUV( up.offsetX, v2 );
double maxY = (forward.offsetY > 0 ? 1 : 0) + this.mapFaceUV( west.offsetY, u2 ) + this.mapFaceUV( up.offsetY, v2 );
double maxZ = (forward.offsetZ > 0 ? 1 : 0) + this.mapFaceUV( west.offsetZ, u2 ) + this.mapFaceUV( up.offsetZ, v2 );
double maxX = ( forward.offsetX > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetX, u2 ) + this.mapFaceUV( up.offsetX, v2 );
double maxY = ( forward.offsetY > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetY, u2 ) + this.mapFaceUV( up.offsetY, v2 );
double maxZ = ( forward.offsetZ > 0 ? 1 : 0 ) + this.mapFaceUV( west.offsetZ, u2 ) + this.mapFaceUV( up.offsetZ, v2 );
renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - (forward.offsetX != 0 ? 0 : 0.001) );
renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + (forward.offsetX != 0 ? 0 : 0.001) );
renderer.renderMinX = Math.max( 0.0, Math.min( minX, maxX ) - ( forward.offsetX != 0 ? 0 : 0.001 ) );
renderer.renderMaxX = Math.min( 1.0, Math.max( minX, maxX ) + ( forward.offsetX != 0 ? 0 : 0.001 ) );
renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - (forward.offsetY != 0 ? 0 : 0.001) );
renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + (forward.offsetY != 0 ? 0 : 0.001) );
renderer.renderMinY = Math.max( 0.0, Math.min( minY, maxY ) - ( forward.offsetY != 0 ? 0 : 0.001 ) );
renderer.renderMaxY = Math.min( 1.0, Math.max( minY, maxY ) + ( forward.offsetY != 0 ? 0 : 0.001 ) );
renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - (forward.offsetZ != 0 ? 0 : 0.001) );
renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + (forward.offsetZ != 0 ? 0 : 0.001) );
renderer.renderMinZ = Math.max( 0.0, Math.min( minZ, maxZ ) - ( forward.offsetZ != 0 ? 0 : 0.001 ) );
renderer.renderMaxZ = Math.min( 1.0, Math.max( minZ, maxZ ) + ( forward.offsetZ != 0 ? 0 : 0.001 ) );
}
private double mapFaceUV(int offset, int uv)
private double mapFaceUV( int offset, int uv )
{
if ( offset == 0 )
return 0;
@@ -753,10 +666,10 @@ public class BaseBlockRender
if ( offset > 0 )
return uv / 16.0;
return (16.0 - uv) / 16.0;
return ( 16.0 - uv ) / 16.0;
}
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer )
{
ForgeDirection forward = ForgeDirection.SOUTH;
ForgeDirection up = ForgeDirection.UP;
@@ -789,7 +702,49 @@ public class BaseBlockRender
renderer.uvRotateBottom = renderer.uvRotateTop = renderer.uvRotateEast = renderer.uvRotateWest = renderer.uvRotateNorth = renderer.uvRotateSouth = 0;
}
public void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame)
protected void applyTESRRotation( double x, double y, double z, ForgeDirection forward, ForgeDirection up )
{
if ( forward != null && up != null )
{
if ( forward == ForgeDirection.UNKNOWN )
forward = ForgeDirection.SOUTH;
if ( up == ForgeDirection.UNKNOWN )
up = ForgeDirection.UP;
ForgeDirection west = Platform.crossProduct( forward, up );
this.rotMat.put( 0, west.offsetX );
this.rotMat.put( 1, west.offsetY );
this.rotMat.put( 2, west.offsetZ );
this.rotMat.put( 3, 0 );
this.rotMat.put( 4, up.offsetX );
this.rotMat.put( 5, up.offsetY );
this.rotMat.put( 6, up.offsetZ );
this.rotMat.put( 7, 0 );
this.rotMat.put( 8, forward.offsetX );
this.rotMat.put( 9, forward.offsetY );
this.rotMat.put( 10, forward.offsetZ );
this.rotMat.put( 11, 0 );
this.rotMat.put( 12, 0 );
this.rotMat.put( 13, 0 );
this.rotMat.put( 14, 0 );
this.rotMat.put( 15, 1 );
GL11.glTranslated( x + 0.5, y + 0.5, z + 0.5 );
GL11.glMultMatrix( this.rotMat );
GL11.glTranslated( -0.5, -0.5, -0.5 );
GL11.glCullFace( GL11.GL_FRONT );
}
else
{
GL11.glTranslated( x, y, z );
}
}
public void doRenderItem( ItemStack itemstack, TileEntity par1EntityItemFrame )
{
if ( itemstack != null )
{
@@ -811,5 +766,4 @@ public class BaseBlockRender
GL11.glPopMatrix();
}
}
}
@@ -18,7 +18,9 @@
package appeng.client.render;
import java.util.EnumSet;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
@@ -29,7 +31,11 @@ import net.minecraftforge.common.util.ForgeDirection;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import appeng.api.AEApi;
import appeng.api.exceptions.MissingDefinition;
import appeng.api.parts.IBoxProvider;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartRenderHelper;
@@ -39,43 +45,143 @@ import appeng.block.networking.BlockCableBus;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
@SideOnly(Side.CLIENT)
public class BusRenderHelper implements IPartRenderHelper
@SideOnly( Side.CLIENT )
public final class BusRenderHelper implements IPartRenderHelper
{
public static final BusRenderHelper INSTANCE = new BusRenderHelper();
private static final int HEX_WHITE = 0xffffff;
final public static BusRenderHelper INSTANCE = new BusRenderHelper();
private final BoundBoxCalculator bbc;
private final boolean noAlphaPass;
private final BaseBlockRender bbr;
private final Optional<Block> maybeBlock;
private final Optional<AEBaseBlock> maybeBaseBlock;
private int renderingForPass;
private int currentPass;
private int itemsRendered;
private double minX;
private double minY;
private double minZ;
private double maxX;
private double maxY;
private double maxZ;
private ForgeDirection ax;
private ForgeDirection ay;
private ForgeDirection az;
private int color;
double minX = 0;
double minY = 0;
double minZ = 0;
double maxX = 16;
double maxY = 16;
double maxZ = 16;
final AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
final BaseBlockRender bbr = new BaseBlockRender();
private ForgeDirection ax = ForgeDirection.EAST;
private ForgeDirection ay = ForgeDirection.UP;
private ForgeDirection az = ForgeDirection.SOUTH;
int color = 0xffffff;
class BoundBoxCalculator implements IPartCollisionHelper
public BusRenderHelper()
{
this.bbc = new BoundBoxCalculator( this );
this.noAlphaPass = !AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass );
this.bbr = new BaseBlockRender();
this.renderingForPass = 0;
this.currentPass = 0;
this.itemsRendered = 0;
this.minX = 0;
this.minY = 0;
this.minZ = 0;
this.maxX = 16;
this.maxY = 16;
this.maxZ = 16;
this.ax = ForgeDirection.EAST;
this.az = ForgeDirection.SOUTH;
this.ay = ForgeDirection.UP;
this.color = HEX_WHITE;
this.maybeBlock = AEApi.instance().definitions().blocks().multiPart().maybeBlock();
this.maybeBaseBlock = this.maybeBlock.transform( new BaseBlockTransformFunction() );
}
public boolean started = false;
public int getItemsRendered()
{
return this.itemsRendered;
}
float minX;
float minY;
float minZ;
public void setPass( int pass )
{
this.renderingForPass = 0;
this.currentPass = pass;
this.itemsRendered = 0;
}
float maxX;
float maxY;
float maxZ;
public double getBound( ForgeDirection side )
{
switch ( side )
{
default:
case UNKNOWN:
return 0.5;
case DOWN:
return this.minY;
case EAST:
return this.maxX;
case NORTH:
return this.minZ;
case SOUTH:
return this.maxZ;
case UP:
return this.maxY;
case WEST:
return this.minX;
}
}
public void setRenderColor( int color )
{
for ( Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
{
final BlockCableBus cableBus = (BlockCableBus) block;
cableBus.setRenderColor( color );
}
}
public void setOrientation( ForgeDirection dx, ForgeDirection dy, ForgeDirection dz )
{
this.ax = dx == null ? ForgeDirection.EAST : dx;
this.ay = dy == null ? ForgeDirection.UP : dy;
this.az = dz == null ? ForgeDirection.SOUTH : dz;
}
public double[] getBounds()
{
return new double[] { this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ };
}
public void setBounds( double[] bounds )
{
if ( bounds == null || bounds.length != 6 )
return;
this.minX = bounds[0];
this.minY = bounds[1];
this.minZ = bounds[2];
this.maxX = bounds[3];
this.maxY = bounds[4];
this.maxZ = bounds[5];
}
private static class BoundBoxCalculator implements IPartCollisionHelper
{
private final BusRenderHelper helper;
private boolean started = false;
private float minX;
private float minY;
private float minZ;
private float maxX;
private float maxY;
private float maxZ;
public BoundBoxCalculator( BusRenderHelper helper )
{
this.helper = helper;
}
@Override
public void addBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
public void addBox( double minX, double minY, double minZ, double maxX, double maxY, double maxZ )
{
if ( this.started )
{
@@ -101,19 +207,19 @@ public class BusRenderHelper implements IPartRenderHelper
@Override
public ForgeDirection getWorldX()
{
return BusRenderHelper.this.ax;
return this.helper.ax;
}
@Override
public ForgeDirection getWorldY()
{
return BusRenderHelper.this.ay;
return this.helper.ay;
}
@Override
public ForgeDirection getWorldZ()
{
return BusRenderHelper.this.az;
return this.helper.az;
}
@Override
@@ -121,34 +227,14 @@ public class BusRenderHelper implements IPartRenderHelper
{
return false;
}
}
final BoundBoxCalculator bbc = new BoundBoxCalculator();
int renderingForPass = 0;
int currentPass = 0;
int itemsRendered = 0;
final boolean noAlphaPass = !AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass );
public int getItemsRendered()
{
return this.itemsRendered;
}
public void setPass(int pass)
{
this.renderingForPass = 0;
this.currentPass = pass;
this.itemsRendered = 0;
}
@Override
public void renderForPass(int pass)
} @Override
public void renderForPass( int pass )
{
this.renderingForPass = pass;
}
public boolean renderThis()
{
if ( this.renderingForPass == this.currentPass || this.noAlphaPass )
@@ -169,11 +255,11 @@ public class BusRenderHelper implements IPartRenderHelper
}
@Override
public ISimplifiedBundle useSimplifiedRendering(int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim)
public ISimplifiedBundle useSimplifiedRendering( int x, int y, int z, IBoxProvider p, ISimplifiedBundle sim )
{
RenderBlocksWorkaround rbw = BusRenderer.INSTANCE.renderer;
if ( sim != null && rbw.similarLighting( this.blk, rbw.blockAccess, x, y, z, sim ) )
if ( sim != null && this.maybeBlock.isPresent() && rbw.similarLighting( this.maybeBlock.get(), rbw.blockAccess, x, y, z, sim ) )
{
rbw.populate( sim );
rbw.faces = EnumSet.allOf( ForgeDirection.class );
@@ -217,7 +303,11 @@ public class BusRenderHelper implements IPartRenderHelper
this.setBounds( this.bbc.minX, this.bbc.minY, this.bbc.minZ, this.bbc.maxX, this.bbc.maxY, this.bbc.maxZ );
this.bbr.renderBlockBounds( rbw, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
rbw.renderStandardBlock( this.blk, x, y, z );
for ( Block block : this.maybeBlock.asSet() )
{
rbw.renderStandardBlock( block, x, y, z );
}
rbw.faces = EnumSet.allOf( ForgeDirection.class );
rbw.renderAllFaces = allFaces;
@@ -229,7 +319,7 @@ public class BusRenderHelper implements IPartRenderHelper
}
@Override
public void setBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ)
public void setBounds( float minX, float minY, float minZ, float maxX, float maxY, float maxZ )
{
this.minX = minX;
this.minY = minY;
@@ -239,43 +329,23 @@ public class BusRenderHelper implements IPartRenderHelper
this.maxZ = maxZ;
}
public double getBound(ForgeDirection side)
{
switch (side)
{
default:
case UNKNOWN:
return 0.5;
case DOWN:
return this.minY;
case EAST:
return this.maxX;
case NORTH:
return this.minZ;
case SOUTH:
return this.maxZ;
case UP:
return this.maxY;
case WEST:
return this.minX;
}
}
@Override
public void setInvColor(int newColor)
public void setInvColor( int newColor )
{
this.color = newColor;
}
@Override
public void setTexture(IIcon ico)
public void setTexture( IIcon ico )
{
this.blk.getRendererInstance().setTemporaryRenderIcon( ico );
for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
{
baseBlock.getRendererInstance().setTemporaryRenderIcon( ico );
}
}
@Override
public void setTexture(IIcon Down, IIcon Up, IIcon North, IIcon South, IIcon West, IIcon East)
public void setTexture( IIcon Down, IIcon Up, IIcon North, IIcon South, IIcon West, IIcon East )
{
IIcon[] list = new IIcon[6];
@@ -286,13 +356,13 @@ public class BusRenderHelper implements IPartRenderHelper
list[4] = West;
list[5] = East;
this.blk.getRendererInstance().setTemporaryRenderIcons( list[this.mapRotation( ForgeDirection.UP ).ordinal()],
list[this.mapRotation( ForgeDirection.DOWN ).ordinal()], list[this.mapRotation( ForgeDirection.SOUTH ).ordinal()],
list[this.mapRotation( ForgeDirection.NORTH ).ordinal()], list[this.mapRotation( ForgeDirection.EAST ).ordinal()],
list[this.mapRotation( ForgeDirection.WEST ).ordinal()] );
for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
{
baseBlock.getRendererInstance().setTemporaryRenderIcons( list[this.mapRotation( ForgeDirection.UP ).ordinal()], list[this.mapRotation( ForgeDirection.DOWN ).ordinal()], list[this.mapRotation( ForgeDirection.SOUTH ).ordinal()], list[this.mapRotation( ForgeDirection.NORTH ).ordinal()], list[this.mapRotation( ForgeDirection.EAST ).ordinal()], list[this.mapRotation( ForgeDirection.WEST ).ordinal()] );
}
}
public ForgeDirection mapRotation(ForgeDirection dir)
public ForgeDirection mapRotation( ForgeDirection dir )
{
ForgeDirection forward = this.az;
ForgeDirection up = this.ay;
@@ -305,7 +375,7 @@ public class BusRenderHelper implements IPartRenderHelper
int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ;
int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX;
for (ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS)
for ( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS )
if ( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z )
west = dx;
@@ -328,146 +398,166 @@ public class BusRenderHelper implements IPartRenderHelper
}
@Override
public void renderInventoryBox(RenderBlocks renderer)
public void renderInventoryBox( RenderBlocks renderer )
{
renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 );
this.bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), this.blk, null, Tessellator.instance, this.color, renderer );
for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
{
this.bbr.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), baseBlock, null, Tessellator.instance, this.color, renderer );
}
}
@Override
public void renderInventoryFace(IIcon IIcon, ForgeDirection face, RenderBlocks renderer)
public void renderInventoryFace( IIcon IIcon, ForgeDirection face, RenderBlocks renderer )
{
renderer.setRenderBounds( this.minX / 16.0, this.minY / 16.0, this.minZ / 16.0, this.maxX / 16.0, this.maxY / 16.0, this.maxZ / 16.0 );
this.setTexture( IIcon );
this.bbr.renderInvBlock( EnumSet.of( face ), this.blk, null, Tessellator.instance, this.color, renderer );
for ( AEBaseBlock baseBlock : this.maybeBaseBlock.asSet() )
{
this.bbr.renderInvBlock( EnumSet.of( face ), baseBlock, null, Tessellator.instance, this.color, renderer );
}
}
@Override
public void renderBlock(int x, int y, int z, RenderBlocks renderer)
public void renderBlock( int x, int y, int z, RenderBlocks renderer )
{
if ( !this.renderThis() )
return;
AEBaseBlock blk = (AEBaseBlock) AEApi.instance().blocks().blockMultiPart.block();
BlockRenderInfo info = blk.getRendererInstance();
ForgeDirection forward = BusRenderHelper.INSTANCE.az;
ForgeDirection up = BusRenderHelper.INSTANCE.ay;
for ( Block multiPart : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
{
final AEBaseBlock block = (AEBaseBlock) multiPart;
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) );
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) );
BlockRenderInfo info = block.getRendererInstance();
ForgeDirection forward = BusRenderHelper.INSTANCE.az;
ForgeDirection up = BusRenderHelper.INSTANCE.ay;
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) );
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) );
renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.DOWN, forward, up ) );
renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.UP, forward, up ) );
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) );
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) );
renderer.uvRotateEast = info.getTexture( ForgeDirection.EAST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.EAST, forward, up ) );
renderer.uvRotateWest = info.getTexture( ForgeDirection.WEST ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.WEST, forward, up ) );
this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
renderer.uvRotateNorth = info.getTexture( ForgeDirection.NORTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.NORTH, forward, up ) );
renderer.uvRotateSouth = info.getTexture( ForgeDirection.SOUTH ).setFlip( BaseBlockRender.getOrientation( ForgeDirection.SOUTH, forward, up ) );
renderer.renderStandardBlock( blk, x, y, z );
this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
renderer.renderStandardBlock( block, x, y, z );
}
}
@Override
public Block getBlock()
{
return AEApi.instance().blocks().blockMultiPart.block();
for ( Block block : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() )
{
return block;
}
throw new MissingDefinition( "Tried to access the multi part block." );
}
public void setRenderColor(int color)
{
BlockCableBus blk = (BlockCableBus) AEApi.instance().blocks().blockMultiPart.block();
blk.setRenderColor( color );
}
public void prepareBounds(RenderBlocks renderer)
public void prepareBounds( RenderBlocks renderer )
{
this.bbr.renderBlockBounds( renderer, this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ, this.ax, this.ay, this.az );
}
@Override
public void setFacesToRender(EnumSet<ForgeDirection> faces)
public void setFacesToRender( EnumSet<ForgeDirection> faces )
{
BusRenderer.INSTANCE.renderer.renderFaces = faces;
}
@Override
public void renderBlockCurrentBounds(int x, int y, int z, RenderBlocks renderer)
public void renderBlockCurrentBounds( int x, int y, int z, RenderBlocks renderer )
{
if ( !this.renderThis() )
return;
renderer.renderStandardBlock( this.blk, x, y, z );
for ( Block block : this.maybeBlock.asSet() )
{
renderer.renderStandardBlock( block, x, y, z );
}
}
@Override
public void renderFaceCutout(int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer)
public void renderFaceCutout( int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer )
{
if ( !this.renderThis() )
return;
switch (face)
switch ( face )
{
case DOWN:
face = this.ay.getOpposite();
break;
case EAST:
face = this.ax;
break;
case NORTH:
face = this.az.getOpposite();
break;
case SOUTH:
face = this.az;
break;
case UP:
face = this.ay;
break;
case WEST:
face = this.ax.getOpposite();
break;
case UNKNOWN:
break;
default:
break;
case DOWN:
face = this.ay.getOpposite();
break;
case EAST:
face = this.ax;
break;
case NORTH:
face = this.az.getOpposite();
break;
case SOUTH:
face = this.az;
break;
case UP:
face = this.ay;
break;
case WEST:
face = this.ax.getOpposite();
break;
case UNKNOWN:
break;
default:
break;
}
this.bbr.renderCutoutFace( this.blk, ico, x, y, z, renderer, face, edgeThickness );
for ( Block block : this.maybeBlock.asSet() )
{
this.bbr.renderCutoutFace( block, ico, x, y, z, renderer, face, edgeThickness );
}
}
@Override
public void renderFace(int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer)
public void renderFace( int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer )
{
if ( !this.renderThis() )
return;
this.prepareBounds( renderer );
switch (face)
switch ( face )
{
case DOWN:
face = this.ay.getOpposite();
break;
case EAST:
face = this.ax;
break;
case NORTH:
face = this.az.getOpposite();
break;
case SOUTH:
face = this.az;
break;
case UP:
face = this.ay;
break;
case WEST:
face = this.ax.getOpposite();
break;
case UNKNOWN:
break;
default:
break;
case DOWN:
face = this.ay.getOpposite();
break;
case EAST:
face = this.ax;
break;
case NORTH:
face = this.az.getOpposite();
break;
case SOUTH:
face = this.az;
break;
case UP:
face = this.ay;
break;
case WEST:
face = this.ax.getOpposite();
break;
case UNKNOWN:
break;
default:
break;
}
this.bbr.renderFace( x, y, z, this.blk, ico, renderer, face );
for ( Block block : this.maybeBlock.asSet() )
{
this.bbr.renderFace( x, y, z, block, ico, renderer, face );
}
}
@Override
@@ -488,29 +578,18 @@ public class BusRenderHelper implements IPartRenderHelper
return this.az;
}
public void setOrientation(ForgeDirection dx, ForgeDirection dy, ForgeDirection dz)
private static final class BaseBlockTransformFunction implements Function<Block, AEBaseBlock>
{
this.ax = dx == null ? ForgeDirection.EAST : dx;
this.ay = dy == null ? ForgeDirection.UP : dy;
this.az = dz == null ? ForgeDirection.SOUTH : dz;
@Nullable
@Override
public AEBaseBlock apply( Block input )
{
if ( input instanceof AEBaseBlock )
{
return ( (AEBaseBlock) input );
}
return null;
}
}
public double[] getBounds()
{
return new double[] { this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ };
}
public void setBounds(double[] bounds)
{
if ( bounds == null || bounds.length != 6 )
return;
this.minX = bounds[0];
this.minY = bounds[1];
this.minZ = bounds[2];
this.maxX = bounds[3];
this.maxY = bounds[4];
this.maxZ = bounds[5];
}
}
@@ -20,6 +20,7 @@ package appeng.client.render.blocks;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;
@@ -70,7 +71,12 @@ public class RenderBlockCraftingCPU extends BaseBlockRender
IIcon nonForward = theIcon;
if ( isMonitor )
nonForward = AEApi.instance().blocks().blockCraftingUnit.block().getIcon( 0, meta | (formed ? 8 : 0) );
{
for ( Block craftingBlock : AEApi.instance().definitions().blocks().craftingUnit().maybeBlock().asSet() )
{
nonForward = craftingBlock.getIcon( 0, meta | ( formed ? 8 : 0 ) );
}
}
if ( formed && renderer.overrideBlockTexture == null )
{
@@ -18,8 +18,10 @@
package appeng.client.render.blocks;
import java.util.Collection;
import java.util.EnumSet;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.item.Item;
@@ -30,8 +32,10 @@ import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.api.util.AEColor;
import appeng.api.util.AEColoredItemDefinition;
import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender;
import appeng.client.texture.ExtraBlockTextures;
@@ -40,50 +44,50 @@ import appeng.tile.qnb.TileQuantumBridge;
public class RenderQNB extends BaseBlockRender
{
public void renderCableAt(double Thickness, IBlockAccess world, int x, int y, int z, AEBaseBlock block, RenderBlocks renderer, IIcon texture, double pull,
EnumSet<ForgeDirection> connections)
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.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.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.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.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.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.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.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 );
}
@@ -109,92 +113,91 @@ public class RenderQNB extends BaseBlockRender
renderer.renderAllFaces = true;
if ( tqb.getBlockType() == AEApi.instance().blocks().blockQuantumLink.block() )
final IDefinitions definitions = AEApi.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
for ( Block linkBlock : blocks.quantumLink().maybeBlock().asSet() )
{
if ( tqb.isFormed() )
if ( tqb.getBlockType() == linkBlock )
{
AEColoredItemDefinition glassCableDefinition = AEApi.instance().parts().partCableGlass;
Item transparentGlassCable = glassCableDefinition.item( AEColor.Transparent );
if ( tqb.isFormed() )
{
EnumSet<ForgeDirection> sides = tqb.getConnections();
AEColoredItemDefinition coveredCableDefinition = AEApi.instance().parts().partCableCovered;
Item transparentCoveredCable = coveredCableDefinition.item( AEColor.Transparent );
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 );
EnumSet<ForgeDirection> sides = tqb.getConnections();
this.renderCableAt( 0.11D, world, x, y, z, block, renderer, transparentGlassCable.getIconIndex( glassCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.141D, sides );
this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transparentCoveredCable.getIconIndex( coveredCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.1875D, sides );
}
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 );
}
float renderMin = 2.0f / 16.0f;
float renderMax = 14.0f / 16.0f;
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
renderer.renderStandardBlock( block, x, y, z );
// super.renderWorldBlock(world, x, y, z, block, modelId, renderer);
}
else
{
if ( !tqb.isFormed() )
{
float renderMin = 2.0f / 16.0f;
float renderMax = 14.0f / 16.0f;
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
renderer.renderStandardBlock( block, x, y, z );
}
else if ( tqb.isCorner() )
{
// renderCableAt(0.11D, world, x, y, z, block, modelId,
// renderer,
// AppEngTextureRegistry.Blocks.MECable.get(), true, 0.0D);
AEColoredItemDefinition coveredCableDefinition = AEApi.instance().parts().partCableCovered;
Item transparentCoveredCable = coveredCableDefinition.item( AEColor.Transparent );
this.renderCableAt( 0.188D, world, x, y, z, block, renderer, transparentCoveredCable.getIconIndex( coveredCableDefinition.stack( AEColor.Transparent, 1 ) ), 0.05D,
tqb.getConnections() );
float renderMin = 4.0f / 16.0f;
float renderMax = 12.0f / 16.0f;
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
renderer.renderStandardBlock( block, x, y, z );
if ( tqb.isPowered() )
{
renderMin = 3.9f / 16.0f;
renderMax = 12.1f / 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 );
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side );
}
}
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 );
if ( tqb.isPowered() )
if ( !tqb.isFormed() )
{
renderMin = -0.01f / 16.0f;
renderMax = 16.01f / 16.0f;
float renderMin = 2.0f / 16.0f;
float renderMax = 14.0f / 16.0f;
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
renderer.renderStandardBlock( block, x, y, z );
}
else if ( tqb.isCorner() )
{
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.05D,
tqb.getConnections() );
int bn = 15;
Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F );
Tessellator.instance.setBrightness( bn << 20 | bn << 4 );
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side );
float renderMin = 4.0f / 16.0f;
float renderMax = 12.0f / 16.0f;
renderer.setRenderBounds( renderMin, renderMin, renderMin, renderMax, renderMax, renderMax );
renderer.renderStandardBlock( block, x, y, z );
if ( tqb.isPowered() )
{
renderMin = 3.9f / 16.0f;
renderMax = 12.1f / 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 );
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side );
}
}
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 );
if ( tqb.isPowered() )
{
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 );
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side );
}
}
}
}
@@ -56,8 +56,17 @@ public class RenderQuartzGlass extends BaseBlockRender
boolean isGlass(AEBaseBlock imb, IBlockAccess world, int x, int y, int z)
{
return world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzGlass.block()
|| world.getBlock( x, y, z ) == AEApi.instance().blocks().blockQuartzVibrantGlass.block();
return this.isQuartzGlass( world, x, y, z ) || this.isVibrantQuartzGlass( world, x, y, z );
}
private boolean isQuartzGlass( IBlockAccess world, int x, int y, int z )
{
return AEApi.instance().definitions().blocks().quartzGlass().isSameAs( world, x, y, z );
}
private boolean isVibrantQuartzGlass( IBlockAccess world, int x, int y, int z )
{
return AEApi.instance().definitions().blocks().quartzVibrantGlass().isSameAs( world, x, y, z );
}
void renderEdge(AEBaseBlock imb, IBlockAccess world, int x, int y, int z, RenderBlocks renderer, ForgeDirection side, ForgeDirection direction)
@@ -48,9 +48,9 @@ public class RenderQuartzOre extends BaseBlockRender
public boolean renderInWorld(AEBaseBlock block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer)
{
OreQuartz blk = (OreQuartz) block;
blk.enhanceBrightness = true;
blk.setEnhanceBrightness( true );
super.renderInWorld( block, world, x, y, z, renderer );
blk.enhanceBrightness = false;
blk.setEnhanceBrightness( false );
blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.OreQuartzStone.getIcon() );
boolean out = super.renderInWorld( block, world, x, y, z, renderer );