Search in sources :

Example 6 with RenderItem

use of net.minecraft.client.renderer.entity.RenderItem in project BluePower by Qmunity.

the class TubeStack method render.

@SideOnly(Side.CLIENT)
public void render(float partialTick) {
    if (renderMode == RenderMode.AUTO) {
        renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL : RenderMode.REDUCED;
    }
    final RenderMode finalRenderMode = renderMode;
    if (customRenderItem == null) {
        customRenderItem = new RenderItem() {

            @Override
            public boolean shouldBob() {
                return false;
            }

            ;

            @Override
            public byte getMiniBlockCount(ItemStack stack, byte original) {
                return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original;
            }
        };
        customRenderItem.setRenderManager(RenderManager.instance);
        renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
        renderedItem.hoverStart = 0.0F;
    }
    renderedItem.setEntityItemStack(stack);
    double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;
    GL11.glPushMatrix();
    GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5, heading.offsetZ * renderProgress * 0.5);
    if (finalRenderMode != RenderMode.NONE) {
        GL11.glPushMatrix();
        if (stack.stackSize > 5) {
            GL11.glScaled(0.8, 0.8, 0.8);
        }
        if (!(stack.getItem() instanceof ItemBlock)) {
            GL11.glScaled(0.8, 0.8, 0.8);
            GL11.glTranslated(0, -0.15, 0);
        }
        customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    } else {
        float size = 0.02F;
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBegin(GL11.GL_QUADS);
        RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    if (color != TubeColor.NONE) {
        float size = 0.2F;
        int colorInt = ItemDye.field_150922_c[color.ordinal()];
        float red = (colorInt >> 16) / 256F;
        float green = (colorInt >> 8 & 255) / 256F;
        float blue = (colorInt & 255) / 256F;
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor3f(red, green, blue);
        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
        RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size));
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
    }
    GL11.glPopMatrix();
}
Also used : RenderItem(net.minecraft.client.renderer.entity.RenderItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) EntityItem(net.minecraft.entity.item.EntityItem) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 7 with RenderItem

use of net.minecraft.client.renderer.entity.RenderItem in project Engine by VoltzEngine-Project.

the class RenderItemOverlayUtility method renderItem.

public static void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Pos position, float rotationYaw, int angle) {
    if (itemStack != null) {
        EntityItem entityItem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack.copy());
        entityItem.getEntityItem().stackSize = 1;
        entityItem.hoverStart = 0.0F;
        GL11.glPushMatrix();
        GL11.glTranslated(position.x(), position.y(), position.z());
        GL11.glRotatef(180.0F + rotationYaw, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(90 * angle, 1, 0, 0);
        RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
        boolean fancyGraphics = RenderManager.instance.options.fancyGraphics;
        RenderManager.instance.options.fancyGraphics = true;
        renderItem.doRender(entityItem, 0, 0, 0, 0, 0);
        RenderManager.instance.options.fancyGraphics = fancyGraphics;
        GL11.glPopMatrix();
    }
}
Also used : RenderItem(net.minecraft.client.renderer.entity.RenderItem) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

RenderItem (net.minecraft.client.renderer.entity.RenderItem)7 EntityItem (net.minecraft.entity.item.EntityItem)4 ItemBlock (net.minecraft.item.ItemBlock)4 FontRenderer (net.minecraft.client.gui.FontRenderer)2 Item (net.minecraft.item.Item)2 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 LPTravelingItem (logisticspipes.transport.LPTravelingItem)1 Block (net.minecraft.block.Block)1 BlockPane (net.minecraft.block.BlockPane)1 Minecraft (net.minecraft.client.Minecraft)1 Tessellator (net.minecraft.client.renderer.Tessellator)1 ItemStack (net.minecraft.item.ItemStack)1 IIcon (net.minecraft.util.IIcon)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 IItemRenderer (net.minecraftforge.client.IItemRenderer)1 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)1