Exemplo n.º 1
0
  protected void doRenderItem(
      ItemRenderType type, ItemStack item, Item iconItem, FluidStack fluid) {

    IIcon icon = iconItem.getIcon(item, 0);
    IIcon mask = iconItem.getIcon(item, 1);
    boolean hasFluid = fluid != null;

    IIcon fluidIcon = hasFluid ? fluid.getFluid().getIcon(fluid) : mask;
    int fluidSheet = hasFluid ? fluid.getFluid().getSpriteNumber() : 0;
    int colorMult = hasFluid ? fluid.getFluid().getColor(fluid) : 0xFFFFFF;
    boolean isFloaty = hasFluid ? fluid.getFluid().getDensity(fluid) < 0 : false;

    if (fluid == null) {
      fluidIcon = Blocks.flowing_lava.getIcon(2, 0);
      fluidSheet = 0;
      colorMult = 0x3F3F3F;
    }
    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;

    float iconMinX = icon.getMinU();
    float iconMaxX = icon.getMaxU();
    float iconMinY = icon.getMinV();
    float iconMaxY = icon.getMaxV();

    float maskMinX = mask.getMinU();
    float maskMaxX = mask.getMaxU();
    float maskMinY = mask.getMinV();
    float maskMaxY = mask.getMaxV();

    float fluidMinX = fluidIcon.getMinU();
    float fluidMaxX = fluidIcon.getMaxU();
    float fluidMinY = fluidIcon.getMinV();
    float fluidMaxY = fluidIcon.getMaxV();

    if (isFloaty && canFlip) {
      iconMaxY = icon.getMinV();
      iconMinY = icon.getMaxV();

      maskMaxY = mask.getMinV();
      maskMinY = mask.getMaxV();

      fluidMaxY = fluidIcon.getMinV();
      fluidMinY = fluidIcon.getMaxV();
    }
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    int texture = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

    if (type == ItemRenderType.INVENTORY) {
      GL11.glDisable(GL11.GL_LIGHTING);

      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV(0, 16, 0, iconMinX, iconMaxY);
      tessellator.addVertexWithUV(16, 16, 0, iconMaxX, iconMaxY);
      tessellator.addVertexWithUV(16, 0, 0, iconMaxX, iconMinY);
      tessellator.addVertexWithUV(0, 0, 0, iconMinX, iconMinY);
      tessellator.draw();

      if (hasFluid) {
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0, 16, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMinX, maskMinY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        bindTexture(RenderHelper.engine(), fluidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 16, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMinX, fluidMinY);
        tessellator.draw();

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }

      GL11.glEnable(GL11.GL_LIGHTING);
    } else {
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);

      if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0.5f, 4 / -16f, 0);
        GL11.glRotatef(180, 0, 1, 0);
      }
      ItemRenderer.renderItemIn2D(
          tessellator,
          iconMaxX,
          iconMinY,
          iconMinX,
          iconMaxY,
          icon.getIconWidth(),
          icon.getIconHeight(),
          0.0625F);

      if (hasFluid) {
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, maskMinX, maskMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, maskMaxX, maskMinY);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.addVertexWithUV(0, 1, -0.0635, maskMinX, maskMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, maskMinX, maskMaxY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        bindTexture(RenderHelper.engine(), fluidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, fluidMaxX, fluidMinY);
        tessellator.draw();

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 1, -0.0635, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, fluidMinX, fluidMaxY);
        tessellator.draw();

        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    }

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glPopMatrix();
  }
  public void renderItem(IItemRenderer.ItemRenderType aType, ItemStack aStack, Object... data) {
    if (GT_Utility.isStackInvalid(aStack)) {
      return;
    }
    GT_MetaGenerated_Tool aItem = (GT_MetaGenerated_Tool) aStack.getItem();
    GL11.glEnable(3042);
    if (aType == IItemRenderer.ItemRenderType.ENTITY) {
      if (RenderItem.renderInFrame) {
        GL11.glScalef(0.85F, 0.85F, 0.85F);
        GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-0.5D, -0.42D, 0.0D);
      } else {
        GL11.glTranslated(-0.5D, -0.42D, 0.0D);
      }
    }
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    IToolStats tToolStats = aItem.getToolStats(aStack);
    if (tToolStats != null) {
      IIconContainer aIcon = tToolStats.getIcon(false, aStack);
      if (aIcon != null) {
        IIcon tIcon = aIcon.getIcon();
        IIcon tOverlay = aIcon.getOverlayIcon();
        if (tIcon != null) {
          Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
          GL11.glBlendFunc(770, 771);
          short[] tModulation = tToolStats.getRGBa(false, aStack);
          GL11.glColor3f(tModulation[0] / 255.0F, tModulation[1] / 255.0F, tModulation[2] / 255.0F);
          if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
            GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
          } else {
            ItemRenderer.renderItemIn2D(
                Tessellator.instance,
                tIcon.getMaxU(),
                tIcon.getMinV(),
                tIcon.getMinU(),
                tIcon.getMaxV(),
                tIcon.getIconWidth(),
                tIcon.getIconHeight(),
                0.0625F);
          }
          GL11.glColor3f(1.0F, 1.0F, 1.0F);
        }
        if (tOverlay != null) {
          Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
          GL11.glBlendFunc(770, 771);
          if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
            GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
          } else {
            ItemRenderer.renderItemIn2D(
                Tessellator.instance,
                tOverlay.getMaxU(),
                tOverlay.getMinV(),
                tOverlay.getMinU(),
                tOverlay.getMaxV(),
                tOverlay.getIconWidth(),
                tOverlay.getIconHeight(),
                0.0625F);
          }
        }
      }
      aIcon = tToolStats.getIcon(true, aStack);
      if (aIcon != null) {
        IIcon tIcon = aIcon.getIcon();
        IIcon tOverlay = aIcon.getOverlayIcon();
        if (tIcon != null) {
          Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
          GL11.glBlendFunc(770, 771);
          short[] tModulation = tToolStats.getRGBa(true, aStack);
          GL11.glColor3f(tModulation[0] / 255.0F, tModulation[1] / 255.0F, tModulation[2] / 255.0F);
          if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
            GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
          } else {
            ItemRenderer.renderItemIn2D(
                Tessellator.instance,
                tIcon.getMaxU(),
                tIcon.getMinV(),
                tIcon.getMinU(),
                tIcon.getMaxV(),
                tIcon.getIconWidth(),
                tIcon.getIconHeight(),
                0.0625F);
          }
          GL11.glColor3f(1.0F, 1.0F, 1.0F);
        }
        if (tOverlay != null) {
          Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
          GL11.glBlendFunc(770, 771);
          if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
            GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
          } else {
            ItemRenderer.renderItemIn2D(
                Tessellator.instance,
                tOverlay.getMaxU(),
                tOverlay.getMinV(),
                tOverlay.getMinU(),
                tOverlay.getMaxV(),
                tOverlay.getIconWidth(),
                tOverlay.getIconHeight(),
                0.0625F);
          }
        }
      }
      if ((aType == IItemRenderer.ItemRenderType.INVENTORY)
          && (GT_MetaGenerated_Tool.getPrimaryMaterial(aStack) != Materials._NULL)) {
        long tDamage = GT_MetaGenerated_Tool.getToolDamage(aStack);
        long tMaxDamage = GT_MetaGenerated_Tool.getToolMaxDamage(aStack);
        if (tDamage <= 0L) {
          aIcon = gregtech.api.enums.Textures.ItemIcons.DURABILITY_BAR[8];
        } else if (tDamage >= tMaxDamage) {
          aIcon = gregtech.api.enums.Textures.ItemIcons.DURABILITY_BAR[0];
        } else {
          aIcon =
              gregtech.api.enums.Textures.ItemIcons.DURABILITY_BAR[
                  ((int)
                      java.lang.Math.max(
                          0L, java.lang.Math.min(7L, (tMaxDamage - tDamage) * 8L / tMaxDamage)))];
        }
        if (aIcon != null) {
          IIcon tIcon = aIcon.getIcon();
          IIcon tOverlay = aIcon.getOverlayIcon();
          if (tIcon != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
            GL11.glBlendFunc(770, 771);
            if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
              GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
            } else {
              ItemRenderer.renderItemIn2D(
                  Tessellator.instance,
                  tIcon.getMaxU(),
                  tIcon.getMinV(),
                  tIcon.getMinU(),
                  tIcon.getMaxV(),
                  tIcon.getIconWidth(),
                  tIcon.getIconHeight(),
                  0.0625F);
            }
          }
          if (tOverlay != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
            GL11.glBlendFunc(770, 771);
            if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
              GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
            } else {
              ItemRenderer.renderItemIn2D(
                  Tessellator.instance,
                  tOverlay.getMaxU(),
                  tOverlay.getMinV(),
                  tOverlay.getMinU(),
                  tOverlay.getMaxV(),
                  tOverlay.getIconWidth(),
                  tOverlay.getIconHeight(),
                  0.0625F);
            }
          }
        }
        Long[] tStats = aItem.getElectricStats(aStack);
        if ((tStats != null) && (tStats[3].longValue() < 0L)) {
          long tCharge = aItem.getRealCharge(aStack);
          if (tCharge <= 0L) {
            aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[0];
          } else if (tCharge >= tStats[0].longValue()) {
            aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[8];
          } else {
            aIcon =
                gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[
                    (7
                        - (int)
                            java.lang.Math.max(
                                0L,
                                java.lang.Math.min(
                                    6L,
                                    (tStats[0].longValue() - tCharge)
                                        * 7L
                                        / tStats[0].longValue())))];
          }
        } else {
          aIcon = null;
        }
        if (aIcon != null) {
          IIcon tIcon = aIcon.getIcon();
          IIcon tOverlay = aIcon.getOverlayIcon();
          if (tIcon != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
            GL11.glBlendFunc(770, 771);
            if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
              GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
            } else {
              ItemRenderer.renderItemIn2D(
                  Tessellator.instance,
                  tIcon.getMaxU(),
                  tIcon.getMinV(),
                  tIcon.getMinU(),
                  tIcon.getMaxV(),
                  tIcon.getIconWidth(),
                  tIcon.getIconHeight(),
                  0.0625F);
            }
          }
          if (tOverlay != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(aIcon.getTextureFile());
            GL11.glBlendFunc(770, 771);
            if (aType.equals(IItemRenderer.ItemRenderType.INVENTORY)) {
              GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F);
            } else {
              ItemRenderer.renderItemIn2D(
                  Tessellator.instance,
                  tOverlay.getMaxU(),
                  tOverlay.getMinV(),
                  tOverlay.getMinU(),
                  tOverlay.getMaxV(),
                  tOverlay.getIconWidth(),
                  tOverlay.getIconHeight(),
                  0.0625F);
            }
          }
        }
      }
    }
    GL11.glDisable(3042);
  }
Exemplo n.º 3
0
  public void renderItemStack(ItemStack stack) {
    if (stack != null) {
      Minecraft mc = Minecraft.getMinecraft();
      mc.renderEngine.bindTexture(
          stack.getItem() instanceof ItemBlock
              ? TextureMap.locationBlocksTexture
              : TextureMap.locationItemsTexture);

      float s = 0.25F;
      GL11.glScalef(s, s, s);
      GL11.glScalef(2F, 2F, 2F);
      if (!ForgeHooksClient.renderEntityItem(
          new EntityItem(
              brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack),
          stack,
          0F,
          0F,
          brewery.getWorldObj().rand,
          mc.renderEngine,
          RenderBlocks.getInstance(),
          1)) {
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        if (stack.getItem() instanceof ItemBlock
            && RenderBlocks.renderItemIn3d(
                Block.getBlockFromItem(stack.getItem()).getRenderType())) {
          GL11.glScalef(0.5F, 0.5F, 0.5F);
          GL11.glTranslatef(1F, 1.1F, 0F);
          GL11.glPushMatrix();
          RenderBlocks.getInstance()
              .renderBlockAsItem(
                  Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 1F);
          GL11.glPopMatrix();
          GL11.glTranslatef(-1F, -1.1F, 0F);
          GL11.glScalef(2F, 2F, 2F);
        } else {
          int renderPass = 0;
          do {
            IIcon icon = stack.getItem().getIcon(stack, renderPass);
            if (icon != null) {
              Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
              GL11.glColor3ub(
                  (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
              float f = icon.getMinU();
              float f1 = icon.getMaxU();
              float f2 = icon.getMinV();
              float f3 = icon.getMaxV();

              ItemRenderer.renderItemIn2D(
                  Tessellator.instance,
                  f1,
                  f2,
                  f,
                  f3,
                  icon.getIconWidth(),
                  icon.getIconHeight(),
                  1F / 16F);
              GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
          } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
        }
      }
      GL11.glScalef(1F / s, 1F / s, 1F / s);

      Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    }
  }
  @Override
  public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float t) {
    int meta = tileentity.getWorldObj() == null ? 3 : tileentity.getBlockMetadata();
    int rotation = meta == 2 ? 0 : meta == 3 ? 180 : meta == 4 ? 270 : 90;

    TileRepairer repairer = (TileRepairer) tileentity;

    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    bindTexture(modelTex);
    GL11.glTranslatef(0F, 2F, 1F);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    model.render();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glScalef(1F, -1F, -1F);

    ItemStack item = ((TileRepairer) tileentity).getStackInSlot(0);
    if (item != null) {
      GL11.glPushMatrix();
      final float scale = 0.5F;
      GL11.glScalef(scale, scale, scale);
      GL11.glTranslatef(-0.5F, (float) (-2.5F + Math.sin(repairer.ticksExisted / 10F) * 0.1F), 0F);

      float deg = repairer.ticksExisted * 0.75F % 360F;
      GL11.glTranslatef(1F / 2F, 1F / 2F, 1F / 32F);
      GL11.glRotatef(deg, 0F, 1F, 0F);
      GL11.glTranslatef(-1F / 2F, -1F / 2F, -1F / 32F);

      bindTexture(TextureMap.locationItemsTexture);

      int renderPass = 0;
      do {
        IIcon icon = item.getItem().getIcon(item, renderPass);
        if (icon != null) {
          Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
          GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
          float f = icon.getMinU();
          float f1 = icon.getMaxU();
          float f2 = icon.getMinV();
          float f3 = icon.getMaxV();
          ItemRenderer.renderItemIn2D(
              Tessellator.instance,
              f1,
              f2,
              f,
              f3,
              icon.getIconWidth(),
              icon.getIconHeight(),
              1F / 16F);
          GL11.glColor3f(1F, 1F, 1F);
        }
        renderPass++;
      } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
      GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    bindTexture(modelTex);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    model.renderGlass();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glScalef(1F, -1F, -1F);

    renderOverlay(
        (TileRepairer) tileentity,
        ((TileRepairer) tileentity).tookLastTick ? repair : repairOff,
        1.25F);
    GL11.glPopMatrix();
    GL11.glColor4f(1F, 1F, 1F, 1F);
  }
  private void renderHeavyNoseCone(
      ItemRenderType type,
      RenderBlocks render,
      ItemStack item,
      float translateX,
      float translateY,
      float translateZ) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);

    for (int i = 0; i < 2; i++) {
      GL11.glPushMatrix();

      if (i == 1) {
        SpaceRace race =
            SpaceRaceManager.getSpaceRaceFromPlayer(
                FMLClientHandler.instance().getClientPlayerEntity().getGameProfile().getName());
        Vector3 color = null;

        if (race != null) {
          color = race.getTeamColor();
        }

        if (color == null) {
          color = new Vector3(1, 1, 1);
        }

        GL11.glColor4f(color.floatX(), color.floatY(), color.floatZ(), 1.0F);
      }

      IIcon iicon = FMLClientHandler.instance().getClientPlayerEntity().getItemIcon(item, i);

      if (iicon == null) {
        GL11.glPopMatrix();
        return;
      }

      FMLClientHandler.instance()
          .getClient()
          .getTextureManager()
          .bindTexture(
              FMLClientHandler.instance()
                  .getClient()
                  .getTextureManager()
                  .getResourceLocation(item.getItemSpriteNumber()));
      VersionUtil.setMipMap(false, false);
      Tessellator tessellator = Tessellator.instance;
      float f = iicon.getMinU();
      float f1 = iicon.getMaxU();
      float f2 = iicon.getMinV();
      float f3 = iicon.getMaxV();
      float f4 = 0.0F;
      float f5 = 1.0F;
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glScalef(1.0F, -1.0F, 1.0F);
      float f6 = 16.0F;
      GL11.glScalef(f6, f6, f6);
      GL11.glTranslatef(-f4, -f5, 0.0F);
      ItemRenderer.renderItemIn2D(
          tessellator, f1, f2, f, f3, iicon.getIconWidth(), iicon.getIconHeight(), 0.0625F);
      GL11.glPopMatrix();
    }

    GL11.glPopMatrix();
  }
Exemplo n.º 6
0
  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();
  }