Java Code Examples for net.minecraft.util.MathHelper.cos()

The following are Jave code examples for showing how to use cos() of the net.minecraft.util.MathHelper class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BaseClient   File: ModelSnowMan.java   Source Code and License 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
    this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
    this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
    this.body.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI) * 0.25F;
    float f = MathHelper.sin(this.body.rotateAngleY);
    float f1 = MathHelper.cos(this.body.rotateAngleY);
    this.rightHand.rotateAngleZ = 1.0F;
    this.leftHand.rotateAngleZ = -1.0F;
    this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY;
    this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY;
    this.rightHand.rotationPointX = f1 * 5.0F;
    this.rightHand.rotationPointZ = -f * 5.0F;
    this.leftHand.rotationPointX = -f1 * 5.0F;
    this.leftHand.rotationPointZ = f * 5.0F;
}
 
Example 2
Project: BaseClient   File: WorldProvider.java   Source Code and License Vote up 6 votes
/**
 * Returns array with sunrise/sunset colors
 */
public float[] calcSunriseSunsetColors(float celestialAngle, float partialTicks)
{
    float f = 0.4F;
    float f1 = MathHelper.cos(celestialAngle * (float)Math.PI * 2.0F) - 0.0F;
    float f2 = -0.0F;

    if (f1 >= f2 - f && f1 <= f2 + f)
    {
        float f3 = (f1 - f2) / f * 0.5F + 0.5F;
        float f4 = 1.0F - (1.0F - MathHelper.sin(f3 * (float)Math.PI)) * 0.99F;
        f4 = f4 * f4;
        this.colorsSunriseSunset[0] = f3 * 0.3F + 0.7F;
        this.colorsSunriseSunset[1] = f3 * f3 * 0.7F + 0.2F;
        this.colorsSunriseSunset[2] = f3 * f3 * 0.0F + 0.2F;
        this.colorsSunriseSunset[3] = f4;
        return this.colorsSunriseSunset;
    }
    else
    {
        return null;
    }
}
 
Example 3
Project: BaseClient   File: ModelWitch.java   Source Code and License 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    super.setRotationAngles(p_78087_1_, p_78087_2_, p_78087_3_, p_78087_4_, p_78087_5_, p_78087_6_, entityIn);
    this.villagerNose.offsetX = this.villagerNose.offsetY = this.villagerNose.offsetZ = 0.0F;
    float f = 0.01F * (float)(entityIn.getEntityId() % 10);
    this.villagerNose.rotateAngleX = MathHelper.sin((float)entityIn.ticksExisted * f) * 4.5F * (float)Math.PI / 180.0F;
    this.villagerNose.rotateAngleY = 0.0F;
    this.villagerNose.rotateAngleZ = MathHelper.cos((float)entityIn.ticksExisted * f) * 2.5F * (float)Math.PI / 180.0F;

    if (this.field_82900_g)
    {
        this.villagerNose.rotateAngleX = -0.9F;
        this.villagerNose.offsetZ = -0.09375F;
        this.villagerNose.offsetY = 0.1875F;
    }
}
 
Example 4
Project: BaseClient   File: EntityFishHook.java   Source Code and License Vote up 6 votes
public EntityFishHook(World worldIn, EntityPlayer fishingPlayer)
{
    super(worldIn);
    this.xTile = -1;
    this.yTile = -1;
    this.zTile = -1;
    this.ignoreFrustumCheck = true;
    this.angler = fishingPlayer;
    this.angler.fishEntity = this;
    this.setSize(0.25F, 0.25F);
    this.setLocationAndAngles(fishingPlayer.posX, fishingPlayer.posY + (double)fishingPlayer.getEyeHeight(), fishingPlayer.posZ, fishingPlayer.rotationYaw, fishingPlayer.rotationPitch);
    this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    this.posY -= 0.10000000149011612D;
    this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
    this.setPosition(this.posX, this.posY, this.posZ);
    float f = 0.4F;
    this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
    this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
    this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f);
    this.handleHookCasting(this.motionX, this.motionY, this.motionZ, 1.5F, 1.0F);
}
 
Example 5
Project: BaseClient   File: ModelQuadruped.java   Source Code and License Vote up 5 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    float f = (180F / (float)Math.PI);
    this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
    this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
    this.body.rotateAngleX = ((float)Math.PI / 2F);
    this.leg1.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
    this.leg2.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
    this.leg3.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
    this.leg4.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
}
 
Example 6
Project: BaseClient   File: EntityWither.java   Source Code and License Vote up 5 votes
private double func_82214_u(int p_82214_1_)
{
    if (p_82214_1_ <= 0)
    {
        return this.posX;
    }
    else
    {
        float f = (this.renderYawOffset + (float)(180 * (p_82214_1_ - 1))) / 180.0F * (float)Math.PI;
        float f1 = MathHelper.cos(f);
        return this.posX + (double)f1 * 1.3D;
    }
}
 
Example 7
Project: BaseClient   File: EntityChicken.java   Source Code and License Vote up 5 votes
public void updateRiderPosition()
{
    super.updateRiderPosition();
    float f = MathHelper.sin(this.renderYawOffset * (float)Math.PI / 180.0F);
    float f1 = MathHelper.cos(this.renderYawOffset * (float)Math.PI / 180.0F);
    float f2 = 0.1F;
    float f3 = 0.0F;
    this.riddenByEntity.setPosition(this.posX + (double)(f2 * f), this.posY + (double)(this.height * 0.5F) + this.riddenByEntity.getYOffset() + (double)f3, this.posZ - (double)(f2 * f1));

    if (this.riddenByEntity instanceof EntityLivingBase)
    {
        ((EntityLivingBase)this.riddenByEntity).renderYawOffset = this.renderYawOffset;
    }
}
 
Example 8
Project: BaseClient   File: ModelQuadruped.java   Source Code and License Vote up 5 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 p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity entityIn)
{
    float f = (180F / (float)Math.PI);
    this.head.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
    this.head.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
    this.body.rotateAngleX = ((float)Math.PI / 2F);
    this.leg1.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
    this.leg2.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
    this.leg3.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
    this.leg4.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
}
 
Example 9
Project: minecraft-quiverbow   File: Helper.java   Source Code and License Vote up 5 votes
public static void knockUserBack(Entity user, byte strength)
{
	user.motionZ += -MathHelper.cos((user.rotationYaw) * (float)Math.PI / 180.0F) * (strength * 0.08F);
	user.motionX += MathHelper.sin((user.rotationYaw) * (float)Math.PI / 180.0F) * (strength * 0.08F);
	
	NetHelper.sendKickbackMessage(user, strength);	// Informing the client about this
}
 
Example 10
Project: BaseClient   File: TileEntityBannerRenderer.java   Source Code and License Vote up 4 votes
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage)
{
    boolean flag = te.getWorld() != null;
    boolean flag1 = !flag || te.getBlockType() == Blocks.standing_banner;
    int i = flag ? te.getBlockMetadata() : 0;
    long j = flag ? te.getWorld().getTotalWorldTime() : 0L;
    GlStateManager.pushMatrix();
    float f = 0.6666667F;

    if (flag1)
    {
        GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
        float f1 = (float)(i * 360) / 16.0F;
        GlStateManager.rotate(-f1, 0.0F, 1.0F, 0.0F);
        this.bannerModel.bannerStand.showModel = true;
    }
    else
    {
        float f2 = 0.0F;

        if (i == 2)
        {
            f2 = 180.0F;
        }

        if (i == 4)
        {
            f2 = 90.0F;
        }

        if (i == 5)
        {
            f2 = -90.0F;
        }

        GlStateManager.translate((float)x + 0.5F, (float)y - 0.25F * f, (float)z + 0.5F);
        GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(0.0F, -0.3125F, -0.4375F);
        this.bannerModel.bannerStand.showModel = false;
    }

    BlockPos blockpos = te.getPos();
    float f3 = (float)(blockpos.getX() * 7 + blockpos.getY() * 9 + blockpos.getZ() * 13) + (float)j + partialTicks;
    this.bannerModel.bannerSlate.rotateAngleX = (-0.0125F + 0.01F * MathHelper.cos(f3 * (float)Math.PI * 0.02F)) * (float)Math.PI;
    GlStateManager.enableRescaleNormal();
    ResourceLocation resourcelocation = this.func_178463_a(te);

    if (resourcelocation != null)
    {
        this.bindTexture(resourcelocation);
        GlStateManager.pushMatrix();
        GlStateManager.scale(f, -f, -f);
        this.bannerModel.renderBanner();
        GlStateManager.popMatrix();
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}
 
Example 11
Project: BaseClient   File: EntitySlime.java   Source Code and License Vote up 4 votes
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    if (!this.worldObj.isRemote && this.worldObj.getDifficulty() == EnumDifficulty.PEACEFUL && this.getSlimeSize() > 0)
    {
        this.isDead = true;
    }

    this.squishFactor += (this.squishAmount - this.squishFactor) * 0.5F;
    this.prevSquishFactor = this.squishFactor;
    super.onUpdate();

    if (this.onGround && !this.wasOnGround)
    {
        int i = this.getSlimeSize();

        for (int j = 0; j < i * 8; ++j)
        {
            float f = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            float f1 = this.rand.nextFloat() * 0.5F + 0.5F;
            float f2 = MathHelper.sin(f) * (float)i * 0.5F * f1;
            float f3 = MathHelper.cos(f) * (float)i * 0.5F * f1;
            World world = this.worldObj;
            EnumParticleTypes enumparticletypes = this.getParticleType();
            double d0 = this.posX + (double)f2;
            double d1 = this.posZ + (double)f3;
            world.spawnParticle(enumparticletypes, d0, this.getEntityBoundingBox().minY, d1, 0.0D, 0.0D, 0.0D, new int[0]);
        }

        if (this.makesSoundOnLand())
        {
            this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
        }

        this.squishAmount = -0.5F;
    }
    else if (!this.onGround && this.wasOnGround)
    {
        this.squishAmount = 1.0F;
    }

    this.wasOnGround = this.onGround;
    this.alterSquishAmount();
}