Java Code Examples for net.minecraft.init.Items.BOW

The following are Jave code examples for showing how to use BOW of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Backmemed   File: ModelSkeleton.java   View Source Code Vote up 6 votes
/**
 * Used for easily adding entity-dependent animations. The second and third float params here are the same second
 * and third as in the setRotationAngles method.
 */
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
{
    this.rightArmPose = ModelBiped.ArmPose.EMPTY;
    this.leftArmPose = ModelBiped.ArmPose.EMPTY;
    ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

    if (itemstack.getItem() == Items.BOW && ((AbstractSkeleton)entitylivingbaseIn).isSwingingArms())
    {
        if (entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT)
        {
            this.rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
        else
        {
            this.leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
    }

    super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
}
 
Example 2
Project: Backmemed   File: ModelSkeleton.java   View Source Code Vote up 6 votes
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
    ItemStack itemstack = ((EntityLivingBase)entityIn).getHeldItemMainhand();
    AbstractSkeleton abstractskeleton = (AbstractSkeleton)entityIn;

    if (abstractskeleton.isSwingingArms() && (itemstack.func_190926_b() || itemstack.getItem() != Items.BOW))
    {
        float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
        float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
        this.bipedRightArm.rotateAngleZ = 0.0F;
        this.bipedLeftArm.rotateAngleZ = 0.0F;
        this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
        this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
        this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
        this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
        this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
        this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
        this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
        this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
    }
}
 
Example 3
Project: CustomWorldGen   File: ModelSkeleton.java   View Source Code Vote up 6 votes
/**
 * Used for easily adding entity-dependent animations. The second and third float params here are the same second
 * and third as in the setRotationAngles method.
 */
public void setLivingAnimations(EntityLivingBase entitylivingbaseIn, float p_78086_2_, float p_78086_3_, float partialTickTime)
{
    this.rightArmPose = ModelBiped.ArmPose.EMPTY;
    this.leftArmPose = ModelBiped.ArmPose.EMPTY;
    ItemStack itemstack = entitylivingbaseIn.getHeldItem(EnumHand.MAIN_HAND);

    if (itemstack != null && itemstack.getItem() == Items.BOW && ((EntitySkeleton)entitylivingbaseIn).isSwingingArms())
    {
        if (entitylivingbaseIn.getPrimaryHand() == EnumHandSide.RIGHT)
        {
            this.rightArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
        else
        {
            this.leftArmPose = ModelBiped.ArmPose.BOW_AND_ARROW;
        }
    }

    super.setLivingAnimations(entitylivingbaseIn, p_78086_2_, p_78086_3_, partialTickTime);
}
 
Example 4
Project: CustomWorldGen   File: ModelSkeleton.java   View Source Code Vote up 6 votes
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
    ItemStack itemstack = ((EntityLivingBase)entityIn).getHeldItemMainhand();
    EntitySkeleton entityskeleton = (EntitySkeleton)entityIn;

    if (entityskeleton.isSwingingArms() && (itemstack == null || itemstack.getItem() != Items.BOW))
    {
        float f = MathHelper.sin(this.swingProgress * (float)Math.PI);
        float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float)Math.PI);
        this.bipedRightArm.rotateAngleZ = 0.0F;
        this.bipedLeftArm.rotateAngleZ = 0.0F;
        this.bipedRightArm.rotateAngleY = -(0.1F - f * 0.6F);
        this.bipedLeftArm.rotateAngleY = 0.1F - f * 0.6F;
        this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F);
        this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F);
        this.bipedRightArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
        this.bipedLeftArm.rotateAngleX -= f * 1.2F - f1 * 0.4F;
        this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
        this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
        this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
    }
}
 
Example 5
Project: customstuff4   File: FuelTests.java   View Source Code Vote up 5 votes
@Test
public void testBurnTimeWithNbt()
{
    Fuel fuel = gson.fromJson("{ \"item\": {\"item\" : \"minecraft:bow\", \"nbt\":\"{AInt:1}\" }, \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    ItemStack stack = new ItemStack(Items.BOW);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("AInt", 1);

    assertFalse(fuel.appliesToStack(new ItemStack(Items.BOW)));
    assertTrue(fuel.appliesToStack(stack));
}
 
Example 6
Project: customstuff4   File: FuelTests.java   View Source Code Vote up 5 votes
@Test
public void testBurnTimeWithWrongNbt()
{
    Fuel fuel = gson.fromJson("{ \"item\": {\"item\" : \"minecraft:bow\", \"nbt\":\"{AInt:1}\" }, \"burnTime\":1337 }", Fuel.class);
    fuel.init(InitPhase.PRE_INIT, new TestContentHelper("{}", TestContent.class));

    ItemStack stack = new ItemStack(Items.BOW);
    stack.setTagCompound(new NBTTagCompound());
    stack.getTagCompound().setInteger("AInt", 2);

    assertFalse(fuel.appliesToStack(stack));
}
 
Example 7
Project: Backmemed   File: AbstractSkeleton.java   View Source Code Vote up 5 votes
/**
 * sets this entity's combat AI.
 */
public void setCombatTask()
{
    if (this.world != null && !this.world.isRemote)
    {
        this.tasks.removeTask(this.aiAttackOnCollide);
        this.tasks.removeTask(this.aiArrowAttack);
        ItemStack itemstack = this.getHeldItemMainhand();

        if (itemstack.getItem() == Items.BOW)
        {
            int i = 20;

            if (this.world.getDifficulty() != EnumDifficulty.HARD)
            {
                i = 40;
            }

            this.aiArrowAttack.setAttackCooldown(i);
            this.tasks.addTask(4, this.aiArrowAttack);
        }
        else
        {
            this.tasks.addTask(4, this.aiAttackOnCollide);
        }
    }
}
 
Example 8
Project: Backmemed   File: AbstractClientPlayer.java   View Source Code Vote up 5 votes
public float getFovModifier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
    f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
    {
        f = 1.0F;
    }

    if (this.isHandActive() && this.getActiveItemStack().getItem() == Items.BOW)
    {
        int i = this.getItemInUseMaxCount();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 = f1 * f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return Reflector.ForgeHooksClient_getOffsetFOV.exists() ? Reflector.callFloat(Reflector.ForgeHooksClient_getOffsetFOV, new Object[] {this, Float.valueOf(f)}): f;
}
 
Example 9
Project: Backmemed   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
 * fuel
 */
public static int getItemBurnTime(ItemStack stack)
{
    if (stack.func_190926_b())
    {
        return 0;
    }
    else
    {
        Item item = stack.getItem();
        return item == Item.getItemFromBlock(Blocks.WOODEN_SLAB) ? 150 : (item == Item.getItemFromBlock(Blocks.WOOL) ? 100 : (item == Item.getItemFromBlock(Blocks.CARPET) ? 67 : (item == Item.getItemFromBlock(Blocks.LADDER) ? 300 : (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON) ? 100 : (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD ? 300 : (item == Item.getItemFromBlock(Blocks.COAL_BLOCK) ? 16000 : (item instanceof ItemTool && "WOOD".equals(((ItemTool)item).getToolMaterialName()) ? 200 : (item instanceof ItemSword && "WOOD".equals(((ItemSword)item).getToolMaterialName()) ? 200 : (item instanceof ItemHoe && "WOOD".equals(((ItemHoe)item).getMaterialName()) ? 200 : (item == Items.STICK ? 100 : (item != Items.BOW && item != Items.FISHING_ROD ? (item == Items.SIGN ? 200 : (item == Items.COAL ? 1600 : (item == Items.LAVA_BUCKET ? 20000 : (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL ? (item == Items.BLAZE_ROD ? 2400 : (item instanceof ItemDoor && item != Items.IRON_DOOR ? 200 : (item instanceof ItemBoat ? 400 : 0))) : 100)))) : 300)))))))))));
    }
}
 
Example 10
Project: CustomWorldGen   File: EntitySkeleton.java   View Source Code Vote up 5 votes
/**
 * sets this entity's combat AI.
 */
public void setCombatTask()
{
    if (this.worldObj != null && !this.worldObj.isRemote)
    {
        this.tasks.removeTask(this.aiAttackOnCollide);
        this.tasks.removeTask(this.aiArrowAttack);
        ItemStack itemstack = this.getHeldItemMainhand();

        if (itemstack != null && itemstack.getItem() == Items.BOW)
        {
            int i = 20;

            if (this.worldObj.getDifficulty() != EnumDifficulty.HARD)
            {
                i = 40;
            }

            this.aiArrowAttack.setAttackCooldown(i);
            this.tasks.addTask(4, this.aiArrowAttack);
        }
        else
        {
            this.tasks.addTask(4, this.aiAttackOnCollide);
        }
    }
}
 
Example 11
Project: CustomWorldGen   File: AbstractClientPlayer.java   View Source Code Vote up 5 votes
public float getFovModifier()
{
    float f = 1.0F;

    if (this.capabilities.isFlying)
    {
        f *= 1.1F;
    }

    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
    f = (float)((double)f * ((iattributeinstance.getAttributeValue() / (double)this.capabilities.getWalkSpeed() + 1.0D) / 2.0D));

    if (this.capabilities.getWalkSpeed() == 0.0F || Float.isNaN(f) || Float.isInfinite(f))
    {
        f = 1.0F;
    }

    if (this.isHandActive() && this.getActiveItemStack() != null && this.getActiveItemStack().getItem() == Items.BOW)
    {
        int i = this.getItemInUseMaxCount();
        float f1 = (float)i / 20.0F;

        if (f1 > 1.0F)
        {
            f1 = 1.0F;
        }
        else
        {
            f1 = f1 * f1;
        }

        f *= 1.0F - f1 * 0.15F;
    }

    return net.minecraftforge.client.ForgeHooksClient.getOffsetFOV(this, f);
}
 
Example 12
Project: Backmemed   File: EntityAIAttackRangedBow.java   View Source Code Vote up 4 votes
protected boolean isBowInMainhand()
{
    return !this.entity.getHeldItemMainhand().func_190926_b() && this.entity.getHeldItemMainhand().getItem() == Items.BOW;
}
 
Example 13
Project: Backmemed   File: LayerHeldItemWitch.java   View Source Code Vote up 4 votes
public void doRenderLayer(EntityWitch entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    ItemStack itemstack = entitylivingbaseIn.getHeldItemMainhand();

    if (!itemstack.func_190926_b())
    {
        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(0.5F, 0.5F, 0.5F);
        }

        this.witchRenderer.getMainModel().villagerNose.postRender(0.0625F);
        GlStateManager.translate(-0.0625F, 0.53125F, 0.21875F);
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();

        if (Block.getBlockFromItem(item).getDefaultState().getRenderType() == EnumBlockRenderType.ENTITYBLOCK_ANIMATED)
        {
            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 f1 = 0.375F;
            GlStateManager.scale(0.375F, -0.375F, 0.375F);
        }
        else if (item == Items.BOW)
        {
            GlStateManager.translate(0.0F, 0.125F, -0.125F);
            GlStateManager.rotate(-45.0F, 0.0F, 1.0F, 0.0F);
            float f2 = 0.625F;
            GlStateManager.scale(0.625F, -0.625F, 0.625F);
            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 f3 = 0.625F;
            GlStateManager.scale(0.625F, -0.625F, 0.625F);
            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 f4 = 0.875F;
            GlStateManager.scale(0.875F, 0.875F, 0.875F);
            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();
    }
}
 
Example 14
Project: Backmemed   File: ItemRenderer.java   View Source Code Vote up 4 votes
/**
 * Renders the active item in the player's hand when in first person mode.
 */
public void renderItemInFirstPerson(float partialTicks)
{
    AbstractClientPlayer abstractclientplayer = this.mc.player;
    float f = abstractclientplayer.getSwingProgress(partialTicks);
    EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
    float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
    float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
    boolean flag = true;
    boolean flag1 = true;

    if (abstractclientplayer.isHandActive())
    {
        ItemStack itemstack = abstractclientplayer.getActiveItemStack();

        if (itemstack != null && itemstack.getItem() == Items.BOW)
        {
            EnumHand enumhand1 = abstractclientplayer.getActiveHand();
            flag = enumhand1 == EnumHand.MAIN_HAND;
            flag1 = !flag;
        }
    }

    this.rotateArroundXAndY(f1, f2);
    this.setLightmap();
    this.rotateArm(partialTicks);
    GlStateManager.enableRescaleNormal();

    if (flag)
    {
        float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
        float f5 = 1.0F - (this.prevEquippedProgressMainHand + (this.equippedProgressMainHand - this.prevEquippedProgressMainHand) * partialTicks);

        if (!Reflector.ForgeHooksClient_renderSpecificFirstPersonHand.exists() || !Reflector.callBoolean(Reflector.ForgeHooksClient_renderSpecificFirstPersonHand, new Object[] {EnumHand.MAIN_HAND, Float.valueOf(partialTicks), Float.valueOf(f1), Float.valueOf(f3), Float.valueOf(f5), this.itemStackMainHand}))
        {
            this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, this.itemStackMainHand, f5);
        }
    }

    if (flag1)
    {
        float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
        float f6 = 1.0F - (this.prevEquippedProgressOffHand + (this.equippedProgressOffHand - this.prevEquippedProgressOffHand) * partialTicks);

        if (!Reflector.ForgeHooksClient_renderSpecificFirstPersonHand.exists() || !Reflector.callBoolean(Reflector.ForgeHooksClient_renderSpecificFirstPersonHand, new Object[] {EnumHand.OFF_HAND, Float.valueOf(partialTicks), Float.valueOf(f1), Float.valueOf(f4), Float.valueOf(f6), this.itemStackOffHand}))
        {
            this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, this.itemStackOffHand, f6);
        }
    }

    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}
 
Example 15
Project: CustomWorldGen   File: EntityAIAttackRangedBow.java   View Source Code Vote up 4 votes
protected boolean isBowInMainhand()
{
    return this.entity.getHeldItemMainhand() != null && this.entity.getHeldItemMainhand().getItem() == Items.BOW;
}
 
Example 16
Project: CustomWorldGen   File: LayerHeldItemWitch.java   View Source Code Vote up 4 votes
public void doRenderLayer(EntityWitch entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
    ItemStack itemstack = entitylivingbaseIn.getHeldItemMainhand();

    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(0.5F, 0.5F, 0.5F);
        }

        ((ModelWitch)this.witchRenderer.getMainModel()).villagerNose.postRender(0.0625F);
        GlStateManager.translate(-0.0625F, 0.53125F, 0.21875F);
        Item item = itemstack.getItem();
        Minecraft minecraft = Minecraft.getMinecraft();

        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(0.375F, -0.375F, 0.375F);
        }
        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(0.625F, -0.625F, 0.625F);
            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(0.625F, -0.625F, 0.625F);
            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(0.875F, 0.875F, 0.875F);
            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();
    }
}
 
Example 17
Project: CustomWorldGen   File: ItemRenderer.java   View Source Code Vote up 4 votes
/**
 * Renders the active item in the player's hand when in first person mode.
 */
public void renderItemInFirstPerson(float partialTicks)
{
    AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
    float f = abstractclientplayer.getSwingProgress(partialTicks);
    EnumHand enumhand = (EnumHand)Objects.firstNonNull(abstractclientplayer.swingingHand, EnumHand.MAIN_HAND);
    float f1 = abstractclientplayer.prevRotationPitch + (abstractclientplayer.rotationPitch - abstractclientplayer.prevRotationPitch) * partialTicks;
    float f2 = abstractclientplayer.prevRotationYaw + (abstractclientplayer.rotationYaw - abstractclientplayer.prevRotationYaw) * partialTicks;
    boolean flag = true;
    boolean flag1 = true;

    if (abstractclientplayer.isHandActive())
    {
        ItemStack itemstack = abstractclientplayer.getActiveItemStack();

        if (itemstack != null && itemstack.getItem() == Items.BOW) //Forge: Data watcher can desync and cause this to NPE...
        {
            EnumHand enumhand1 = abstractclientplayer.getActiveHand();
            flag = enumhand1 == EnumHand.MAIN_HAND;
            flag1 = !flag;
        }
    }

    this.rotateArroundXAndY(f1, f2);
    this.setLightmap();
    this.rotateArm(partialTicks);
    GlStateManager.enableRescaleNormal();

    if (flag)
    {
        float f3 = enumhand == EnumHand.MAIN_HAND ? f : 0.0F;
        float f5 = 1.0F - (this.prevEquippedProgressMainHand + (this.equippedProgressMainHand - this.prevEquippedProgressMainHand) * partialTicks);
        if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(EnumHand.MAIN_HAND, partialTicks, f1, f3, f5, this.itemStackMainHand))
        this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.MAIN_HAND, f3, this.itemStackMainHand, f5);
    }

    if (flag1)
    {
        float f4 = enumhand == EnumHand.OFF_HAND ? f : 0.0F;
        float f6 = 1.0F - (this.prevEquippedProgressOffHand + (this.equippedProgressOffHand - this.prevEquippedProgressOffHand) * partialTicks);
        if(!net.minecraftforge.client.ForgeHooksClient.renderSpecificFirstPersonHand(EnumHand.OFF_HAND, partialTicks, f1, f4, f6, this.itemStackOffHand))
        this.renderItemInFirstPerson(abstractclientplayer, partialTicks, f1, EnumHand.OFF_HAND, f4, this.itemStackOffHand, f6);
    }

    GlStateManager.disableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
}