Java 类org.bukkit.craftbukkit.TrigMath 实例源码

项目:Cauldron    文件:EntityLookHelper.java   
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);
        // CraftBukkit start - Math -> TrigMath
        float f = (float)(TrigMath.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
        float f1 = (float)(-(TrigMath.atan2(d1, d3) * 180.0D / Math.PI));
        // CraftBukkit end
        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;
        }
    }
}
项目:CraftBukkit    文件:EntitySquid.java   
public void e() {
    super.e();
    this.bq = this.bp;
    this.bs = this.br;
    this.bu = this.bt;
    this.bw = this.bv;
    this.bt += this.by;
    if (this.bt > 6.2831855F) {
        this.bt -= 6.2831855F;
        if (this.random.nextInt(10) == 0) {
            this.by = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
        }
    }

    if (this.M()) {
        float f;

        if (this.bt < 3.1415927F) {
            f = this.bt / 3.1415927F;
            this.bv = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F;
            if ((double) f > 0.75D) {
                this.bx = 1.0F;
                this.bz = 1.0F;
            } else {
                this.bz *= 0.8F;
            }
        } else {
            this.bv = 0.0F;
            this.bx *= 0.9F;
            this.bz *= 0.99F;
        }

        if (!this.world.isStatic) {
            this.motX = (double) (this.bA * this.bx);
            this.motY = (double) (this.bB * this.bx);
            this.motZ = (double) (this.bC * this.bx);
        }

        f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
        // CraftBukkit - Math -> TrigMath
        this.aM += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aM) * 0.1F;
        this.yaw = this.aM;
        this.br += 3.1415927F * this.bz * 1.5F;
        // CraftBukkit - Math -> TrigMath
        this.bp += (-((float) TrigMath.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.bp) * 0.1F;
    } else {
        this.bv = MathHelper.abs(MathHelper.sin(this.bt)) * 3.1415927F * 0.25F;
        if (!this.world.isStatic) {
            this.motX = 0.0D;
            this.motY -= 0.08D;
            this.motY *= 0.9800000190734863D;
            this.motZ = 0.0D;
        }

        this.bp = (float) ((double) this.bp + (double) (-90.0F - this.bp) * 0.02D);
    }
}
项目:Almura-Server    文件:EntitySquid.java   
public void c() {
    super.c();
    this.bq = this.bp;
    this.bs = this.br;
    this.bu = this.bt;
    this.bw = this.bv;
    this.bt += this.by;
    if (this.bt > 6.2831855F) {
        this.bt -= 6.2831855F;
        if (this.random.nextInt(10) == 0) {
            this.by = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
        }
    }

    if (this.H()) {
        float f;

        if (this.bt < 3.1415927F) {
            f = this.bt / 3.1415927F;
            this.bv = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F;
            if ((double) f > 0.75D) {
                this.bx = 1.0F;
                this.bz = 1.0F;
            } else {
                this.bz *= 0.8F;
            }
        } else {
            this.bv = 0.0F;
            this.bx *= 0.9F;
            this.bz *= 0.99F;
        }

        if (!this.world.isStatic) {
            this.motX = (double) (this.bA * this.bx);
            this.motY = (double) (this.bB * this.bx);
            this.motZ = (double) (this.bC * this.bx);
        }

        f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
        // CraftBukkit - Math -> TrigMath
        this.aN += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aN) * 0.1F;
        this.yaw = this.aN;
        this.br += 3.1415927F * this.bz * 1.5F;
        // CraftBukkit - Math -> TrigMath
        this.bp += (-((float) TrigMath.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.bp) * 0.1F;
    } else {
        this.bv = MathHelper.abs(MathHelper.sin(this.bt)) * 3.1415927F * 0.25F;
        if (!this.world.isStatic) {
            this.motX = 0.0D;
            this.motY -= 0.08D;
            this.motY *= 0.9800000190734863D;
            this.motZ = 0.0D;
        }

        this.bp = (float) ((double) this.bp + (double) (-90.0F - this.bp) * 0.02D);
    }
}
项目:Tweakkit-Server    文件:EntitySquid.java   
public void e() {
    super.e();
    this.bq = this.bp;
    this.bs = this.br;
    this.bu = this.bt;
    this.bw = this.bv;
    this.bt += this.by;
    if (this.bt > 6.2831855F) {
        this.bt -= 6.2831855F;
        if (this.random.nextInt(10) == 0) {
            this.by = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
        }
    }

    if (this.M()) {
        float f;

        if (this.bt < 3.1415927F) {
            f = this.bt / 3.1415927F;
            this.bv = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F;
            if ((double) f > 0.75D) {
                this.bx = 1.0F;
                this.bz = 1.0F;
            } else {
                this.bz *= 0.8F;
            }
        } else {
            this.bv = 0.0F;
            this.bx *= 0.9F;
            this.bz *= 0.99F;
        }

        if (!this.world.isStatic) {
            this.motX = (double) (this.bA * this.bx);
            this.motY = (double) (this.bB * this.bx);
            this.motZ = (double) (this.bC * this.bx);
        }

        f = MathHelper.sqrt(this.motX * this.motX + this.motZ * this.motZ);
        // CraftBukkit - Math -> TrigMath
        this.aM += (-((float) TrigMath.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.aM) * 0.1F;
        this.yaw = this.aM;
        this.br += 3.1415927F * this.bz * 1.5F;
        // CraftBukkit - Math -> TrigMath
        this.bp += (-((float) TrigMath.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.bp) * 0.1F;
    } else {
        this.bv = MathHelper.abs(MathHelper.sin(this.bt)) * 3.1415927F * 0.25F;
        if (!this.world.isStatic) {
            this.motX = 0.0D;
            this.motY -= 0.08D;
            this.motY *= 0.9800000190734863D;
            this.motZ = 0.0D;
        }

        this.bp = (float) ((double) this.bp + (double) (-90.0F - this.bp) * 0.02D);
    }
}
项目:Cauldron    文件:EntitySquid.java   
public void onLivingUpdate()
{
    super.onLivingUpdate();
    this.prevSquidPitch = this.squidPitch;
    this.prevSquidYaw = this.squidYaw;
    this.prevSquidRotation = this.squidRotation;
    this.lastTentacleAngle = this.tentacleAngle;
    this.squidRotation += this.rotationVelocity;

    if (this.squidRotation > ((float)Math.PI * 2F))
    {
        this.squidRotation -= ((float)Math.PI * 2F);

        if (this.rand.nextInt(10) == 0)
        {
            this.rotationVelocity = 1.0F / (this.rand.nextFloat() + 1.0F) * 0.2F;
        }
    }

    if (this.isInWater())
    {
        float f;

        if (this.squidRotation < (float)Math.PI)
        {
            f = this.squidRotation / (float)Math.PI;
            this.tentacleAngle = MathHelper.sin(f * f * (float)Math.PI) * (float)Math.PI * 0.25F;

            if ((double)f > 0.75D)
            {
                this.randomMotionSpeed = 1.0F;
                this.field_70871_bB = 1.0F;
            }
            else
            {
                this.field_70871_bB *= 0.8F;
            }
        }
        else
        {
            this.tentacleAngle = 0.0F;
            this.randomMotionSpeed *= 0.9F;
            this.field_70871_bB *= 0.99F;
        }

        if (!this.worldObj.isRemote)
        {
            this.motionX = (double)(this.randomMotionVecX * this.randomMotionSpeed);
            this.motionY = (double)(this.randomMotionVecY * this.randomMotionSpeed);
            this.motionZ = (double)(this.randomMotionVecZ * this.randomMotionSpeed);
        }

        f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
        // CraftBukkit - Math -> TrigMath
        this.renderYawOffset += (-((float) TrigMath.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
        this.rotationYaw = this.renderYawOffset;
        this.squidYaw += (float)Math.PI * this.field_70871_bB * 1.5F;
        // CraftBukkit - Math -> TrigMath
        this.squidPitch += (-((float) TrigMath.atan2((double) f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F;
    }
    else
    {
        this.tentacleAngle = MathHelper.abs(MathHelper.sin(this.squidRotation)) * (float)Math.PI * 0.25F;

        if (!this.worldObj.isRemote)
        {
            this.motionX = 0.0D;
            this.motionY -= 0.08D;
            this.motionY *= 0.9800000190734863D;
            this.motionZ = 0.0D;
        }

        this.squidPitch = (float)((double)this.squidPitch + (double)(-90.0F - this.squidPitch) * 0.02D);
    }
}