private void pipeGateRender( RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { state.currentTexture = BuildCraftTransport.instance.gateIconProvider.getIcon(state.getGateIconIndex()); float min = Utils.pipeMinPos + 0.05F; float max = Utils.pipeMaxPos - 0.05F; if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) { block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) { block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) { block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) { block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) { block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) { block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); } }
public void renderPipe( RenderBlocks renderblocks, IBlockAccess iblockaccess, Block block, IPipeRenderState renderState, int x, int y, int z) { float minSize = Utils.pipeMinPos; float maxSize = Utils.pipeMaxPos; PipeRenderState state = renderState.getRenderState(); IIconProvider icons = renderState.getPipeIcons(); if (icons == null) return; state.currentTexture = icons.getIcon(state.textureMatrix.getTextureIndex(ForgeDirection.UNKNOWN)); block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize); renderblocks.setRenderBoundsFromBlock(block); renderblocks.renderStandardBlock(block, x, y, z); 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.renderStandardBlock(block, x, y, z); } 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.renderStandardBlock(block, x, y, z); } 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.renderStandardBlock(block, x, y, z); } 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.renderStandardBlock(block, x, y, z); } 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.renderStandardBlock(block, x, y, z); } 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.renderStandardBlock(block, x, y, z); } block.setBlockBounds(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)); pipeWireRender( renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMaxPos, Utils.pipeMinPos, IPipe.WireColor.Red, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Blue)) { state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon( state.wireMatrix.getWireIconIndex(WireColor.Blue)); pipeWireRender( renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMaxPos, Utils.pipeMaxPos, IPipe.WireColor.Blue, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Green)) { state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon( state.wireMatrix.getWireIconIndex(WireColor.Green)); pipeWireRender( renderblocks, block, state, Utils.pipeMaxPos, Utils.pipeMinPos, Utils.pipeMinPos, IPipe.WireColor.Green, x, y, z); } if (state.wireMatrix.hasWire(WireColor.Yellow)) { state.currentTexture = BuildCraftTransport.instance.wireIconProvider.getIcon( state.wireMatrix.getWireIconIndex(WireColor.Yellow)); pipeWireRender( renderblocks, block, state, Utils.pipeMinPos, Utils.pipeMinPos, Utils.pipeMaxPos, IPipe.WireColor.Yellow, x, y, z); } if (state.hasGate()) { pipeGateRender(renderblocks, block, state, x, y, z); } pipeFacadeRenderer(renderblocks, block, state, x, y, z); pipePlugRenderer(renderblocks, block, state, x, y, z); }
private void pipePlugRenderer( RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { float zFightOffset = 1F / 4096F; float[][] zeroState = new float[3][2]; // X START - END zeroState[0][0] = 0.25F + zFightOffset; zeroState[0][1] = 0.75F - zFightOffset; // Y START - END zeroState[1][0] = 0.125F; zeroState[1][1] = 0.25F; // Z START - END zeroState[2][0] = 0.25F + zFightOffset; zeroState[2][1] = 0.75F - zFightOffset; state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.PipeStructureCobblestone); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.plugMatrix.isConnected(direction)) { 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.renderStandardBlock(block, x, y, z); } } // X START - END zeroState[0][0] = 0.25F + 0.125F / 2 + zFightOffset; zeroState[0][1] = 0.75F - 0.125F / 2 + zFightOffset; // Y START - END zeroState[1][0] = 0.25F; zeroState[1][1] = 0.25F + 0.125F; // Z START - END zeroState[2][0] = 0.25F + 0.125F / 2; zeroState[2][1] = 0.75F - 0.125F / 2; state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.PipeStructureCobblestone); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.plugMatrix.isConnected(direction)) { 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.renderStandardBlock(block, x, y, z); } } }
private void pipeFacadeRenderer( RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { float zFightOffset = 1F / 4096F; float[][] zeroState = new float[3][2]; // X START - END zeroState[0][0] = 0.0F - zFightOffset / 2; zeroState[0][1] = 1.0F + zFightOffset / 2; // Y START - END zeroState[1][0] = 0.0F - zFightOffset; zeroState[1][1] = facadeThickness; // Z START - END zeroState[2][0] = 0.0F; zeroState[2][1] = 1.0F; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0) { Block renderBlock = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)]; int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta); if (renderBlock.getRenderType() == 31) { if ((renderMeta & 12) == 4) { renderblocks.uvRotateEast = 1; renderblocks.uvRotateWest = 1; renderblocks.uvRotateTop = 1; renderblocks.uvRotateBottom = 1; } else if ((renderMeta & 12) == 8) { renderblocks.uvRotateSouth = 1; renderblocks.uvRotateNorth = 1; } } // Hollow facade if (state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = deepClone(zeroState); rotated[2][0] = 0.0F; 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.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.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); rotated[0][0] = 0.0F; 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.renderStandardBlock(block, x, y, z); rotated = deepClone(zeroState); rotated[0][0] = Utils.pipeMaxPos; 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.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.renderStandardBlock(block, x, y, z); } if (renderBlock.getRenderType() == 31) { renderblocks.uvRotateSouth = 0; renderblocks.uvRotateEast = 0; renderblocks.uvRotateWest = 0; renderblocks.uvRotateNorth = 0; renderblocks.uvRotateTop = 0; renderblocks.uvRotateBottom = 0; } } } // X START - END zeroState[0][0] = Utils.pipeMinPos; zeroState[0][1] = Utils.pipeMaxPos; // Y START - END zeroState[1][0] = facadeThickness; zeroState[1][1] = Utils.pipeMinPos; // Z START - END zeroState[2][0] = Utils.pipeMinPos; zeroState[2][1] = Utils.pipeMaxPos; state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon( PipeIconProvider.PipeStructureCobblestone); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { 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.renderStandardBlock(block, x, y, z); } } }