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

The following are Jave code examples for showing how to use wrapAngleTo180_double() 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: EntityDragon.java   Source Code and License Vote up 6 votes
/**
 * Returns a double[3] array with movement offsets, used to calculate trailing tail/neck positions. [0] = yaw
 * offset, [1] = y offset, [2] = unused, always 0. Parameters: buffer index offset, partial ticks.
 */
public double[] getMovementOffsets(int p_70974_1_, float p_70974_2_)
{
    if (this.getHealth() <= 0.0F)
    {
        p_70974_2_ = 0.0F;
    }

    p_70974_2_ = 1.0F - p_70974_2_;
    int i = this.ringBufferIndex - p_70974_1_ * 1 & 63;
    int j = this.ringBufferIndex - p_70974_1_ * 1 - 1 & 63;
    double[] adouble = new double[3];
    double d0 = this.ringBuffer[i][0];
    double d1 = MathHelper.wrapAngleTo180_double(this.ringBuffer[j][0] - d0);
    adouble[0] = d0 + d1 * (double)p_70974_2_;
    d0 = this.ringBuffer[i][1];
    d1 = this.ringBuffer[j][1] - d0;
    adouble[1] = d0 + d1 * (double)p_70974_2_;
    adouble[2] = this.ringBuffer[i][2] + (this.ringBuffer[j][2] - this.ringBuffer[i][2]) * (double)p_70974_2_;
    return adouble;
}
 
Example 2
Project: BaseClient   File: EntityDragon.java   Source Code and License Vote up 6 votes
/**
 * Returns a double[3] array with movement offsets, used to calculate trailing tail/neck positions. [0] = yaw
 * offset, [1] = y offset, [2] = unused, always 0. Parameters: buffer index offset, partial ticks.
 */
public double[] getMovementOffsets(int p_70974_1_, float p_70974_2_)
{
    if (this.getHealth() <= 0.0F)
    {
        p_70974_2_ = 0.0F;
    }

    p_70974_2_ = 1.0F - p_70974_2_;
    int i = this.ringBufferIndex - p_70974_1_ * 1 & 63;
    int j = this.ringBufferIndex - p_70974_1_ * 1 - 1 & 63;
    double[] adouble = new double[3];
    double d0 = this.ringBuffer[i][0];
    double d1 = MathHelper.wrapAngleTo180_double(this.ringBuffer[j][0] - d0);
    adouble[0] = d0 + d1 * (double)p_70974_2_;
    d0 = this.ringBuffer[i][1];
    d1 = this.ringBuffer[j][1] - d0;
    adouble[1] = d0 + d1 * (double)p_70974_2_;
    adouble[2] = this.ringBuffer[i][2] + (this.ringBuffer[j][2] - this.ringBuffer[i][2]) * (double)p_70974_2_;
    return adouble;
}
 
Example 3
Project: minecraft-quiverbow   File: AI_Targeting.java   Source Code and License Vote up 6 votes
public static void adjustAim(Entity_AA turret, boolean secondRail, double posX, double posY, double posZ)
{
	_WeaponBase currentWeapon = turret.firstWeapon;
	if (secondRail) { currentWeapon = turret.secondWeapon; }
	
	if (currentWeapon == null) { return; }	// Has no weapon, so no point in adjusting anything
	
	if (currentWeapon instanceof LightningRed) { }	// Laser
	else if (currentWeapon instanceof MediGun) { }
	else if (currentWeapon instanceof Sunray) { }
	else if (currentWeapon instanceof ERA) { }
	else if (currentWeapon instanceof Endernymous) { }
	else
	{
		double distance = getDistanceSqToTarget(turret, posX, posY, posZ);
		double angleMod = (0.045 * distance) / (currentWeapon.Speed * currentWeapon.Speed);	// 0.05
		
		if (currentWeapon instanceof FrostLancer) { angleMod /= 2; }		// Half gravity
		else if (currentWeapon instanceof EnderRifle) { angleMod /= 2; }	// Half gravity
		
		turret.rotationPitch -= MathHelper.wrapAngleTo180_double(angleMod);
	}
}
 
Example 4
Project: BaseClient   File: EntityDragon.java   Source Code and License Vote up 4 votes
/**
 * Simplifies the value of a number by adding/subtracting 180 to the point that the number is between -180 and 180.
 */
private float simplifyAngle(double p_70973_1_)
{
    return (float)MathHelper.wrapAngleTo180_double(p_70973_1_);
}
 
Example 5
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static double wrapDegrees(double p_wrapDegrees_0_)
{
    return MathHelper.wrapAngleTo180_double(p_wrapDegrees_0_);
}
 
Example 6
Project: BaseClient   File: EntityDragon.java   Source Code and License Vote up 4 votes
/**
 * Simplifies the value of a number by adding/subtracting 180 to the point that the number is between -180 and 180.
 */
private float simplifyAngle(double p_70973_1_)
{
    return (float)MathHelper.wrapAngleTo180_double(p_70973_1_);
}
 
Example 7
Project: BaseClient   File: RealmsMth.java   Source Code and License Vote up 4 votes
public static double wrapDegrees(double p_wrapDegrees_0_)
{
    return MathHelper.wrapAngleTo180_double(p_wrapDegrees_0_);
}