Search in sources :

Example 46 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project minecolonies by Minecolonies.

the class ItemIcon method drawItemStack.

/**
 * Modified from GuiContainer
 */
private void drawItemStack(final ItemStack stack, final int x, final int y) {
    if (ItemStackUtils.isEmpty(itemStack)) {
        return;
    }
    final RenderItem itemRender = mc.getRenderItem();
    GlStateManager.translate(x, y, GUI_ITEM_Z_TRANSLATE);
    GlStateManager.scale(this.getWidth() / DEFAULT_ITEMSTACK_SIZE, this.getHeight() / DEFAULT_ITEMSTACK_SIZE, 1f);
    FontRenderer font = stack.getItem().getFontRenderer(stack);
    if (font == null) {
        font = mc.fontRenderer;
    }
    itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
    itemRender.renderItemOverlayIntoGUI(font, stack, 0, 0, null);
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 47 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Binnie by ForestryMC.

the class FlowerAlyzerPlugin method drawAnalyticsPage1.

@SideOnly(Side.CLIENT)
@Override
public void drawAnalyticsPage1(GuiScreen gui, ItemStack itemStack) {
    lastTopOffset = 10;
    guiLeft = (gui.width - 246) / 2;
    guiTop = (gui.height - 238) / 2;
    IFlower flower = BotanyAPI.flowerRoot.getMember(itemStack);
    if (flower == null) {
        return;
    }
    ItemStack renderP = getIconStacks().get(flower.getGenome().getPrimary().getUID());
    ItemStack renderS = getIconStacks().get(flower.getGenome().getSecondary().getUID());
    gui.mc.fontRenderer.drawString("Active", guiLeft + 10 + COLUMN_1, guiTop + 10, 0xffffff);
    gui.mc.fontRenderer.drawString("Inactive", guiLeft + 10 + COLUMN_2, guiTop + 10, 0xffffff);
    if (renderP != null && renderS != null) {
        RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
        itemRender.renderItemAndEffectIntoGUI(renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12);
        itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderP, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
        itemRender.renderItemAndEffectIntoGUI(renderS, guiLeft + 10 + COLUMN_2, guiTop + 10 + 12);
        itemRender.renderItemOverlayIntoGUI(gui.mc.fontRenderer, renderS, guiLeft + 10 + COLUMN_1, guiTop + 10 + 12, null);
    }
    guiTop += ROW_SIZE * 3;
    for (EnumFlowerChromosome chromosom : firstPageChromosome) {
        drawChromosome(gui, chromosom, flower);
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) IFlower(binnie.botany.api.genetics.IFlower) ItemStack(net.minecraft.item.ItemStack) EnumFlowerChromosome(binnie.botany.api.genetics.EnumFlowerChromosome) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 48 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Binnie by ForestryMC.

the class RenderUtil method drawItem.

public static void drawItem(final Point pos, final ItemStack itemStack, final boolean rotating) {
    GlStateManager.enableBlend();
    GlStateManager.enableDepth();
    GlStateManager.pushAttrib();
    Preconditions.checkNotNull(itemStack);
    Minecraft minecraft = Minecraft.getMinecraft();
    RenderHelper.enableGUIStandardItemLighting();
    RenderItem renderItem = minecraft.getRenderItem();
    FontRenderer font = getFontRenderer(minecraft, itemStack);
    if (rotating) {
        GlStateManager.pushMatrix();
        final float phase = Minecraft.getSystemTime() / 20;
        /**
         * {@link RenderItem#setupGuiTransform(int, int, boolean)} It adds 100 to zLevel from
         * {@link RenderItem#renderItemAndEffectIntoGUI(net.minecraft.entity.EntityLivingBase, net.minecraft.item.ItemStack, int, int)}.
         * So z=150
         */
        GlStateManager.translate(8, 8, 150);
        GlStateManager.rotate(phase, 0, -0.866f, 0.5f);
        GlStateManager.translate(-8, -8, -150);
    }
    renderItem.renderItemAndEffectIntoGUI(null, itemStack, pos.xPos(), pos.yPos());
    if (rotating) {
        GlStateManager.popMatrix();
    }
    renderItem.renderItemOverlayIntoGUI(font, itemStack, pos.xPos(), pos.yPos(), null);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.popAttrib();
    GlStateManager.disableBlend();
    GlStateManager.disableDepth();
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) FontRenderer(net.minecraft.client.gui.FontRenderer) Minecraft(net.minecraft.client.Minecraft)

Example 49 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project ImmersiveEngineering by BluSunrize.

the class GuiButtonItem method drawButton.

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
    if (this.visible) {
        ClientUtils.bindTexture("immersiveengineering:textures/gui/hud_elements.png");
        GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
        this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
        GlStateManager.blendFunc(770, 771);
        this.drawTexturedModalRect(x, y, 24 + (state ? 18 : 0), 128, width, height);
        this.mouseDragged(mc, mouseX, mouseY);
        if (!item.isEmpty()) {
            this.zLevel = 200.0F;
            RenderItem itemRender = mc.getRenderItem();
            itemRender.zLevel = 200.0F;
            FontRenderer font = item.getItem().getFontRenderer(item);
            if (font == null)
                font = mc.fontRenderer;
            itemRender.renderItemAndEffectIntoGUI(item, x + 1, y + 1);
            this.zLevel = 0.0F;
            itemRender.zLevel = 0.0F;
            if (!state) {
                RenderHelper.enableStandardItemLighting();
                GlStateManager.disableLighting();
                GlStateManager.disableDepth();
                ClientUtils.drawColouredRect(x + 1, y + 1, 16, 16, 0x77444444);
                GlStateManager.enableLighting();
                GlStateManager.enableDepth();
            }
            RenderHelper.disableStandardItemLighting();
        }
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 50 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project LogisticsPipes by RS485.

the class ItemStackRenderer method renderInWorld.

public void renderInWorld() {
    assert renderManager != null;
    assert renderItem != null;
    assert scaleX != 0.0F;
    assert scaleY != 0.0F;
    assert scaleZ != 0.0F;
    if (entityitem == null || !ItemStack.areItemStacksEqual(entityitem.getItem(), itemstack)) {
        Objects.requireNonNull(world, "World is needed for EntityItem creation");
        if (itemstack.isEmpty()) {
            // :itemcard: 🤷
            itemstack = new ItemStack(LPItems.itemCard);
        }
        entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemstack);
        entityitem.getItem().setCount(1);
        entityitem.hoverStart = 0.0F;
    }
    Item item = itemstack.getItem();
    if (item instanceof ItemBlock) {
        Block block = ((ItemBlock) item).getBlock();
        if (block instanceof BlockPane) {
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
        }
    } else if (item == LPItems.requestTable) {
        GlStateManager.scale(0.5F, 0.5F, 0.5F);
    }
    itemEntityRenderer.doRender(entityitem, posX, posY, zLevel, 0.0F, partialTickTime);
}
Also used : Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) RenderEntityItem(net.minecraft.client.renderer.entity.RenderEntityItem) RenderItem(net.minecraft.client.renderer.RenderItem) BlockPane(net.minecraft.block.BlockPane) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) EntityItem(net.minecraft.entity.item.EntityItem) RenderEntityItem(net.minecraft.client.renderer.entity.RenderEntityItem)

Aggregations

RenderItem (net.minecraft.client.renderer.RenderItem)51 ItemStack (net.minecraft.item.ItemStack)17 Minecraft (net.minecraft.client.Minecraft)11 FontRenderer (net.minecraft.client.gui.FontRenderer)10 Item (net.minecraft.item.Item)7 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)6 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)6 EntityItem (net.minecraft.entity.item.EntityItem)6 ItemModelMesher (net.minecraft.client.renderer.ItemModelMesher)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 TextureManager (net.minecraft.client.renderer.texture.TextureManager)4 ArrayList (java.util.ArrayList)3 IBlockState (net.minecraft.block.state.IBlockState)3 ItemBlock (net.minecraft.item.ItemBlock)3 Vec3d (net.minecraft.util.math.Vec3d)3 Block (net.minecraft.block.Block)2 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)2 ScaledResolution (net.minecraft.client.gui.ScaledResolution)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 EnumFacing (net.minecraft.util.EnumFacing)2