public void drawFluidTank(IFluidTank tank, int x, int y) {
   FluidStack fluid = tank.getFluid();
   TextureManager manager = Minecraft.getMinecraft().renderEngine;
   if (fluid != null) {
     manager.bindTexture(manager.getResourceLocation(0));
     float amount = fluid.amount;
     float capacity = tank.getCapacity();
     float scale = amount / capacity;
     int fluidTankHeight = 60;
     int fluidAmount = (int) (scale * fluidTankHeight);
     drawFluid(
         x, y + fluidTankHeight - fluidAmount, fluid.getFluid().getIcon(fluid), 16, fluidAmount);
     manager.bindTexture(PymParticleProducerGuiTextures);
     drawTexturedModalRect(x - 1, y - 1, 238, 0, 18, 62);
   }
 }
  public static void drawLiquidBar(
      int x, int y, int width, int height, int fluidID, int percentage) {
    Fluid fluid = FluidRegistry.getFluid(fluidID);
    if (fluid == null) return;

    Icon icon = fluid.getIcon();

    if (icon == null) return;

    // Bind SpriteNumber=0,texture "/terrain.png"
    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(0));

    double u = icon.getInterpolatedU(3.0D);
    double u2 = icon.getInterpolatedU(13.0D);
    double v = icon.getInterpolatedV(1.0D);
    double v2 = icon.getInterpolatedV(15.0D);

    int z = height * percentage / 100;

    GL11.glEnable(3553);
    GL11.glColor4d(1.0D, 1.0D, 1.0D, 1.0D);

    GL11.glBegin(7);
    GL11.glTexCoord2d(u, v);
    GL11.glVertex2i(x, y + height - z);

    GL11.glTexCoord2d(u, v2);
    GL11.glVertex2i(x, y + height);

    GL11.glTexCoord2d(u2, v2);
    GL11.glVertex2i(x + width, y + height);

    GL11.glTexCoord2d(u2, v);
    GL11.glVertex2i(x + width, y + height - z);
    GL11.glEnd();
  }
Exemple #3
0
 public static void bindIconSheet(TextureManager manager, int type) {
   final ResourceLocation resourceLocation = manager.getResourceLocation(type);
   manager.bindTexture(resourceLocation);
 }
  public static void renderItem(EntityLivingBase entity, ItemStack itemStack, int renderPass) {
    TextureManager texturemanager = FMLClientHandler.instance().getClient().getTextureManager();
    Item item = itemStack.getItem();
    Block block = Block.getBlockFromItem(item);

    GL11.glPushMatrix();
    if (itemStack.getItemSpriteNumber() == 0
        && item instanceof ItemBlock
        && RenderBlocks.renderItemIn3d(block.getRenderType())) {
      texturemanager.bindTexture(texturemanager.getResourceLocation(0));

      if (itemStack != null && block != null && block.getRenderBlockPass() != 0) {
        GL11.glDepthMask(false);
        RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F);
        GL11.glDepthMask(true);
      } else {
        RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F);
      }
    } else {
      IIcon iicon = entity.getItemIcon(itemStack, renderPass);
      if (iicon == null) {
        GL11.glPopMatrix();
        return;
      }

      texturemanager.bindTexture(
          texturemanager.getResourceLocation(itemStack.getItemSpriteNumber()));
      TextureUtil.func_152777_a(false, false, 1.0F);
      Tessellator tessellator = Tessellator.instance;
      float minU = iicon.getMinU();
      float maxU = iicon.getMaxU();
      float minV = iicon.getMinV();
      float maxV = iicon.getMaxV();
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glTranslatef(0.0F, -0.3F, 0.0F);
      GL11.glScalef(1.5F, 1.5F, 1.5F);
      GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
      GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
      ItemRenderer.renderItemIn2D(
          tessellator,
          maxU,
          minV,
          minU,
          maxV,
          iicon.getIconWidth(),
          iicon.getIconHeight(),
          0.0625F);

      if (itemStack.hasEffect(renderPass)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RenderHelper.RES_ITEM_GLINT);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(768, 1, 1, 0);
        GL11.glColor4f(0.38F, 0.19F, 0.608F, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);

        GL11.glPushMatrix();
        GL11.glScalef(0.125F, 0.125F, 0.125F);
        float animOffset = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(animOffset, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScalef(0.125F, 0.125F, 0.125F);
        animOffset = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-animOffset, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }

      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      texturemanager.bindTexture(
          texturemanager.getResourceLocation(itemStack.getItemSpriteNumber()));
      TextureUtil.func_147945_b();
    }
    if (itemStack != null && block != null && block.getRenderBlockPass() != 0) {
      GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glPopMatrix();
  }