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

The following are Jave code examples for showing how to use wrapAngleTo180_float() 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: EntityLiving.java   Source Code and License Vote up 6 votes
/**
 * Arguments: current rotation, intended rotation, max increment.
 */
private float updateRotation(float p_70663_1_, float p_70663_2_, float p_70663_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_70663_2_ - p_70663_1_);

    if (f > p_70663_3_)
    {
        f = p_70663_3_;
    }

    if (f < -p_70663_3_)
    {
        f = -p_70663_3_;
    }

    return p_70663_1_ + f;
}
 
Example 2
Project: BaseClient   File: EntityLiving.java   Source Code and License Vote up 6 votes
/**
 * Arguments: current rotation, intended rotation, max increment.
 */
private float updateRotation(float p_70663_1_, float p_70663_2_, float p_70663_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_70663_2_ - p_70663_1_);

    if (f > p_70663_3_)
    {
        f = p_70663_3_;
    }

    if (f < -p_70663_3_)
    {
        f = -p_70663_3_;
    }

    return p_70663_1_ + f;
}
 
Example 3
Project: BaseClient   File: EntityWither.java   Source Code and License Vote up 6 votes
private float func_82204_b(float p_82204_1_, float p_82204_2_, float p_82204_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_82204_2_ - p_82204_1_);

    if (f > p_82204_3_)
    {
        f = p_82204_3_;
    }

    if (f < -p_82204_3_)
    {
        f = -p_82204_3_;
    }

    return p_82204_1_ + f;
}
 
Example 4
Project: BaseClient   File: EntityLivingBase.java   Source Code and License Vote up 5 votes
protected float func_110146_f(float p_110146_1_, float p_110146_2_)
{
    float f = MathHelper.wrapAngleTo180_float(p_110146_1_ - this.renderYawOffset);
    this.renderYawOffset += f * 0.3F;
    float f1 = MathHelper.wrapAngleTo180_float(this.rotationYaw - this.renderYawOffset);
    boolean flag = f1 < -90.0F || f1 >= 90.0F;

    if (f1 < -75.0F)
    {
        f1 = -75.0F;
    }

    if (f1 >= 75.0F)
    {
        f1 = 75.0F;
    }

    this.renderYawOffset = this.rotationYaw - f1;

    if (f1 * f1 > 2500.0F)
    {
        this.renderYawOffset += f1 * 0.2F;
    }

    if (flag)
    {
        p_110146_2_ *= -1.0F;
    }

    return p_110146_2_;
}
 
Example 5
Project: BaseClient   File: EntityLookHelper.java   Source Code and License Vote up 5 votes
/**
 * Updates look
 */
public void onUpdateLook()
{
    this.entity.rotationPitch = 0.0F;

    if (this.isLooking)
    {
        this.isLooking = false;
        double d0 = this.posX - this.entity.posX;
        double d1 = this.posY - (this.entity.posY + (double)this.entity.getEyeHeight());
        double d2 = this.posZ - this.entity.posZ;
        double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
        float f = (float)(MathHelper.func_181159_b(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f1 = (float)(-(MathHelper.func_181159_b(d1, d3) * 180.0D / Math.PI));
        this.entity.rotationPitch = this.updateRotation(this.entity.rotationPitch, f1, this.deltaLookPitch);
        this.entity.rotationYawHead = this.updateRotation(this.entity.rotationYawHead, f, this.deltaLookYaw);
    }
    else
    {
        this.entity.rotationYawHead = this.updateRotation(this.entity.rotationYawHead, this.entity.renderYawOffset, 10.0F);
    }

    float f2 = MathHelper.wrapAngleTo180_float(this.entity.rotationYawHead - this.entity.renderYawOffset);

    if (!this.entity.getNavigator().noPath())
    {
        if (f2 < -75.0F)
        {
            this.entity.rotationYawHead = this.entity.renderYawOffset - 75.0F;
        }

        if (f2 > 75.0F)
        {
            this.entity.rotationYawHead = this.entity.renderYawOffset + 75.0F;
        }
    }
}
 
Example 6
Project: BaseClient   File: EntityMoveHelper.java   Source Code and License Vote up 5 votes
/**
 * Limits the given angle to a upper and lower limit.
 */
protected float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
{
    float f = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);

    if (f > p_75639_3_)
    {
        f = p_75639_3_;
    }

    if (f < -p_75639_3_)
    {
        f = -p_75639_3_;
    }

    float f1 = p_75639_1_ + f;

    if (f1 < 0.0F)
    {
        f1 += 360.0F;
    }
    else if (f1 > 360.0F)
    {
        f1 -= 360.0F;
    }

    return f1;
}
 
Example 7
Project: BaseClient   File: EntityBat.java   Source Code and License Vote up 4 votes
protected void updateAITasks()
{
    super.updateAITasks();
    BlockPos blockpos = new BlockPos(this);
    BlockPos blockpos1 = blockpos.up();

    if (this.getIsBatHanging())
    {
        if (!this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
        {
            this.setIsBatHanging(false);
            this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
        }
        else
        {
            if (this.rand.nextInt(200) == 0)
            {
                this.rotationYawHead = (float)this.rand.nextInt(360);
            }

            if (this.worldObj.getClosestPlayerToEntity(this, 4.0D) != null)
            {
                this.setIsBatHanging(false);
                this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
            }
        }
    }
    else
    {
        if (this.spawnPosition != null && (!this.worldObj.isAirBlock(this.spawnPosition) || this.spawnPosition.getY() < 1))
        {
            this.spawnPosition = null;
        }

        if (this.spawnPosition == null || this.rand.nextInt(30) == 0 || this.spawnPosition.distanceSq((double)((int)this.posX), (double)((int)this.posY), (double)((int)this.posZ)) < 4.0D)
        {
            this.spawnPosition = new BlockPos((int)this.posX + this.rand.nextInt(7) - this.rand.nextInt(7), (int)this.posY + this.rand.nextInt(6) - 2, (int)this.posZ + this.rand.nextInt(7) - this.rand.nextInt(7));
        }

        double d0 = (double)this.spawnPosition.getX() + 0.5D - this.posX;
        double d1 = (double)this.spawnPosition.getY() + 0.1D - this.posY;
        double d2 = (double)this.spawnPosition.getZ() + 0.5D - this.posZ;
        this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
        this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
        this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
        float f = (float)(MathHelper.func_181159_b(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
        float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
        this.moveForward = 0.5F;
        this.rotationYaw += f1;

        if (this.rand.nextInt(100) == 0 && this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
        {
            this.setIsBatHanging(true);
        }
    }
}
 
Example 8
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static float wrapDegrees(float p_wrapDegrees_0_)
{
    return MathHelper.wrapAngleTo180_float(p_wrapDegrees_0_);
}
 
Example 9
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static float wrapDegrees(float p_wrapDegrees_0_)
{
    return MathHelper.wrapAngleTo180_float(p_wrapDegrees_0_);
}