コード例 #1
0
  @Override
  public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();

    if (mc == null) {
      mc = FMLClientHandler.instance().getClient();
      itemRenderer = new RenderItem();
    }
    this.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
    Tessellator tessellator = Tessellator.instance;

    if (type == ItemRenderType.EQUIPPED) {

      GL11.glTranslatef(-0.5F, -0.5F, 0);
      GL11.glScalef(2, 2, 1);
      Icon icon = ((ItemSpear) item.getItem()).bigIcon;

      RenderManager.instance.itemRenderer.renderItemIn2D(
          tessellator,
          icon.getMaxU(),
          icon.getMinV(),
          icon.getMinU(),
          icon.getMaxV(),
          icon.getIconWidth(),
          icon.getIconHeight(),
          1F / 16F);

      if (item != null && item.hasEffect(0)) {
        // HeraldryItemRenderer.renderEnchantmentEffects(tessellator);
      }

    } else if (type == ItemRenderType.INVENTORY) {

      GL11.glColor4f(1F, 1F, 1F, 1F);
      // GL11.glRotatef(90, 0, 0, 1);
      itemRenderer.renderIcon(0, 0, item.getIconIndex(), 16, 16);

    } else if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
      Icon icon = item.getIconIndex();

      RenderManager.instance.itemRenderer.renderItemIn2D(
          tessellator,
          icon.getMaxU(),
          icon.getMinV(),
          icon.getMinU(),
          icon.getMaxV(),
          icon.getIconWidth(),
          icon.getIconHeight(),
          1F / 16F);

      if (item != null && item.hasEffect(0)) {
        renderEnchantmentEffects(tessellator);
      }
    }

    GL11.glPopMatrix();
  }
コード例 #2
0
  @Override
  public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    ArrayList upgrades = PolytoolItem.getUpgrades(item);
    int count = 1;
    float red = 0F;
    float green = 0F;
    float blue = 0F;

    for (int i = 0; i < upgrades.size(); i++) {
      for (int j = 0; j < ((PolytoolUpgradeType) upgrades.get(i)).power; j++) {
        count++;
      }
    }
    for (int i = 0; i < upgrades.size(); i++) {
      for (int j = 0; j < ((PolytoolUpgradeType) upgrades.get(i)).power; j++) {
        ElementEnum element = ((PolytoolUpgradeType) upgrades.get(i)).getElement();
        red += (1 / count) * getRed(element);
        green += (1 / count) * getGreen(element);
        blue += (1 / count) * getBlue(element);
      }
    }
    GL11.glColor3f(red, green, blue);

    // Get icon index for the texture
    IIcon icon = item.getIconIndex();
    // Use vanilla code to render the icon in a 16x16 square of inventory slot
    renderItem.renderIcon(0, 0, icon, 16, 16);

    GL11.glPopMatrix();
  }
コード例 #3
0
 public static void renderItemIntoGUI(
     FontRenderer fontRenderer,
     ItemStack itemStack,
     int x,
     int y,
     float opacity,
     float scale,
     int zLevel) {
   IIcon icon = itemStack.getIconIndex();
   GL11.glDisable(GL11.GL_LIGHTING);
   FMLClientHandler.instance()
       .getClient()
       .renderEngine
       .bindTexture(TextureMap.locationItemsTexture);
   int overlayColour = itemStack.getItem().getColorFromItemStack(itemStack, 0);
   float red = (overlayColour >> 16 & 255) / 255.0F;
   float green = (overlayColour >> 8 & 255) / 255.0F;
   float blue = (overlayColour & 255) / 255.0F;
   GL11.glColor4f(red, green, blue, opacity);
   Tessellator tessellator = Tessellator.instance;
   tessellator.startDrawingQuads();
   tessellator.addVertexWithUV(x, y + 16 * scale, zLevel, icon.getMinU(), icon.getMaxV());
   tessellator.addVertexWithUV(
       x + 16 * scale, y + 16 * scale, zLevel, icon.getMaxU(), icon.getMaxV());
   tessellator.addVertexWithUV(x + 16 * scale, y, zLevel, icon.getMaxU(), icon.getMinV());
   tessellator.addVertexWithUV(x, y, zLevel, icon.getMinU(), icon.getMinV());
   tessellator.draw();
   GL11.glEnable(GL11.GL_LIGHTING);
 }
コード例 #4
0
  public static void renderItemIntoGUI(
      FontRenderer fontRenderer,
      RenderEngine renderEngine,
      ItemStack stack,
      int x,
      int y,
      float opacity,
      float scale) {

    int itemID = stack.itemID;
    int meta = stack.getItemDamage();
    int iconIndex = stack.getIconIndex();

    GL11.glDisable(GL11.GL_LIGHTING);

    renderEngine.bindTexture(renderEngine.getTexture(stack.getItem().getTextureFile()));

    int overlayColour = Item.itemsList[itemID].getColorFromItemStack(stack, 0);
    float var17 = (float) (overlayColour >> 16 & 255) / 255.0F;
    float var16 = (float) (overlayColour >> 8 & 255) / 255.0F;
    float var12 = (float) (overlayColour & 255) / 255.0F;

    GL11.glColor4f(var17, var16, var12, opacity);

    drawTexturedQuad(x, y, iconIndex % 16 * 16, iconIndex / 16 * 16, 16, 16, -90, scale);
    GL11.glEnable(GL11.GL_LIGHTING);
  }
コード例 #5
0
 private void drawItemIcon(ItemStack stack, int x, int y) {
   GL11.glPushMatrix();
   GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
   GL11.glEnable(GL11.GL_BLEND);
   GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
   int k = (this.width - this.xSize) / 2;
   int l = (this.height - this.ySize) / 2;
   IIcon iicon1 = stack.getIconIndex();
   this.mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);
   this.drawTexturedModelRectFromIcon(x, y, iicon1, 16, 16);
   GL11.glDisable(GL11.GL_BLEND);
   GL11.glPopMatrix();
   this.mc.getTextureManager().bindTexture(PymParticleProducerGuiTextures);
 }
コード例 #6
0
  /** Renders the item */
  public void doRenderItem(
      ArrowEntity arrow, double par2, double par4, double par6, float par8, float par9) {
    this.random.setSeed(187L);
    ItemStack itemstack = arrow.getEntityItem();

    if (itemstack.getItem() != null) {
      GL11.glPushMatrix();
      float f2 =
          shouldBob() ? MathHelper.sin(((float) 0 + par9 * 0.2f) / 10.0F + 0) * 0.1F + 0.1F : 0F;
      float f3 = (((float) 0 + par9 * 0.2f) / 20.0F + 0) * (180F / (float) Math.PI);
      byte b0 = getMiniBlockCount(itemstack);

      GL11.glTranslatef((float) par2, (float) par4 + f2, (float) par6);
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      int i;
      float f4;
      float f5;
      float f6;

      float f8;

      if (itemstack.getItem().requiresMultipleRenderPasses()) {
        // GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
        GL11.glTranslatef(0.0F, -0.05F, 0.0F);

        this.loadTexture("/gui/items.png");

        for (int k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) {
          this.random.setSeed(187L);
          Icon icon = itemstack.getItem().getIcon(itemstack, k);
          f8 = 1.0F;

          if (this.renderWithColor) {
            i = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, k);
            f5 = (float) (i >> 16 & 255) / 255.0F;
            f4 = (float) (i >> 8 & 255) / 255.0F;
            f6 = (float) (i & 255) / 255.0F;
            GL11.glColor4f(f5 * f8, f4 * f8, f6 * f8, 1.0F);
            this.renderDroppedItem(arrow, icon, b0, par9, f5 * f8, f4 * f8, f6 * f8);
          } else {
            this.renderDroppedItem(arrow, icon, b0, par9, 1.0F, 1.0F, 1.0F);
          }
          GL11.glScalef(1.005f, 1.005f, 1.005f);
          // GL11.glTranslatef(0F, -0.0025F, 0.0F);
        }
      } else {
        GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
        GL11.glTranslatef(0.0F, -0.05F, 0.0F);

        Icon icon1 = itemstack.getIconIndex();

        if (itemstack.getItemSpriteNumber() == 0) {
          this.loadTexture("/terrain.png");
        } else {
          this.loadTexture("/gui/items.png");
        }

        if (this.renderWithColor) {
          int l = Item.itemsList[itemstack.itemID].getColorFromItemStack(itemstack, 0);
          f8 = (float) (l >> 16 & 255) / 255.0F;
          float f9 = (float) (l >> 8 & 255) / 255.0F;
          f5 = (float) (l & 255) / 255.0F;
          f4 = 1.0F;
          this.renderDroppedItem(arrow, icon1, b0, par9, f8 * f4, f9 * f4, f5 * f4);
        } else {
          this.renderDroppedItem(arrow, icon1, b0, par9, 1.0F, 1.0F, 1.0F);
        }
      }

      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      GL11.glPopMatrix();
    }
  }
コード例 #7
0
  /** Renders the item's icon or block into the UI at the specified position. */
  public void renderItemIntoGUI(
      FontRenderer par1FontRenderer,
      RenderEngine par2RenderEngine,
      ItemStack par3ItemStack,
      int par4,
      int par5) {
    int k = par3ItemStack.itemID;
    int l = par3ItemStack.getItemDamage();
    Icon icon = par3ItemStack.getIconIndex();
    float f;
    float f1;
    float f2;

    int j1;

    if (Item.itemsList[k].requiresMultipleRenderPasses()) {
      GL11.glDisable(GL11.GL_LIGHTING);
      par2RenderEngine.bindTexture(
          par3ItemStack.getItemSpriteNumber() == 0 ? "/terrain.png" : "/gui/items.png");

      for (j1 = 0; j1 < Item.itemsList[k].getRenderPasses(l); ++j1) {
        Icon icon1 = Item.itemsList[k].getIcon(par3ItemStack, j1);
        int k1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, j1);
        f = (float) (k1 >> 16 & 255) / 255.0F;
        f1 = (float) (k1 >> 8 & 255) / 255.0F;
        float f3 = (float) (k1 & 255) / 255.0F;

        if (this.renderWithColor) {
          GL11.glColor4f(f, f1, f3, 1.0F);
        }

        this.renderIcon(par4, par5, icon1, 16, 16);
      }

      GL11.glEnable(GL11.GL_LIGHTING);
    } else {
      GL11.glDisable(GL11.GL_LIGHTING);

      if (par3ItemStack.getItemSpriteNumber() == 0) {
        par2RenderEngine.bindTexture("/terrain.png");
      } else {
        par2RenderEngine.bindTexture("/gui/items.png");
      }

      if (icon == null) {
        icon = par2RenderEngine.getMissingIcon(par3ItemStack.getItemSpriteNumber());
      }

      j1 = Item.itemsList[k].getColorFromItemStack(par3ItemStack, 0);
      float f4 = (float) (j1 >> 16 & 255) / 255.0F;
      f2 = (float) (j1 >> 8 & 255) / 255.0F;
      f = (float) (j1 & 255) / 255.0F;

      if (this.renderWithColor) {
        GL11.glColor4f(f4, f2, f, 1.0F);
      }

      this.renderIcon(par4, par5, icon, 16, 16);
      GL11.glEnable(GL11.GL_LIGHTING);
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
  }