mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-02 17:32:03 +01:00
SPIGOT-6993: Allow #setVelocity to change the speed of a fireball and add a note to #setDirection about it
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
4951fa2dd1
commit
7aa4984347
1 changed files with 15 additions and 0 deletions
|
@ -55,10 +55,25 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||
@Override
|
||||
public void setDirection(Vector direction) {
|
||||
Preconditions.checkArgument(direction != null, "Vector direction cannot be null");
|
||||
if (direction.isZero()) {
|
||||
setVelocity(direction);
|
||||
return;
|
||||
}
|
||||
getHandle().assignPower(direction.getX(), direction.getY(), direction.getZ());
|
||||
update(); // SPIGOT-6579
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector velocity) {
|
||||
Preconditions.checkArgument(velocity != null, "Vector velocity cannot be null");
|
||||
// SPIGOT-6993: Allow power to be higher / lower than the normalized direction enforced by #setDirection(Vector)
|
||||
// Note: Because of MC-80142 the fireball will stutter on the client when setting the velocity to something other than 0 or the normalized vector * 0.1
|
||||
getHandle().xPower = velocity.getX();
|
||||
getHandle().yPower = velocity.getY();
|
||||
getHandle().zPower = velocity.getZ();
|
||||
update(); // SPIGOT-6579
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityFireball getHandle() {
|
||||
return (EntityFireball) entity;
|
||||
|
|
Loading…
Reference in a new issue