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();
}
}
}