Java Code Examples for net.minecraft.item.Item#shouldRotateAroundWhenRendering()

The following examples show how to use net.minecraft.item.Item#shouldRotateAroundWhenRendering() .
Example 1
Project: Gadomancy   File: RenderGolemHelper.java    License: GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void renderToolItem(EntityGolemBase golem, ItemStack itemstack, ModelBase mainModel, RenderManager renderManager) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    float angle = (float) (0.195 * Math.PI / -1 * ((ModelGolem) mainModel).golemRightArm.rotateAngleX);

    float y = (float) (Math.cos(angle) * 1.15);
    float z = (float) (Math.sin(angle) * 1.15);

    GL11.glTranslatef(-0.25F, y, z * -0.5f);

    GL11.glRotated(angle / Math.PI * 180f, -1, 0, 0);

    float fs = 0.66F;
    GL11.glScalef(fs, fs, fs);

    net.minecraftforge.client.IItemRenderer customRenderer = net.minecraftforge.client.MinecraftForgeClient.getItemRenderer(itemstack, net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED);
    boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED, itemstack, net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D));

    Item item = itemstack.getItem();
    float f1;

    if (item instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(item).getRenderType())))
    {
        f1 = 0.5F;
        GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
        f1 *= 0.75F;
        GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(-f1, -f1, f1);
    }
    else if (item == Items.bow)
    {
        f1 = 0.625F;
        GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
        GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
        GL11.glScalef(f1, -f1, f1);
        GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    }
    else if (item.isFull3D())
    {
        f1 = 0.625F;

        if (item.shouldRotateAroundWhenRendering())
        {
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            GL11.glTranslatef(0.0F, -0.125F, 0.0F);
        }

        GL11.glTranslatef(0.0F, 0.1875F, 0.0F);

        GL11.glScalef(f1, -f1, f1);
        GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
    }
    else
    {
        f1 = 0.375F;
        GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
        GL11.glScalef(f1, f1, f1);
        GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
    }

    float f2;
    int i;
    float f5;

    if (itemstack.getItem().requiresMultipleRenderPasses())
    {
        for (i = 0; i < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++i)
        {
            int j = itemstack.getItem().getColorFromItemStack(itemstack, i);
            f5 = (float)(j >> 16 & 255) / 255.0F;
            f2 = (float)(j >> 8 & 255) / 255.0F;
            float f3 = (float)(j & 255) / 255.0F;
            GL11.glColor4f(f5, f2, f3, 1.0F);

            renderManager.itemRenderer.renderItem(golem, itemstack, i);
        }
    }
    else
    {
        i = itemstack.getItem().getColorFromItemStack(itemstack, 0);
        float f4 = (float)(i >> 16 & 255) / 255.0F;
        f5 = (float)(i >> 8 & 255) / 255.0F;
        f2 = (float)(i & 255) / 255.0F;
        GL11.glColor4f(f4, f5, f2, 1.0F);

        renderManager.itemRenderer.renderItem(golem, itemstack, 0);
    }


    GL11.glScaled(1.0D, 1.0D, 1.0D);

    GL11.glPopMatrix();
}
 
Example 2
Project: EnderZoo   File: RenderWitherWitch.java    License: Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public void doRenderLayer(EntityWitherWitch entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_,
        float p_177141_6_, float p_177141_7_, float scale) {
      ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

      if (itemstack != null) {
        GlStateManager.color(1.0F, 1.0F, 1.0F);
        GlStateManager.pushMatrix();

        if (this.witchRenderer.getMainModel().isChild) {
          GlStateManager.translate(0.0F, 0.625F, 0.0F);
          GlStateManager.rotate(-20.0F, -1.0F, 0.0F, 0.0F);
          float f = 0.5F;
          GlStateManager.scale(f, f, f);
        }

        ((ModelWitch) this.witchRenderer.getMainModel()).villagerNose.postRender(0.0625F);
        GlStateManager.translate(-0.0625F, 0.53125F, 0.21875F);
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();
      //TODO: method is gone, so skip?
//        if (item instanceof ItemBlock && minecraft.getBlockRendererDispatcher().isEntityBlockAnimated(Block.getBlockFromItem(item))) {
//          GlStateManager.translate(0.0F, 0.0625F, -0.25F);
//          GlStateManager.rotate(30.0F, 1.0F, 0.0F, 0.0F);
//          GlStateManager.rotate(-5.0F, 0.0F, 1.0F, 0.0F);
//          float f4 = 0.375F;
//          GlStateManager.scale(f4, -f4, f4);
//        } else 
          if (item == Items.BOW) {
          GlStateManager.translate(0.0F, 0.125F, -0.125F);
          GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
          float f1 = 0.625F;
          GlStateManager.scale(f1, -f1, f1);
          GlStateManager.rotate(-100.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(-20.0F, 0.0F, 1.0F, 0.0F);
        } else if (item.isFull3D()) {
          if (item.shouldRotateAroundWhenRendering()) {
            GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
            GlStateManager.translate(0.0F, -0.0625F, 0.0F);
          }

          this.witchRenderer.transformHeldFull3DItemLayer();
          GlStateManager.translate(0.0625F, -0.125F, 0.0F);
          float f2 = 0.625F;
          GlStateManager.scale(f2, -f2, f2);
          GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(0.0F, 0.0F, 1.0F, 0.0F);
        } else {
          GlStateManager.translate(0.1875F, 0.1875F, 0.0F);
          float f3 = 0.875F;
          GlStateManager.scale(f3, f3, f3);
          GlStateManager.rotate(-20.0F, 0.0F, 0.0F, 1.0F);
          GlStateManager.rotate(-60.0F, 1.0F, 0.0F, 0.0F);
          GlStateManager.rotate(-30.0F, 0.0F, 0.0F, 1.0F);
        }

        GlStateManager.rotate(-15.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(40.0F, 0.0F, 0.0F, 1.0F);
        minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND);
        GlStateManager.popMatrix();
      }
    }