Java Code Examples for net.minecraft.util.MathHelper#sqrt_float()

The following examples show how to use net.minecraft.util.MathHelper#sqrt_float() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TickDynamic   File: Entity.java    License: MIT License 6 votes vote down vote up
/**
 * Used in both water and by flying objects
 */
public void moveFlying(float p_70060_1_, float p_70060_2_, float p_70060_3_)
{
    float f3 = p_70060_1_ * p_70060_1_ + p_70060_2_ * p_70060_2_;

    if (f3 >= 1.0E-4F)
    {
        f3 = MathHelper.sqrt_float(f3);

        if (f3 < 1.0F)
        {
            f3 = 1.0F;
        }

        f3 = p_70060_3_ / f3;
        p_70060_1_ *= f3;
        p_70060_2_ *= f3;
        float f4 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F);
        float f5 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F);
        this.motionX += (double)(p_70060_1_ * f5 - p_70060_2_ * f4);
        this.motionZ += (double)(p_70060_2_ * f5 + p_70060_1_ * f4);
    }
}
 
Example 2
public void rotateCorpse(T bat, float rotation, float partialTicks) {
    GlStateManager.rotate(180.0F - rotation, 0.0F, 1.0F, 0.0F);

    if (bat.deathTime > 0) {
        float f = ((float) bat.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
        f = MathHelper.sqrt_float(f);
        if (f > 1.0F) f = 1.0F;

        GlStateManager.rotate(f * ((IMixinRendererLivingEntity<T>) parent).callGetDeathMaxRotation(bat), 0.0F, 0.0F, 1.0F);
    } else {
        Hyperium.INSTANCE.getHandlers().getFlipHandler().transform(bat);
    }
}
 
Example 3
Source Project: TickDynamic   File: Entity.java    License: MIT License 5 votes vote down vote up
/**
 * Returns the distance to the entity. Args: entity
 */
public float getDistanceToEntity(Entity p_70032_1_)
{
    float f = (float)(this.posX - p_70032_1_.posX);
    float f1 = (float)(this.posY - p_70032_1_.posY);
    float f2 = (float)(this.posZ - p_70032_1_.posZ);
    return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
 
Example 4
protected void spinCroc(MoCEntityCrocodile croc, EntityLiving prey)
{
    int intSpin = croc.spinInt;

    int direction = 1;
    if (intSpin > 40)
    {
        intSpin -= 40;
        direction = -1;
    }
    int intEndSpin = intSpin;
    if (intSpin >= 20)
    {
        intEndSpin = (20 - (intSpin - 20));
    }
    if (intEndSpin == 0)
    {
        intEndSpin = 1;
    }
    float f3 = ((((float) intEndSpin) - 1.0F) / 20F) * 1.6F;
    f3 = MathHelper.sqrt_float(f3);
    if (f3 > 1.0F)
    {
        f3 = 1.0F;
    }
    f3 *= direction;
    GL11.glRotatef(f3 * 90F, 0.0F, 0.0F, 1.0F);

    if (prey != null)
    {
        prey.deathTime = intEndSpin;
    }
}