Search in sources :

Example 21 with RenderItem

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

the class RenderThrownTomahawk method doRender.

@Override
public void doRender(EntityThrownTomahawk entity, double x, double y, double z, float entityYaw, float partialTicks) {
    if (entity == null)
        return;
    ItemStack stack = entity.getThrownStack();
    if (stack == null || stack.getItem() == null || StackHelper.isEmpty(stack))
        return;
    RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
    EntityItem entityitem = new EntityItem(entity.world, entity.posX, entity.posY, entity.posZ, stack);
    StackHelper.setCount(entityitem.getEntityItem(), 1);
    entityitem.hoverStart = 0.0F;
    GlStateManager.pushMatrix();
    GlStateManager.disableLighting();
    Vec3d vec = new Vec3d(0.0, 0.25, 0.0);
    GlStateManager.translate(x, y, z);
    GlStateManager.rotate(90 - entity.throwYaw, 0, 1, 0);
    float rotation = entity.spin + (entity.inAir ? entity.SPIN_RATE * partialTicks : 0);
    GlStateManager.rotate(rotation, 0, 0, 1);
    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) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) Vec3d(net.minecraft.util.math.Vec3d)

Example 22 with RenderItem

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

the class RenderTileMaterialGrader method renderItem.

private void renderItem(World world, ItemStack stack, int rotationYaw) {
    RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
    if (StackHelper.isValid(stack)) {
        // GlStateManager.translate(0.5, 0.5, 0.5);
        EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, StackHelper.safeCopy(stack));
        StackHelper.setCount(entityitem.getEntityItem(), 1);
        entityitem.hoverStart = 0.0F;
        GlStateManager.pushMatrix();
        GlStateManager.disableLighting();
        Vec3d vec = new Vec3d(0.0, 0.0, 0.0);
        GlStateManager.translate(vec.xCoord, vec.yCoord, vec.zCoord);
        GlStateManager.rotate(rotationYaw, 0.0F, 1.0F, 0);
        GlStateManager.rotate(-90, 1.0F, 0.0F, 0);
        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 23 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Wizardry by TeamWizardry.

the class RenderCodex method renderItemStack.

// Manually rendering itemstack overlays because mojang set all their states
// to disabled depth which doesn't work for us
public void renderItemStack(ItemStack stack) {
    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();
    GlStateManager.enableRescaleNormal();
    GlStateManager.pushMatrix();
    RenderItem itemRender = Minecraft.getMinecraft().getRenderItem();
    itemRender.renderItemAndEffectIntoGUI(stack, 0, 0);
    GlStateManager.translate(0, 0, 150);
    FontRenderer font = stack.getItem().getFontRenderer(stack);
    if (font == null)
        font = Minecraft.getMinecraft().fontRenderer;
    if (font != null && stack.getCount() != 1) {
        GlStateManager.translate(0, 0, 5);
        GlStateManager.disableLighting();
        GlStateManager.disableBlend();
        font.drawStringWithShadow(stack.getCount() + "", 17F - font.getStringWidth(stack.getCount() + ""), 9F, 0xFFFFFF);
        GlStateManager.enableDepth();
        GlStateManager.enableBlend();
        GlStateManager.translate(0, 0, -5);
    }
    if (stack.getItem().showDurabilityBar(stack)) {
        GlStateManager.disableLighting();
        GlStateManager.disableTexture2D();
        GlStateManager.disableAlpha();
        GlStateManager.disableBlend();
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();
        double health = stack.getItem().getDurabilityForDisplay(stack);
        int rgbfordisplay = stack.getItem().getRGBDurabilityForDisplay(stack);
        int i = Math.round(13.0F - (float) health * 13.0F);
        draw(bufferbuilder, 2, 13, 13, 2, 0, 0, 0, 255);
        draw(bufferbuilder, 2, 13, i, 1, rgbfordisplay >> 16 & 255, rgbfordisplay >> 8 & 255, rgbfordisplay & 255, 255);
        GlStateManager.enableBlend();
        GlStateManager.enableAlpha();
        GlStateManager.enableTexture2D();
        GlStateManager.enableLighting();
    }
    EntityPlayerSP entityplayersp = Minecraft.getMinecraft().player;
    float f3 = entityplayersp == null ? 0.0F : entityplayersp.getCooldownTracker().getCooldown(stack.getItem(), Minecraft.getMinecraft().getRenderPartialTicks());
    if (f3 > 0.0F) {
        GlStateManager.disableLighting();
        GlStateManager.disableTexture2D();
        Tessellator tessellator1 = Tessellator.getInstance();
        BufferBuilder bufferbuilder1 = tessellator1.getBuffer();
        this.draw(bufferbuilder1, 0, MathHelper.floor(16.0F * (1.0F - f3)), 16, MathHelper.ceil(16.0F * f3), 255, 255, 255, 127);
        GlStateManager.enableTexture2D();
        GlStateManager.enableLighting();
    }
    GlStateManager.popMatrix();
    GlStateManager.enableLighting();
    GlStateManager.enableAlpha();
    GlStateManager.enableBlend();
    GlStateManager.disableRescaleNormal();
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) FontRenderer(net.minecraft.client.gui.FontRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP)

Example 24 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ClientProxyCombat method registerItemModel.

private void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    renderItem.getItemModelMesher().register(toRegister, 0, new ModelResourceLocation(ValkyrienWarfareCombatMod.MODID + ":" + toRegister.getUnlocalizedName().substring(5), "inventory"));
    ;
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 25 with RenderItem

use of net.minecraft.client.renderer.RenderItem in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ClientProxyWorld method registerItemModel.

private void registerItemModel(Item toRegister) {
    RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
    renderItem.getItemModelMesher().register(toRegister, 0, new ModelResourceLocation(ValkyrienWarfareWorldMod.MODID + ":" + toRegister.getUnlocalizedName().substring(5), "inventory"));
}
Also used : RenderItem(net.minecraft.client.renderer.RenderItem) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

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