Reduce redundant code in pipe world renderer
This commit is contained in:
parent
7c8104c682
commit
0ae4035dab
1 changed files with 35 additions and 63 deletions
|
@ -80,12 +80,12 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
|
||||
private void renderAllFaceExeptAxe(RenderBlocks renderblocks, Block block, Icon icon, int x, int y, int z, char axe) {
|
||||
float minX = (float) block.getBlockBoundsMinX();
|
||||
float minY = (float) block.getBlockBoundsMinY();
|
||||
float minZ = (float) block.getBlockBoundsMinZ();
|
||||
float maxX = (float) block.getBlockBoundsMaxX();
|
||||
float maxY = (float) block.getBlockBoundsMaxY();
|
||||
float maxZ = (float) block.getBlockBoundsMaxZ();
|
||||
float minX = (float) renderblocks.renderMinX;
|
||||
float minY = (float) renderblocks.renderMinY;
|
||||
float minZ = (float) renderblocks.renderMinZ;
|
||||
float maxX = (float) renderblocks.renderMaxX;
|
||||
float maxY = (float) renderblocks.renderMaxY;
|
||||
float maxZ = (float) renderblocks.renderMaxZ;
|
||||
if (axe != 'x') {
|
||||
renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, minX);
|
||||
renderTwoWayXFace(renderblocks, block, icon, x, y, z, minY, minZ, maxY, maxZ, maxX);
|
||||
|
@ -101,20 +101,17 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
}
|
||||
|
||||
private void renderTwoWayXFace(RenderBlocks renderblocks, Block block, Icon icon, int xCoord, int yCoord, int zCoord, float minY, float minZ, float maxY, float maxZ, float x) {
|
||||
block.setBlockBounds(x, minY, minZ, x, maxY, maxZ);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(x, minY, minZ, x, maxY, maxZ);
|
||||
renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
private void renderTwoWayYFace(RenderBlocks renderblocks, Block block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minZ, float maxX, float maxZ, float y) {
|
||||
block.setBlockBounds(minX, y, minZ, maxX, y, maxZ);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minX, y, minZ, maxX, y, maxZ);
|
||||
renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
private void renderTwoWayZFace(RenderBlocks renderblocks, Block block, Icon icon, int xCoord, int yCoord, int zCoord, float minX, float minY, float maxX, float maxY, float z) {
|
||||
block.setBlockBounds(minX, minY, z, maxX, maxY, z);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minX, minY, z, maxX, maxY, z);
|
||||
renderblocks.renderStandardBlock(block, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
|
@ -137,55 +134,48 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.WEST)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.WEST));
|
||||
block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x');
|
||||
west = true;
|
||||
}
|
||||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.EAST)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.EAST));
|
||||
block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'x');
|
||||
east = true;
|
||||
}
|
||||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.DOWN)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.DOWN));
|
||||
block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y');
|
||||
down = true;
|
||||
}
|
||||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.UP)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UP));
|
||||
block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'y');
|
||||
up = true;
|
||||
}
|
||||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.NORTH)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.NORTH));
|
||||
block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z');
|
||||
north = true;
|
||||
}
|
||||
|
||||
if (state.pipeConnectionMatrix.isConnected(ForgeDirection.SOUTH)) {
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.SOUTH));
|
||||
block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
|
||||
renderAllFaceExeptAxe(renderblocks, block, state.currentTexture, x, y, z, 'z');
|
||||
south = true;
|
||||
}
|
||||
|
||||
state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN));
|
||||
block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
|
||||
if (!west)
|
||||
renderTwoWayXFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, minSize);
|
||||
if (!east)
|
||||
|
@ -199,7 +189,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
if (!south)
|
||||
renderTwoWayZFace(renderblocks, block, state.currentTexture, x, y, z, minSize, minSize, maxSize, maxSize, maxSize);
|
||||
|
||||
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if (state.wireMatrix.hasWire(WireColor.Red)) {
|
||||
state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon(state.wireMatrix.getWireIconIndex(WireColor.Red));
|
||||
|
@ -277,16 +267,14 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
rotated[2][1] = Utils.pipeMinPos;
|
||||
rotated[1][0] -= zFightOffset / 2;
|
||||
transform(rotated, direction);
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
|
||||
rotated = deepClone(zeroState);
|
||||
rotated[2][0] = Utils.pipeMaxPos;
|
||||
rotated[1][0] -= zFightOffset / 2;
|
||||
transform(rotated, direction);
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
|
||||
rotated = deepClone(zeroState);
|
||||
|
@ -294,8 +282,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
rotated[0][1] = Utils.pipeMinPos;
|
||||
rotated[1][1] -= zFightOffset;
|
||||
transform(rotated, direction);
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
|
||||
rotated = deepClone(zeroState);
|
||||
|
@ -303,14 +290,12 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
rotated[0][1] = 1F;
|
||||
rotated[1][1] -= zFightOffset;
|
||||
transform(rotated, direction);
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
} else { // Solid facade
|
||||
float[][] rotated = deepClone(zeroState);
|
||||
transform(rotated, direction);
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
|
@ -344,8 +329,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
float[][] rotated = deepClone(zeroState);
|
||||
transform(rotated, direction);
|
||||
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -373,8 +357,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
float[][] rotated = deepClone(zeroState);
|
||||
transform(rotated, direction);
|
||||
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -396,8 +379,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
float[][] rotated = deepClone(zeroState);
|
||||
transform(rotated, direction);
|
||||
|
||||
block.setBlockBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -496,34 +478,30 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
// Z render
|
||||
|
||||
if (minZ != Utils.pipeMinPos || maxZ != Utils.pipeMaxPos || !found) {
|
||||
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx
|
||||
renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, minZ, cx == Utils.pipeMinPos ? cx
|
||||
: cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, maxZ);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
// X render
|
||||
|
||||
if (minX != Utils.pipeMinPos || maxX != Utils.pipeMaxPos || !found) {
|
||||
block.setBlockBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy
|
||||
renderblocks.setRenderBounds(minX, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz, maxX, cy == Utils.pipeMinPos ? cy
|
||||
: cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
// Y render
|
||||
|
||||
if (minY != Utils.pipeMinPos || maxY != Utils.pipeMaxPos || !found) {
|
||||
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx
|
||||
renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, minY, cz == Utils.pipeMinPos ? cz - 0.05F : cz, cx == Utils.pipeMinPos ? cx
|
||||
: cx + 0.05F, maxY, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (center || !found) {
|
||||
block.setBlockBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
|
||||
renderblocks.setRenderBounds(cx == Utils.pipeMinPos ? cx - 0.05F : cx, cy == Utils.pipeMinPos ? cy - 0.05F : cy, cz == Utils.pipeMinPos ? cz - 0.05F : cz,
|
||||
cx == Utils.pipeMinPos ? cx : cx + 0.05F, cy == Utils.pipeMinPos ? cy : cy + 0.05F, cz == Utils.pipeMinPos ? cz : cz + 0.05F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
|
@ -537,38 +515,32 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
|
||||
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos + 0.001F, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
|
||||
block.setBlockBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(Utils.pipeMaxPos + 0.001F, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
|
||||
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos + 0.001F, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
|
||||
block.setBlockBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(min, Utils.pipeMaxPos + 0.001F, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos + 0.001F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.setRenderBounds(min, min, Utils.pipeMaxPos + 0.001F, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue