geforkt von Mirrors/Paper
#1406: Fix incorrect assumption of Fireball having constant speed
By: DerFrZocker <derrieple@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
4691102616
Commit
79d9816660
@ -6,6 +6,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class CraftFireball extends AbstractProjectile implements Fireball {
|
public class CraftFireball extends AbstractProjectile implements Fireball {
|
||||||
public CraftFireball(CraftServer server, EntityFireball entity) {
|
public CraftFireball(CraftServer server, EntityFireball entity) {
|
||||||
@ -49,7 +50,7 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector getDirection() {
|
public Vector getDirection() {
|
||||||
return new Vector(getHandle().xPower, getHandle().yPower, getHandle().zPower);
|
return getAcceleration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,23 +58,32 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
|||||||
Preconditions.checkArgument(direction != null, "Vector direction cannot be null");
|
Preconditions.checkArgument(direction != null, "Vector direction cannot be null");
|
||||||
if (direction.isZero()) {
|
if (direction.isZero()) {
|
||||||
setVelocity(direction);
|
setVelocity(direction);
|
||||||
|
setAcceleration(direction);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getHandle().assignPower(direction.getX(), direction.getY(), direction.getZ());
|
|
||||||
update(); // SPIGOT-6579
|
direction = direction.clone().normalize();
|
||||||
|
setVelocity(direction.clone().multiply(getVelocity().length()));
|
||||||
|
setAcceleration(direction.multiply(getAcceleration().length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setVelocity(Vector velocity) {
|
public void setAcceleration(@NotNull Vector acceleration) {
|
||||||
Preconditions.checkArgument(velocity != null, "Vector velocity cannot be null");
|
Preconditions.checkArgument(acceleration != null, "Vector acceleration cannot be null");
|
||||||
// SPIGOT-6993: Allow power to be higher / lower than the normalized direction enforced by #setDirection(Vector)
|
// SPIGOT-6993: EntityFireball#assignPower will normalize the given values
|
||||||
// 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
|
// Note: Because of MC-80142 the fireball will stutter on the client when setting the power to something other than 0 or the normalized vector * 0.1
|
||||||
getHandle().xPower = velocity.getX();
|
getHandle().xPower = acceleration.getX();
|
||||||
getHandle().yPower = velocity.getY();
|
getHandle().yPower = acceleration.getY();
|
||||||
getHandle().zPower = velocity.getZ();
|
getHandle().zPower = acceleration.getZ();
|
||||||
update(); // SPIGOT-6579
|
update(); // SPIGOT-6579
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Vector getAcceleration() {
|
||||||
|
return new Vector(getHandle().xPower, getHandle().yPower, getHandle().zPower);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityFireball getHandle() {
|
public EntityFireball getHandle() {
|
||||||
return (EntityFireball) entity;
|
return (EntityFireball) entity;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren