#1016: Fix incorrect assumption of Fireball having constant speed

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot 2024-05-29 06:56:40 +10:00
parent 932c4966ad
commit f9b0675bdd

View File

@ -10,26 +10,56 @@ public interface Fireball extends Projectile, Explosive {
/** /**
* Sets the direction the fireball should be flying towards. * Sets the direction the fireball should be flying towards.
* The direction vector will be normalized and the default speed will be applied.
* <br> * <br>
* To also change the speed of the fireball, use {@link #setVelocity(Vector)}. * This is a convenience method, it will change the velocity direction and
* <b>Note:</b> that the client may not respect non-default speeds and will therefore * acceleration direction, while keeping the power the same.
* mispredict the location of the fireball, causing visual stutter.
* <br> * <br>
* <b>Also Note:</b> that this method and {@link #setVelocity(Vector)} will override each other. * <b>Note:</b> This method only uses the direction of the vector and will
* normalize (a copy of) it.
* <br>
* <b>Special Case:</b> When the given direction is
* {@link Vector#isZero() zero}, the velocity and acceleration will also be
* set to zero without keeping the power.
* *
* @param direction the direction this fireball should be flying towards * @param direction the direction this fireball should be flying towards
* @see #setVelocity(Vector) * @see #setVelocity(Vector)
* @see #setAcceleration(Vector)
*/ */
public void setDirection(@NotNull Vector direction); public void setDirection(@NotNull Vector direction);
/** /**
* Retrieve the direction this fireball is heading toward * Retrieve the direction this fireball is heading toward.
* The returned vector is not normalized. * The returned vector is not normalized.
* *
* @return the direction * @return the direction
* @see #getAcceleration()
* @deprecated badly named method, returns the value of
* {@link #getAcceleration()}
*/ */
@NotNull @NotNull
@Deprecated(since = "1.20.6")
public Vector getDirection(); public Vector getDirection();
/**
* Sets the acceleration of the fireball.
*
* The acceleration gets applied to the velocity every tick, depending on
* the specific type of the fireball a damping / drag factor is applied so
* that the velocity does not grow into infinity.
* <br>
* <b>Note:</b> that the client may not respect non-default acceleration
* power and will therefore mispredict the location of the fireball, causing
* visual stutter.
*
* @param acceleration the acceleration
*/
void setAcceleration(@NotNull Vector acceleration);
/**
* Retrieve the acceleration of this fireball.
*
* @return the acceleration
*/
@NotNull
Vector getAcceleration();
} }