Search in sources :

Example 1 with IItemRenderer

use of net.minecraftforge.client.IItemRenderer in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method renderItemStackOnSign.

public void renderItemStackOnSign(ItemStack itemstack) {
    if (itemstack == null || itemstack.getItem() == null) {
        // Only happens on false configuration
        return;
    }
    Item item = itemstack.getItem();
    IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, ItemRenderType.INVENTORY);
    Minecraft.getMinecraft().renderEngine.bindTexture(itemstack.getItemSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
    GL11.glPushMatrix();
    if (customRenderer != null) {
        if (customRenderer.shouldUseRenderHelper(ItemRenderType.INVENTORY, itemstack, ItemRendererHelper.INVENTORY_BLOCK)) {
            GL11.glScalef(0.20F, -0.20F, -0.01F);
            GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_LIGHT0);
            GL11.glDisable(GL11.GL_LIGHT1);
            GL11.glDisable(GL11.GL_COLOR_MATERIAL);
            customRenderer.renderItem(ItemRenderType.INVENTORY, itemstack, renderBlocks);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glEnable(GL11.GL_LIGHT1);
            GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        } else {
            GL11.glScalef(0.018F, -0.018F, -0.01F);
            GL11.glTranslatef(-7F, -8F, 0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_LIGHT0);
            GL11.glDisable(GL11.GL_LIGHT1);
            GL11.glDisable(GL11.GL_COLOR_MATERIAL);
            customRenderer.renderItem(ItemRenderType.INVENTORY, itemstack, renderBlocks);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glEnable(GL11.GL_LIGHT1);
            GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        }
    } else if (item instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType())) {
        GL11.glScalef(0.20F, -0.20F, -0.01F);
        GL11.glRotatef(210.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(-45.0F, 0.0F, 1.0F, 0.0F);
        renderBlocks.useInventoryTint = false;
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LIGHT0);
        GL11.glDisable(GL11.GL_LIGHT1);
        GL11.glDisable(GL11.GL_COLOR_MATERIAL);
        renderBlocks.renderBlockAsItem(Block.getBlockFromItem(item), itemstack.getItemDamage(), 1.0F);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_LIGHT0);
        GL11.glEnable(GL11.GL_LIGHT1);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    } else {
        GL11.glScalef(0.02F, -0.02F, -0.01F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LIGHT0);
        GL11.glDisable(GL11.GL_LIGHT1);
        GL11.glDisable(GL11.GL_COLOR_MATERIAL);
        GL11.glTranslatef(-8F, -8F, 0.0F);
        if (item.requiresMultipleRenderPasses()) {
            for (int var14 = 0; var14 < item.getRenderPasses(itemstack.getItemDamage()); ++var14) {
                IIcon var15 = item.getIconFromDamageForRenderPass(itemstack.getItemDamage(), var14);
                renderItem(var15);
            }
        } else {
            renderItem(item.getIconIndex(itemstack));
        }
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_LIGHT0);
        GL11.glEnable(GL11.GL_LIGHT1);
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    }
    GL11.glPopMatrix();
}
Also used : Item(net.minecraft.item.Item) RenderItem(net.minecraft.client.renderer.entity.RenderItem) LPTravelingItem(logisticspipes.transport.LPTravelingItem) IItemRenderer(net.minecraftforge.client.IItemRenderer) IIcon(net.minecraft.util.IIcon) ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

LPTravelingItem (logisticspipes.transport.LPTravelingItem)1 RenderItem (net.minecraft.client.renderer.entity.RenderItem)1 Item (net.minecraft.item.Item)1 ItemBlock (net.minecraft.item.ItemBlock)1 IIcon (net.minecraft.util.IIcon)1 IItemRenderer (net.minecraftforge.client.IItemRenderer)1