コード例 #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
  /** Render the item's icon or block into the GUI, including the glint effect. */
  public void renderItemAndEffectIntoGUI(
      FontRenderer par1FontRenderer,
      RenderEngine par2RenderEngine,
      ItemStack par3ItemStack,
      int par4,
      int par5) {
    if (par3ItemStack != null) {
      if (!ForgeHooksClient.renderInventoryItem(
          renderBlocks,
          par2RenderEngine,
          par3ItemStack,
          renderWithColor,
          zLevel,
          (float) par4,
          (float) par5)) {
        this.renderItemIntoGUI(par1FontRenderer, par2RenderEngine, par3ItemStack, par4, par5);
      }

      if (par3ItemStack.hasEffect()) {
        GL11.glDepthFunc(GL11.GL_GREATER);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(false);
        par2RenderEngine.bindTexture("%blur%/misc/glint.png");
        this.zLevel -= 50.0F;
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_DST_COLOR);
        GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
        this.renderGlint(par4 * 431278612 + par5 * 32178161, par4 - 2, par5 - 2, 20, 20);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        this.zLevel += 50.0F;
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
    }
  }
コード例 #3
0
  /** Renders a dropped item */
  private void renderDroppedItem(
      ArrowEntity arrow, Icon par2Icon, int par3, float par4, float par5, float par6, float par7) {
    Tessellator tessellator = Tessellator.instance;

    if (par2Icon == null) {
      par2Icon =
          this.renderManager.renderEngine.getMissingIcon(
              arrow.getEntityItem().getItemSpriteNumber());
    }

    float f4 = par2Icon.getMinU();
    float f5 = par2Icon.getMaxU();
    float f6 = par2Icon.getMinV();
    float f7 = par2Icon.getMaxV();
    float f8 = 1.0F;
    float f9 = 0.5F;
    float f10 = 0.25F;
    float f11;

    GL11.glPushMatrix();
    /*float rotation = dagger.prevRotationPitch + (dagger.rotationPitch - dagger.prevRotationPitch) * par7;
    GL11.glRotatef(dagger.rotationYaw + 90, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-rotation * 15, 0.0F, 0.0F, 1.0F);*/
    GL11.glRotatef(
        arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par4 - 90.0F,
        0.0F,
        1.0F,
        0.0F);
    GL11.glRotatef(
        arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par4 - 45.0F,
        0.0F,
        0.0F,
        1.0F);
    float f12 = 0.0625F;
    f11 = 0.021875F;
    ItemStack itemstack = arrow.getEntityItem();
    int j = itemstack.stackSize;
    byte b0 = getMiniItemCount(itemstack);

    GL11.glTranslatef(-f9, -f10, -((f12 + f11) * (float) b0 / 2.0F));

    for (int k = 0; k < b0; ++k) {
      GL11.glTranslatef(0f, 0f, f12 + f11);

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

      GL11.glColor4f(par5, par6, par7, 1.0F);
      ItemRenderer.renderItemIn2D(
          tessellator, f5, f6, f4, f7, par2Icon.getSheetWidth(), par2Icon.getSheetHeight(), f12);

      if (itemstack != null && itemstack.hasEffect()) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        this.renderManager.renderEngine.bindTexture("%blur%/misc/glint.png");
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f13 = 0.76F;
        GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f14 = 0.125F;
        GL11.glScalef(f14, f14, f14);
        float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
        GL11.glTranslatef(f15, 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, 255, 255, f12);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f14, f14, f14);
        f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
        GL11.glTranslatef(-f15, 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, 255, 255, f12);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
    }

    GL11.glPopMatrix();
  }
コード例 #4
0
  /** Renders the item stack for being in an entity's hand Args: itemStack */
  public void renderItem(EntityLiving par1EntityLiving, ItemStack par2ItemStack, int par3) {
    GL11.glPushMatrix();

    Block block = null;
    if (par2ItemStack.getItem() instanceof ItemBlock
        && par2ItemStack.itemID < Block.blocksList.length) {
      block = Block.blocksList[par2ItemStack.itemID];
    }

    IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(par2ItemStack, EQUIPPED);

    if (customRenderer != null) {
      this.mc.renderEngine.bindTexture(
          par2ItemStack.getItemSpriteNumber() == 0 ? "/terrain.png" : "/gui/items.png");
      ForgeHooksClient.renderEquippedItem(
          customRenderer, renderBlocksInstance, par1EntityLiving, par2ItemStack);
    } else if (block != null
        && par2ItemStack.getItemSpriteNumber() == 0
        && RenderBlocks.renderItemIn3d(Block.blocksList[par2ItemStack.itemID].getRenderType())) {
      this.mc.renderEngine.bindTexture("/terrain.png");
      this.renderBlocksInstance.renderBlockAsItem(
          Block.blocksList[par2ItemStack.itemID], par2ItemStack.getItemDamage(), 1.0F);
    } else {
      Icon icon = par1EntityLiving.getItemIcon(par2ItemStack, par3);

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

      if (par2ItemStack.getItemSpriteNumber() == 0) {
        this.mc.renderEngine.bindTexture("/terrain.png");
      } else {
        this.mc.renderEngine.bindTexture("/gui/items.png");
      }

      Tessellator tessellator = Tessellator.instance;
      float f = icon.getMinU();
      float f1 = icon.getMaxU();
      float f2 = icon.getMinV();
      float f3 = icon.getMaxV();
      float f4 = 0.0F;
      float f5 = 0.3F;
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glTranslatef(-f4, -f5, 0.0F);
      float f6 = 1.5F;
      GL11.glScalef(f6, f6, f6);
      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);
      renderItemIn2D(
          tessellator, f1, f2, f, f3, icon.getSheetWidth(), icon.getSheetHeight(), 0.0625F);

      if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        this.mc.renderEngine.bindTexture("%blur%/misc/glint.png");
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        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);
    }

    GL11.glPopMatrix();
  }
コード例 #5
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();
  }