Search in sources :

Example 41 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project GregTech by GregTechCE.

the class FacadeRenderer method renderItemCover.

public static void renderItemCover(CCRenderState ccrs, int side, ItemStack renderStack, Cuboid6 bounds) {
    Minecraft minecraft = Minecraft.getMinecraft();
    RenderItem renderItem = minecraft.getRenderItem();
    IBakedModel model = renderItem.getItemModelWithOverrides(renderStack, null, null);
    IBlockState state = FacadeHelper.lookupBlockForItem(renderStack);
    String cacheKey = state.getBlock().getRegistryName() + "|" + state.getBlock().getMetaFromState(state);
    List<CCQuad> renderQuads = itemQuadCache.getIfPresent(cacheKey);
    if (renderQuads == null) {
        List<BakedQuad> quads = new ArrayList<>(model.getQuads(null, null, 0));
        for (EnumFacing face : EnumFacing.VALUES) {
            quads.addAll(model.getQuads(null, face, 0));
        }
        renderQuads = applyItemTint(sliceQuads(CCQuad.fromArray(quads), side, bounds), renderStack);
        itemQuadCache.put(cacheKey, renderQuads);
    }
    AdvCCRSConsumer consumer = new AdvCCRSConsumer(ccrs);
    consumer.setTranslation(new Matrix4().translate(Vector3.center.copy().subtract(bounds.center())).scale(1.05, 1.05, 1.05));
    for (CCQuad quad : renderQuads) {
        quad.pipe(consumer);
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) CCQuad(codechicken.lib.render.CCQuad) Minecraft(net.minecraft.client.Minecraft) Matrix4(codechicken.lib.vec.Matrix4) RenderItem(net.minecraft.client.renderer.RenderItem) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 42 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project SilentGems by SilentChaos512.

the class RenderTileChaosAltar method renderItem.

private void renderItem(World world, ItemStack stack, float partialTicks) {
    RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
    if (stack != null) {
        // GlStateManager.translate(0.5, 0.5, 0.5);
        EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, stack.copy());
        StackHelper.setCount(entityitem.getEntityItem(), 1);
        entityitem.hoverStart = 0.0F;
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
        GlStateManager.rotate(rotation, 0.0F, 1.0F, 0);
        Vec3d vec = new Vec3d(0.0, 0.25, 0.0);
        GlStateManager.translate(vec.xCoord, vec.yCoord, vec.zCoord);
        float scale = 0.5f;
        GlStateManager.scale(scale, scale, scale);
        GlStateManager.pushAttrib();
        RenderHelper.enableStandardItemLighting();
        itemRenderer.renderItem(entityitem.getEntityItem(), ItemCameraTransforms.TransformType.FIXED);
        RenderHelper.disableStandardItemLighting();
        GlStateManager.popAttrib();
        GlStateManager.enableLighting();
        GlStateManager.popMatrix();
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) EntityItem(net.minecraft.entity.item.EntityItem) Vec3d(net.minecraft.util.math.Vec3d)

Example 43 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 44 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 45 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)

Aggregations

RenderItem (net.minecraft.client.renderer.RenderItem)55 ItemStack (net.minecraft.item.ItemStack)18 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