Search in sources :

Example 51 with RenderItem

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

the class LogisticsRenderPipe method renderItemStackOnSign.

public void renderItemStackOnSign(@Nonnull ItemStack itemstack) {
    if (itemstack.isEmpty()) {
        // Only happens on false configuration
        return;
    }
    Minecraft mc = Minecraft.getMinecraft();
    RenderItem itemRender = mc.getRenderItem();
    GlStateManager.disableLighting();
    // Forge: Reset color in case Items change it.
    GlStateManager.color(1F, 1F, 1F);
    // Forge: Make sure blend is enabled else tabs show a white border.
    GlStateManager.enableBlend();
    itemRender.zLevel = 100.0F;
    GlStateManager.enableRescaleNormal();
    // itemRender.renderItemAndEffectIntoGUI(itemstack, 0, 0);
    // item render code
    GlStateManager.pushMatrix();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableAlpha();
    GlStateManager.alphaFunc(516, 0.1F);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    // mezz.jei.render.ItemStackFastRenderer#getBakedModel
    ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
    IBakedModel bakedModel = itemModelMesher.getItemModel(itemstack);
    bakedModel = bakedModel.getOverrides().handleItemState(bakedModel, itemstack, null, null);
    // make item/block flat and position it
    GlStateManager.translate(0.05F, 0F, 0F);
    GlStateManager.scale(0.8F, 0.8F, 0.001F);
    // model rotation
    bakedModel = ForgeHooksClient.handleCameraTransforms(bakedModel, ItemCameraTransforms.TransformType.GUI, false);
    // model scaling to fit on sign
    GlStateManager.scale(0.4F, 0.4F, 0.4F);
    itemRender.renderItem(itemstack, bakedModel);
    GlStateManager.disableRescaleNormal();
    GlStateManager.disableAlpha();
    GlStateManager.popMatrix();
    mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
    // item render code end
    // not needed?
    // itemRender.renderItemOverlays(mc.fontRenderer, itemstack, 0, 0);
    itemRender.zLevel = 0.0F;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ItemModelMesher(net.minecraft.client.renderer.ItemModelMesher) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Minecraft(net.minecraft.client.Minecraft)

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