Search in sources :

Example 36 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Metalworks by canitzp.

the class Util method renderItemInWorld.

@SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack) {
    if (!stack.isEmpty()) {
        Minecraft mc = Minecraft.getMinecraft();
        RenderItem renderer = mc.getRenderItem();
        TextureManager manager = mc.getTextureManager();
        IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null);
        manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
        GlStateManager.enableRescaleNormal();
        GlStateManager.enableBlend();
        GlStateManager.pushMatrix();
        model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false);
        renderer.renderItem(stack, model);
        GlStateManager.cullFace(GlStateManager.CullFace.BACK);
        GlStateManager.popMatrix();
        GlStateManager.disableRescaleNormal();
        GlStateManager.disableBlend();
        manager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        manager.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) TextureManager(net.minecraft.client.renderer.texture.TextureManager) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 37 with RenderItem

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

the class WidgetCamouflageTab method draw.

@Override
public void draw(int startX, int startY) {
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    Minecraft minecraft = Minecraft.getMinecraft();
    TextureManager textureManager = minecraft.getTextureManager();
    textureManager.bindTexture(manager.gui.textureFile);
    manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, 196, 0, 48, 25);
    if (handlerSlot != null) {
        manager.gui.drawTexturedModalRect(startX + xPos + 44, startY + yPos, 196, 25, 24, 25);
    }
    if (!typeStack.isEmpty()) {
        textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        RenderItem renderItem = minecraft.getRenderItem();
        renderItem.renderItemIntoGUI(typeStack, startX + xPos + 6, startY + yPos + 6);
    }
    greenhouseSlot.draw(startX, startY);
    if (handlerSlot != null) {
        handlerSlot.draw(startX, startY);
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) TextureManager(net.minecraft.client.renderer.texture.TextureManager) Minecraft(net.minecraft.client.Minecraft)

Example 38 with RenderItem

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

the class WidgetClimateModifier method draw.

public void draw(int startX, int startY) {
    if (!isVisible()) {
        return;
    }
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    textureManager.bindTexture(modifier.getTextureMap());
    TextureAtlasSprite icon = modifier.getIcon();
    if (icon == null) {
        RenderHelper.enableGUIStandardItemLighting();
        ItemStack stack = modifier.getIconItemStack();
        FontRenderer font = null;
        if (!stack.isEmpty()) {
            font = stack.getItem().getFontRenderer(stack);
        }
        if (font == null) {
            font = parent.gui.getFontRenderer();
        }
        RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
        itemRender.renderItemAndEffectIntoGUI(null, stack, xPos + startX, yPos + startY);
        itemRender.renderItemOverlayIntoGUI(font, stack, xPos + startX, yPos + startY, null);
        RenderHelper.disableStandardItemLighting();
    } else {
        parent.gui.drawTexturedModalRect(startX + xPos, startY + yPos, icon, 16, 16);
    }
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) TextureManager(net.minecraft.client.renderer.texture.TextureManager) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemStack(net.minecraft.item.ItemStack)

Example 39 with RenderItem

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

the class GuiUtil method drawItemStack.

public static void drawItemStack(FontRenderer fontRenderer, ItemStack stack, int xPos, int yPos) {
    FontRenderer font = null;
    if (!stack.isEmpty()) {
        font = stack.getItem().getFontRenderer(stack);
    }
    if (font == null) {
        font = fontRenderer;
    }
    RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(stack, xPos, yPos);
    itemRender.renderItemOverlayIntoGUI(font, stack, xPos, yPos, null);
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) FontRenderer(net.minecraft.client.gui.FontRenderer)

Example 40 with RenderItem

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

the class Widget method drawItemStack.

@SideOnly(Side.CLIENT)
protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.0F, 32.0F);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableLighting();
    RenderHelper.enableGUIStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f);
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(itemStack, x, y);
    itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, x, y, altTxt);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableLighting();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    GlStateManager.disableDepth();
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) Minecraft(net.minecraft.client.Minecraft) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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