public boolean renderAlgae(
      IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer) {

    block.setBlockBounds(0.0F, 0.0F - 0.125F, 0.0F, 1.0F, 0.0F - 0.0625F, 1.0F);
    renderer.renderStandardBlock(block, x, y, z);
    float var7 = 0.5F;
    float var8 = 0.015625F;
    block.setBlockBounds(0.5F - var7, 0.0F - 0.125F, 0.5F - var7, 0.5F + var7, var8, 0.5F + var7);
    return true;
  }
  @Override
  public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {

    if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {

      EntityRenderIndex index = new EntityRenderIndex(block, metadata);
      if (blockByEntityRenders.containsKey(index)) {
        blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
      }

    } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
      Tessellator tessellator = Tessellator.instance;

      block.setBlockBounds(
          Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
      renderer.func_83018_a(block);
      block.setBlockBoundsForItemRender();
      GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, -1F, 0.0F);
      renderer.renderBottomFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 1.0F, 0.0F);
      renderer.renderTopFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 0.0F, -1F);
      renderer.renderEastFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 0.0F, 1.0F);
      renderer.renderWestFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(-1F, 0.0F, 0.0F);
      renderer.renderNorthFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(1.0F, 0.0F, 0.0F);
      renderer.renderSouthFace(
          block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, metadata));
      tessellator.draw();
      GL11.glTranslatef(0.5F, 0.5F, 0.5F);
      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }
  }
  @Override
  public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {

    if (block.getRenderType() == BuildCraftCore.blockByEntityModel) {

      EntityRenderIndex index = new EntityRenderIndex(block, metadata);
      if (blockByEntityRenders.containsKey(index)) {
        blockByEntityRenders.get(index).inventoryRender(-0.5, -0.5, -0.5, 0, 0);
      }

    } else if (block.getRenderType() == BuildCraftCore.legacyPipeModel) {
      Tessellator tessellator = Tessellator.instance;

      block.setBlockBounds(
          CoreConstants.PIPE_MIN_POS,
          0.0F,
          CoreConstants.PIPE_MIN_POS,
          CoreConstants.PIPE_MAX_POS,
          1.0F,
          CoreConstants.PIPE_MAX_POS);
      renderer.setRenderBoundsFromBlock(block);
      block.setBlockBoundsForItemRender();
      GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, -1F, 0.0F);
      renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 1.0F, 0.0F);
      renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 0.0F, -1F);
      renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(0.0F, 0.0F, 1.0F);
      renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(-1F, 0.0F, 0.0F);
      renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata));
      tessellator.draw();
      tessellator.startDrawingQuads();
      tessellator.setNormal(1.0F, 0.0F, 0.0F);
      renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata));
      tessellator.draw();
      GL11.glTranslatef(0.5F, 0.5F, 0.5F);
      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }
  }
  @Override
  public void renderInventoryBlock(Block block, int i, int j, RenderBlocks renderblocks) {
    block.setBlockBounds(
        Utils.pipeMinPos, 0.0F, Utils.pipeMinPos, Utils.pipeMaxPos, 1.0F, Utils.pipeMaxPos);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1);
    renderblocks.setRenderBoundsFromBlock(block);
    renderBlockInInv(renderblocks, block, 0);

    block.setBlockBounds(5F / 16F, 4F / 16F, 5F / 16F, 11F / 16F, 13F / 16F, 11F / 16F);
    renderblocks.setRenderBoundsFromBlock(block);
    renderBlockInInv(renderblocks, block, 1);

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  }
 public void toBlockBounds(Block b) {
   b.setBlockBounds(
       (minX - 16) / 16F,
       (minY - 16) / 16F,
       (minZ - 16) / 16F,
       (maxX - 16) / 16F,
       (maxY - 16) / 16F,
       (maxZ - 16) / 16F);
 }
  private boolean renderSponge(
      RenderBlocks var1, IBlockAccess var2, int var3, int var4, int var5, Block var6) {
    int var7 = var2.getBlockMetadata(var3, var4, var5);
    if (var7 == 0) {
      var6.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.25F, 0.625F);
      var1.renderStandardBlock(var6, var3, var4, var5);
    } else if (var7 == 1) {
      var6.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
      var1.renderStandardBlock(var6, var3, var4, var5);
    } else if (var7 == 2) {
      var6.setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 0.75F, 0.875F);
      var1.renderStandardBlock(var6, var3, var4, var5);
    }

    var1.renderBlockLiquid(Blocks.water, var3, var4, var5);

    return true;
  }
 private void renderInvCuboid(
     RenderBlocks renderer,
     Block block,
     float minX,
     float minY,
     float minZ,
     float maxX,
     float maxY,
     float maxZ,
     Icon icon) {
   Tessellator tessellator = Tessellator.instance;
   block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
   renderer.setRenderBoundsFromBlock(block);
   GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
   block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
   renderer.setRenderBoundsFromBlock(block);
   tessellator.startDrawingQuads();
   tessellator.setNormal(0.0F, -1F, 0.0F);
   renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   tessellator.startDrawingQuads();
   tessellator.setNormal(0.0F, 1.0F, 0.0F);
   renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   tessellator.startDrawingQuads();
   tessellator.setNormal(0.0F, 0.0F, -1F);
   renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   tessellator.startDrawingQuads();
   tessellator.setNormal(0.0F, 0.0F, 1.0F);
   renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   tessellator.startDrawingQuads();
   tessellator.setNormal(-1F, 0.0F, 0.0F);
   renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   tessellator.startDrawingQuads();
   tessellator.setNormal(1.0F, 0.0F, 0.0F);
   renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
   tessellator.draw();
   GL11.glTranslatef(0.5F, 0.5F, 0.5F);
   block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
   renderer.setRenderBoundsFromBlock(block);
 }
  /* LEGACY PIPE RENDERING and quarry frames! */
  private void legacyPipeRender(
      RenderBlocks renderblocks,
      IBlockAccess iblockaccess,
      int i,
      int j,
      int k,
      Block block,
      int l) {
    float minSize = CoreConstants.PIPE_MIN_POS;
    float maxSize = CoreConstants.PIPE_MAX_POS;

    block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
    renderblocks.setRenderBoundsFromBlock(block);
    renderblocks.renderStandardBlock(block, i, j, k);

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i - 1, j, k)) {
      block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i + 1, j, k)) {
      block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j - 1, k)) {
      block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j + 1, k)) {
      block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k - 1)) {
      block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k + 1)) {
      block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  }
  /* LEGACY PIPE RENDERING */
  private void legacyPipeRender(
      RenderBlocks renderblocks,
      IBlockAccess iblockaccess,
      int i,
      int j,
      int k,
      Block block,
      int l) {
    float minSize = Utils.pipeMinPos;
    float maxSize = Utils.pipeMaxPos;

    block.setBlockBounds(minSize, minSize, minSize, maxSize, maxSize, maxSize);
    renderblocks.func_83018_a(block);
    renderblocks.renderStandardBlock(block, i, j, k);

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i - 1, j, k)) {
      block.setBlockBounds(0.0F, minSize, minSize, minSize, maxSize, maxSize);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i + 1, j, k)) {
      block.setBlockBounds(maxSize, minSize, minSize, 1.0F, maxSize, maxSize);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j - 1, k)) {
      block.setBlockBounds(minSize, 0.0F, minSize, maxSize, minSize, maxSize);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j + 1, k)) {
      block.setBlockBounds(minSize, maxSize, minSize, maxSize, 1.0F, maxSize);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k - 1)) {
      block.setBlockBounds(minSize, minSize, 0.0F, maxSize, maxSize, minSize);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    if (Utils.checkLegacyPipesConnections(iblockaccess, i, j, k, i, j, k + 1)) {
      block.setBlockBounds(minSize, minSize, maxSize, maxSize, maxSize, 1.0F);
      renderblocks.func_83018_a(block);
      renderblocks.renderStandardBlock(block, i, j, k);
    }

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  }
Example #10
0
  public static void setSudisBlockBoundsBasedOnState(
      Block block, IBlockAccess blockAccess, int x, int y, int z, int yOffset) {
    TileEntitySudis tileEntitySudis = (TileEntitySudis) blockAccess.getBlockTileEntity(x, y, z);

    int connectCount = 0;
    float f = 0.375F;
    float f1 = 0.625F;
    float f2 = 0.375F;
    float f3 = 0.625F;

    if (tileEntitySudis != null && tileEntitySudis.getHasMultipleSudes()) {
      boolean flag = canConnectSudisTo(blockAccess, x, y, z - 1);
      boolean flag1 = canConnectSudisTo(blockAccess, x, y, z + 1);
      boolean flag2 = canConnectSudisTo(blockAccess, x - 1, y, z);
      boolean flag3 = canConnectSudisTo(blockAccess, x + 1, y, z);
      if (flag) {
        connectCount++;
      }
      if (flag1) {
        connectCount++;
      }
      if (flag2) {
        connectCount++;
      }
      if (flag3) {
        connectCount++;
      }
      if (connectCount == 0) {
        int metadata = blockAccess.getBlockMetadata(x, y, z);
        int facing = metadata & BlockHelper.MASK_DIR;
        if (facing == BlockHelper.META_DIR_NORTH || facing == BlockHelper.META_DIR_SOUTH) {
          f = .0f;
          f1 = 1.0f;
        } else {
          f2 = .0f;
          f3 = 1.0f;
        }
      } else {
        if (flag || (flag1 && connectCount <= 1)) {
          f2 = 0.0F;
        }
        if (flag1 || (flag && connectCount <= 1)) {
          f3 = 1.0F;
        }
        if (flag2 || (flag3 && connectCount <= 1)) {
          f = 0.0F;
        }
        if (flag3 || (flag2 && connectCount <= 1)) {
          f1 = 1.0F;
        }
      }
    }

    block.setBlockBounds(f, yOffset, f2, f1, MODEL_SUDIS_HEIGHT + yOffset, f3);
  }
 private boolean renderCoral(
     RenderBlocks var1, IBlockAccess var2, int var3, int var4, int var5, Block var6) {
   if (var2.getBlock(var3, var4, var5) instanceof BlockCoral) {
     if (var2.getBlockMetadata(var3, var4, var5) % 8 == 6) {
       var6.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.25F, 0.625F);
       var1.renderStandardBlock(var6, var3, var4, var5);
     } else if (var2.getBlockMetadata(var3, var4, var5) % 8 == 2) {
       var6.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.5F, 0.75F);
       var1.renderStandardBlock(var6, var3, var4, var5);
     } else {
       var6.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
       var1.renderCrossedSquares(var6, var3, var4, var5);
     }
   } else {
     var6.setBlockBounds(0.25F, 0.0F, 0.25F, 0.75F, 0.75F, 0.75F);
     var1.renderCrossedSquares(var6, var3, var4, var5);
   }
   var1.renderBlockLiquid(Blocks.water, var3, var4, var5);
   return true;
 }
  public void setBoundsOnBlock(Block block) {
    if (haveBlockBounds) {
      block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
      return;
    }
    if (hasSkin()) {
      Skin skin = null;
      if (worldObj.isRemote) {
        skin = getSkinClient(skinPointer);
      } else {
        skin = getSkinServer(skinPointer);
      }

      if (skin != null) {
        float scale = 0.0625F;
        SkinPart skinPart = skin.getParts().get(0);
        Rectangle3D rec = skinPart.getPartBounds();
        IRectangle3D buildSpace = skinPart.getPartType().getBuildingSpace();

        int x = buildSpace.getX() + buildSpace.getWidth() + rec.getX();
        int y = buildSpace.getY() + buildSpace.getHeight() - rec.getY() - rec.getHeight();
        int z = buildSpace.getZ() + buildSpace.getDepth() - rec.getZ() - rec.getDepth();
        minX = x * scale;
        minY = y * scale;
        minZ = z * scale;
        maxX = (x + rec.getWidth()) * scale;
        maxY = (y + rec.getHeight()) * scale;
        maxZ = (z + rec.getDepth()) * scale;
        rotateBlockBounds();
        haveBlockBounds = true;
        block.setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
        return;
      }
    }
    block.setBlockBounds(0F, 0F, 0F, 1F, 1F, 1F);
  }
 @Override
 public boolean addCollisionBoxesToList(
     Block ignore, AxisAlignedBB aabb, List<AxisAlignedBB> list, Entity entity) {
   Block block = new Block(Material.rock);
   ClayState state = getState();
   if (state == ClayState.WET) {
     block.setBlockBounds(0, 0, 0, 1, 1F / 8F, 1);
     AxisAlignedBB a = block.getCollisionBoundingBox(worldObj, pos, null);
     if (aabb.intersectsWith(a)) {
       list.add(a);
     }
   }
   for (ClayLump lump : parts) {
     lump.toRotatedBlockBounds(this, block);
     AxisAlignedBB a = block.getCollisionBoundingBox(worldObj, pos, null);
     if (aabb.intersectsWith(a)) {
       list.add(a);
     }
   }
   return true;
 }
 private void setBlockBoundsBasedOnSelection(World world, int x, int y, int z) {
   float m = ConfigurationLib.littleBlocksSize;
   if (xSelected == -10) {
     this.setBlockBounds(0f, 0f, 0f, 0f, 0f, 0f);
   } else {
     TileEntityLittleChunk tile = (TileEntityLittleChunk) world.getTileEntity(x, y, z);
     Block block = tile.getBlock(xSelected, ySelected, zSelected);
     // System.out.println("Content: " + content);
     if (block == null) {
       this.setBlockBounds(
           xSelected / m,
           ySelected / m,
           zSelected / m,
           (xSelected + 1) / m,
           (ySelected + 1) / m,
           (zSelected + 1) / m);
     } else {
       if (block != null) {
         if (BlockStairs.func_150148_a /* isBlockStairsID */(block)) {
           block.setBlockBounds(0, 0, 0, 1, 1, 1);
         } else {
           block.setBlockBoundsBasedOnState(
               tile.getLittleWorld(),
               (x << 3) + xSelected,
               (y << 3) + ySelected,
               (z << 3) + zSelected);
         }
         this.setBlockBounds(
             (float) (xSelected + block.getBlockBoundsMinX()) / m,
             (float) (ySelected + block.getBlockBoundsMinY()) / m,
             (float) (zSelected + block.getBlockBoundsMinZ()) / m,
             (float) (xSelected + block.getBlockBoundsMaxX()) / m,
             (float) (ySelected + block.getBlockBoundsMaxY()) / m,
             (float) (zSelected + block.getBlockBoundsMaxZ()) / m);
       }
     }
   }
 }
  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);
    }
  }
Example #16
0
  private void renderPipeItem(
      RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); // don't break other mods' guis when holding a pipe
    // force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);

    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;

    Block block = FakeBlock.INSTANCE;
    IIcon icon = PipeIconProvider.TYPE.PipeStainedOverlay.getIcon();

    if (item.getItemDamage() >= 1) {
      GL11.glPushMatrix();

      int c = ColorUtils.getRGBColor(item.getItemDamage() - 1);
      GL11.glColor3ub((byte) (c >> 16), (byte) ((c >> 8) & 0xFF), (byte) (c & 0xFF));
      block.setBlockBounds(
          CoreConstants.PIPE_MIN_POS + zFightOffset,
          0.0F + zFightOffset,
          CoreConstants.PIPE_MIN_POS + zFightOffset,
          CoreConstants.PIPE_MAX_POS - zFightOffset,
          1.0F - zFightOffset,
          CoreConstants.PIPE_MAX_POS - zFightOffset);
      block.setBlockBoundsForItemRender();
      render.setRenderBoundsFromBlock(block);

      GL11.glTranslatef(translateX, translateY, translateZ);
      RenderUtils.drawBlockItem(render, tessellator, block, icon);
      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
      GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
      GL11.glPopMatrix();
    }

    block = BuildCraftTransport.genericPipeBlock;
    icon = item.getItem().getIconFromDamage(0);

    if (icon == null) {
      icon =
          ((TextureMap)
                  Minecraft.getMinecraft()
                      .getTextureManager()
                      .getTexture(TextureMap.locationBlocksTexture))
              .getAtlasSprite("missingno");
    }

    block.setBlockBounds(
        CoreConstants.PIPE_MIN_POS,
        0.0F,
        CoreConstants.PIPE_MIN_POS,
        CoreConstants.PIPE_MAX_POS,
        1.0F,
        CoreConstants.PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);

    GL11.glTranslatef(translateX, translateY, translateZ);
    RenderUtils.drawBlockItem(render, tessellator, block, icon);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib(); // nicely leave the rendering how it was
  }
  @Override
  public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
    GL11.glPushMatrix();
    try {

      if (metadata == BlockMetalDecoration.META_fence) {
        GL11.glTranslatef(-.5f, -.5f, -.5f);
        renderer.setRenderBounds(0, 0, .375, .25, 1, .625);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
        renderer.setRenderBounds(.75, 0, .375, 1, 1, .625);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
        renderer.setRenderBounds(-.125, .8125, .4375, 1.125, .9375, .5625);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
        renderer.setRenderBounds(-.125, .3125, .4375, 1.125, .4375, .5625);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
        GL11.glTranslatef(.5f, .5f, .5f);
      } else if (metadata == BlockMetalDecoration.META_scaffolding) {
        block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        renderer.setRenderBoundsFromBlock(block);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
      } else if (metadata == BlockMetalDecoration.META_lantern) {
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityLantern());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDecoration.META_structuralArm) {
        Tessellator tes = ClientUtils.tes();
        IIcon iSide = block.getIcon(2, 3);
        IIcon iTop = block.getIcon(0, 3);

        GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

        tes.startDrawing(6);
        tes.setNormal(0.0F, -1.0F, 0.0F);
        renderer.renderFaceYNeg(block, 0, 0, 0, iTop);
        tes.draw();

        tes.startDrawing(6);
        tes.setNormal(0.0F, 1.0F, 0.0F);
        tes.setBrightness(0xff);
        tes.addVertexWithUV(1, 1, 1, iTop.getMaxU(), iTop.getMaxV());
        tes.addVertexWithUV(1, 1, 0, iTop.getMaxU(), iTop.getMinV());
        tes.addVertexWithUV(0, 0, 0, iTop.getMinU(), iTop.getMinV());
        tes.addVertexWithUV(0, 0, 1, iTop.getMinU(), iTop.getMaxV());
        tes.draw();

        tes.startDrawing(6);
        tes.setNormal(0.0F, 0.0F, -1.0F);
        tes.addVertexWithUV(0, 0, 0, iSide.getMinU(), iSide.getInterpolatedV(0 * 16));
        tes.addVertexWithUV(1, 1, 0, iSide.getMaxU(), iSide.getInterpolatedV(1 * 16));
        tes.addVertexWithUV(1, 0, 0, iSide.getMaxU(), iSide.getMinV());
        tes.addVertexWithUV(0, 0, 0, iSide.getMinU(), iSide.getMinV());
        tes.draw();

        tes.startDrawing(6);
        tes.setNormal(0.0F, 0.0F, 1.0F);
        tes.addVertexWithUV(1, 1, 1, iSide.getMaxU(), iSide.getInterpolatedV(1 * 16));
        tes.addVertexWithUV(0, 0, 1, iSide.getMinU(), iSide.getInterpolatedV(0 * 16));
        tes.addVertexWithUV(0, 0, 1, iSide.getMinU(), iSide.getMinV());
        tes.addVertexWithUV(1, 0, 1, iSide.getMaxU(), iSide.getMinV());
        tes.draw();

        tes.startDrawing(6);
        tes.setNormal(-1.0F, 0.0F, 0.0F);
        tes.addVertexWithUV(0, 0, 1, iSide.getMaxU(), iSide.getInterpolatedV(0 * 16));
        tes.addVertexWithUV(0, 0, 0, iSide.getMinU(), iSide.getInterpolatedV(0 * 16));
        tes.addVertexWithUV(0, 0, 0, iSide.getMinU(), iSide.getMinV());
        tes.addVertexWithUV(0, 0, 1, iSide.getMaxU(), iSide.getMinV());
        tes.draw();

        tes.startDrawing(6);
        tes.setNormal(1.0F, 0.0F, 0.0F);
        tes.addVertexWithUV(1, 1, 0, iSide.getMinU(), iSide.getInterpolatedV(1 * 16));
        tes.addVertexWithUV(1, 1, 1, iSide.getMaxU(), iSide.getInterpolatedV(1 * 16));
        tes.addVertexWithUV(1, 0, 1, iSide.getMaxU(), iSide.getMinV());
        tes.addVertexWithUV(1, 0, 0, iSide.getMinU(), iSide.getMinV());
        tes.draw();
      } else if (metadata == BlockMetalDecoration.META_connectorStructural) {
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityConnectorStructural());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDecoration.META_wallMount) {
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityWallmountMetal());
        Tessellator.instance.draw();
      } else {
        block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        renderer.setRenderBoundsFromBlock(block);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    GL11.glPopMatrix();
  }
  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);
  }
  @Override
  public boolean renderWorldBlock(
      IBlockAccess iblockaccess,
      int x,
      int y,
      int z,
      Block block,
      int l,
      RenderBlocks renderblocks) {

    int meta = iblockaccess.getBlockMetadata(x, y, z);

    if (meta == ForgeDirection.EAST.ordinal()) {
      renderblocks.uvRotateEast = 2;
      renderblocks.uvRotateWest = 1;
      renderblocks.uvRotateTop = 1;
      renderblocks.uvRotateBottom = 2;

      block.setBlockBounds(0.0F, 0.0F, 0.0F, 4F / 16F, 1, 1);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(4F / 16F, 5F / 16F, 5F / 16F, 13F / 16F, 11F / 16F, 11F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    } else if (meta == ForgeDirection.WEST.ordinal()) {
      renderblocks.uvRotateEast = 1;
      renderblocks.uvRotateWest = 2;
      renderblocks.uvRotateTop = 2;
      renderblocks.uvRotateBottom = 1;

      block.setBlockBounds(1F - 4F / 16F, 0.0F, 0.0F, 1, 1, 1);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(1F - 13F / 16F, 5F / 16F, 5F / 16F, 1F - 4F / 16F, 11F / 16F, 11F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    } else if (meta == ForgeDirection.NORTH.ordinal()) {
      renderblocks.uvRotateSouth = 1;
      renderblocks.uvRotateNorth = 2;

      block.setBlockBounds(0.0F, 0.0F, 1F - 4F / 16F, 1, 1, 1);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(5F / 16F, 5F / 16F, 1F - 13F / 16F, 11F / 16F, 11F / 16F, 1F - 4F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    } else if (meta == ForgeDirection.SOUTH.ordinal()) {
      renderblocks.uvRotateSouth = 2;
      renderblocks.uvRotateNorth = 1;
      renderblocks.uvRotateTop = 3;
      renderblocks.uvRotateBottom = 3;

      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 1, 4F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(5F / 16F, 5F / 16F, 4F / 16F, 11F / 16F, 11F / 16F, 13F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    } else if (meta == ForgeDirection.DOWN.ordinal()) {
      renderblocks.uvRotateEast = 3;
      renderblocks.uvRotateWest = 3;
      renderblocks.uvRotateSouth = 3;
      renderblocks.uvRotateNorth = 3;

      block.setBlockBounds(0.0F, 1.0F - 4F / 16F, 0.0F, 1.0F, 1.0F, 1.0F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(5F / 16F, 1F - 13F / 16F, 5F / 16F, 11F / 16F, 1F - 4F / 16F, 11F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    } else if (meta == ForgeDirection.UP.ordinal()) {
      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 4F / 16F, 1);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);

      block.setBlockBounds(5F / 16F, 4F / 16F, 5F / 16F, 11F / 16F, 13F / 16F, 11F / 16F);
      renderblocks.setRenderBoundsFromBlock(block);
      renderblocks.renderStandardBlock(block, x, y, z);
    }

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1, 1, 1);
    renderblocks.uvRotateEast = 0;
    renderblocks.uvRotateWest = 0;
    renderblocks.uvRotateSouth = 0;
    renderblocks.uvRotateNorth = 0;
    renderblocks.uvRotateTop = 0;
    renderblocks.uvRotateBottom = 0;

    return true;
  }
  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);
      }
    }
  }
  @Override
  public boolean renderWorldBlock(
      IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {

    int ID = block.blockID;
    int meta = world.getBlockMetadata(x, y, z);
    if (meta > 8) meta = 8;
    this.boxIcon = Block.planks.getIcon(0, 0);
    this.contentsIcon = DCsAppleMilk.bowlBlock.getIcon(0, meta);

    if (modelId == this.getRenderId()) {
      // box
      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          6.0F / 16.0F, 0.0F / 16.0F, 6.0F / 16.0F, 10.0F / 16.0F, 1.0F / 16.0F, 10.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);

      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          4.0F / 16.0F, 1.0F / 16.0F, 4.0F / 16.0F, 12.0F / 16.0F, 2.0F / 16.0F, 12.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);

      // contents
      if (meta == 0 || meta == 4) {
        renderer.setOverrideBlockTexture(this.contentsIcon);
        block.setBlockBounds(
            4.0F / 16.0F, 2.0F / 16.0F, 4.0F / 16.0F, 12.0F / 16.0F, 7.0F / 16.0F, 12.0F / 16.0F);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);

        renderer.setOverrideBlockTexture(this.contentsIcon);
        block.setBlockBounds(
            5.0F / 16.0F, 7.0F / 16.0F, 5.0F / 16.0F, 11.0F / 16.0F, 8.0F / 16.0F, 11.0F / 16.0F);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);
      } else if (meta < 8) {
        renderer.setOverrideBlockTexture(this.contentsIcon);
        block.setBlockBounds(
            4.0F / 16.0F, 2.0F / 16.0F, 4.0F / 16.0F, 12.0F / 16.0F, 4.0F / 16.0F, 12.0F / 16.0F);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);
      }

      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          3.0F / 16.0F, 2.0F / 16.0F, 3.0F / 16.0F, 13.0F / 16.0F, 5.0F / 16.0F, 4.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);
      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          3.0F / 16.0F, 2.0F / 16.0F, 12.0F / 16.0F, 13.0F / 16.0F, 5.0F / 16.0F, 13.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);
      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          3.0F / 16.0F, 2.0F / 16.0F, 4.0F / 16.0F, 4.0F / 16.0F, 5.0F / 16.0F, 12.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);
      renderer.setOverrideBlockTexture(this.boxIcon);
      block.setBlockBounds(
          12.0F / 16.0F, 2.0F / 16.0F, 4.0F / 16.0F, 13.0F / 16.0F, 5.0F / 16.0F, 12.0F / 16.0F);
      renderer.setRenderBoundsFromBlock(block);
      renderer.renderStandardBlock(block, x, y, z);

      renderer.clearOverrideBlockTexture();
      block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
      renderer.setRenderBoundsFromBlock(block);
      return true;
    }
    return false;
  }
  private void pipeWireRender(
      RenderBlocks renderblocks,
      Block block,
      PipeRenderState state,
      float cx,
      float cy,
      float cz,
      IPipe.WireColor color,
      int x,
      int y,
      int z) {

    float minX = Utils.pipeMinPos;
    float minY = Utils.pipeMinPos;
    float minZ = Utils.pipeMinPos;

    float maxX = Utils.pipeMaxPos;
    float maxY = Utils.pipeMaxPos;
    float maxZ = Utils.pipeMaxPos;

    boolean foundX = false, foundY = false, foundZ = false;

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
      minX = 0;
      foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
      maxX = 1;
      foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
      minY = 0;
      foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
      maxY = 1;
      foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
      minZ = 0;
      foundZ = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
      maxZ = 1;
      foundZ = true;
    }

    boolean center = false;

    if (minX == 0 && maxX != 1 && (foundY || foundZ))
      if (cx == Utils.pipeMinPos) {
        maxX = Utils.pipeMinPos;
      } else {
        center = true;
      }

    if (minX != 0 && maxX == 1 && (foundY || foundZ))
      if (cx == Utils.pipeMaxPos) {
        minX = Utils.pipeMaxPos;
      } else {
        center = true;
      }

    if (minY == 0 && maxY != 1 && (foundX || foundZ))
      if (cy == Utils.pipeMinPos) {
        maxY = Utils.pipeMinPos;
      } else {
        center = true;
      }

    if (minY != 0 && maxY == 1 && (foundX || foundZ))
      if (cy == Utils.pipeMaxPos) {
        minY = Utils.pipeMaxPos;
      } else {
        center = true;
      }

    if (minZ == 0 && maxZ != 1 && (foundX || foundY))
      if (cz == Utils.pipeMinPos) {
        maxZ = Utils.pipeMinPos;
      } else {
        center = true;
      }

    if (minZ != 0 && maxZ == 1 && (foundX || foundY))
      if (cz == Utils.pipeMaxPos) {
        minZ = Utils.pipeMaxPos;
      } else {
        center = true;
      }

    boolean found = foundX || foundY || foundZ;

    // 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 : 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 : 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 : 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,
          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);
    }
  }
  @Override
  public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
    GL11.glPushMatrix();
    try {
      if (metadata == BlockMetalDevices2.META_breakerSwitch) {
        GL11.glTranslatef(-1f, -.75f, .25f);
        GL11.glScalef(1.25f, 1.25f, 1.25f);
        GL11.glRotatef(-90, 1, 0, 0);
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityBreakerSwitch());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_energyMeter) {
        GL11.glScalef(.75f, .75f, .75f);
        GL11.glTranslatef(0, .625f, 0);
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityEnergyMeter());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_electricLantern) {
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityElectricLantern());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_floodlight) {
        Tessellator.instance.startDrawingQuads();
        TileEntityFloodlight tile = new TileEntityFloodlight();
        TileEntitySpecialRenderer tesr =
            TileEntityRendererDispatcher.instance.getSpecialRenderer(tile);
        if (tesr instanceof TileRenderFloodlight)
          ((TileRenderFloodlight) tesr)
              .model.render(
                  tile,
                  Tessellator.instance,
                  new Matrix4().translate(0, .125, 0),
                  new Matrix4().rotate(Math.PI, 0, 1, 0),
                  0,
                  false);
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_fluidPipe) {
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityFluidPipe());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_fluidPump) {
        GL11.glPushMatrix();
        GL11.glScalef(0.65f, 0.65f, 0.65f);
        GL11.glTranslatef(0, -0.5f, 0);
        IEContent.blockMetalDevice2.setBlockBounds(0, 0, 0, 1, 1, 1);
        renderer.setRenderBoundsFromBlock(IEContent.blockMetalDevice2);
        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F);
        renderer.renderFaceXPos(
            IEContent.blockMetalDevice2,
            0,
            0,
            0,
            IEContent.blockMetalDevice2.getIcon(0, BlockMetalDevices2.META_fluidPump));
        Tessellator.instance.draw();

        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F);
        renderer.renderFaceXNeg(
            IEContent.blockMetalDevice2,
            0,
            0,
            0,
            IEContent.blockMetalDevice2.getIcon(2, BlockMetalDevices2.META_fluidPump));
        Tessellator.instance.draw();

        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F);
        renderer.renderFaceZPos(
            IEContent.blockMetalDevice2,
            0,
            0,
            0,
            IEContent.blockMetalDevice2.getIcon(1, BlockMetalDevices2.META_fluidPump));
        Tessellator.instance.draw();

        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F);
        renderer.renderFaceZNeg(
            IEContent.blockMetalDevice2,
            0,
            0,
            0,
            IEContent.blockMetalDevice2.getIcon(0, BlockMetalDevices2.META_fluidPump));
        Tessellator.instance.draw();

        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.setNormal(0.0F, -1.0f, 0.0F);
        renderer.renderFaceYNeg(
            IEContent.blockMetalDevice2,
            0,
            0,
            0,
            IEContent.blockMetalDevice2.getIcon(3, BlockMetalDevices2.META_fluidPump));
        Tessellator.instance.draw();

        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityFluidPump());
        Tessellator.instance.draw();
        GL11.glPopMatrix();
      } else if (metadata == BlockMetalDevices2.META_barrel) {
        renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
      } else if (metadata == BlockMetalDevices2.META_capacitorCreative) {
        block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
        renderer.setRenderBoundsFromBlock(block);
        ClientUtils.drawInventoryBlock(block, metadata, renderer);
      } else if (metadata == BlockMetalDevices2.META_redstoneBreaker) {
        GL11.glTranslatef(-.5f, -.5f, -.5f);
        Tessellator.instance.startDrawingQuads();
        ClientUtils.handleStaticTileRenderer(new TileEntityRedstoneBreaker());
        Tessellator.instance.draw();
      } else if (metadata == BlockMetalDevices2.META_chargingStation) {
        Tessellator.instance.startDrawingQuads();
        TileEntityChargingStation tile = new TileEntityChargingStation();
        GL11.glRotatef(-180, 0, 1, 0);
        GL11.glTranslatef(-.5f, -.5f, -.5f);
        renderPass = 0;
        ClientUtils.handleStaticTileRenderer(tile);
        renderPass = 1;
        ClientUtils.handleStaticTileRenderer(tile);
        Tessellator.instance.draw();
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    GL11.glPopMatrix();
  }