private void renderBlock(RenderBlocks renderer, Block content, int color, int x, int y, int z) {
   if (renderer.overrideBlockTexture == null) {
     renderer.setOverrideBlockTexture(Textures.White_BG);
     renderer.renderStandardBlockWithColorMultiplier(
         content,
         x,
         y,
         z,
         (color >> 16 & 255) / 255.0F,
         (color >> 8 & 255) / 255.0F,
         (color & 255) / 255.0F);
     renderer.clearOverrideBlockTexture();
   }
 }
예제 #2
0
  @Override
  public boolean renderWorldBlock(
      IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    TEBarrel te = (TEBarrel) world.getTileEntity(x, y, z);
    Block planksBlock;
    Block lidBlock;
    if (te.barrelType < 16) {
      planksBlock = TFCBlocks.Planks;
      lidBlock = TFCBlocks.WoodSupportH;
    } else {
      planksBlock = TFCBlocks.Planks2;
      lidBlock = TFCBlocks.WoodSupportH2;
    }
    renderer.renderAllFaces = true;

    if ((te.rotation & -128) == 0) {
      if (te.getSealed()) {
        renderer.setRenderBounds(min + 0.05F, min, min + 0.05F, max - 0.05F, 0.95F, max - 0.05F);
        renderer.renderStandardBlock(lidBlock, x, y, z);
      } else {
        renderer.setRenderBounds(
            min + 0.05F, min, min + 0.05F, max - 0.05F, min + 0.05F, max - 0.05F);
        renderer.renderStandardBlock(lidBlock, x, y, z);

        if (te.fluid != null) {
          int color = te.fluid.getFluid().getColor(te.fluid);
          float f = (color >> 16 & 255) / 255.0F;
          float f1 = (color >> 8 & 255) / 255.0F;
          float f2 = (color & 255) / 255.0F;
          float h = 0.75f * (te.fluid.amount / 10000f);
          renderer.setRenderBounds(
              min + 0.05F, min + 0.05, min + 0.05F, max - 0.05F, min + 0.05f + h, max - 0.05F);
          IIcon still = te.fluid.getFluid().getStillIcon();
          renderer.setOverrideBlockTexture(still);
          renderer.renderStandardBlockWithColorMultiplier(lidBlock, x, y, z, f, f1, f2);
          renderer.clearOverrideBlockTexture();
        }
      }
      renderer.setRenderBounds(min, 0F, min + 0.05F, min + 0.05F, 1F, max - 0.05F);
      rotate(renderer, 1);
      renderer.renderStandardBlock(planksBlock, x, y, z);
      rotate(renderer, 0);
      renderer.renderStandardBlock(block, x, y, z);

      renderer.setRenderBounds(max - 0.05F, 0F, min + 0.05F, max, 1F, max - 0.05F);
      rotate(renderer, 1);
      renderer.renderStandardBlock(planksBlock, x, y, z);
      rotate(renderer, 0);
      renderer.renderStandardBlock(block, x, y, z);

      renderer.setRenderBounds(min, 0F, min, max, 1F, min + 0.05F);
      rotate(renderer, 1);
      renderer.renderStandardBlock(planksBlock, x, y, z);
      rotate(renderer, 0);
      renderer.renderStandardBlock(block, x, y, z);

      renderer.setRenderBounds(min, 0F, max - 0.05F, max, 1F, max);
      rotate(renderer, 1);
      renderer.renderStandardBlock(planksBlock, x, y, z);
      rotate(renderer, 0);
      renderer.renderStandardBlock(block, x, y, z);
    } else {
      if ((te.rotation & 3) == 0) {
        renderer.setRenderBounds(min, min, min + 0.05F, 0.95F, min + 0.05F, max - 0.05F);
        renderer.renderStandardBlock(lidBlock, x, y, z);
      }
      if ((te.rotation & 3) == 1) {
        renderer.setRenderBounds(min + 0.05F, min, min, max - 0.05F, min + 0.05F, 0.95F);
        renderer.renderStandardBlock(lidBlock, x, y, z);
      }
    }

    renderer.renderAllFaces = false;

    return true;
  }