From 7aa4984347836b1dea887978cbb28c4b7222918d Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 4 May 2024 19:34:27 +1000 Subject: [PATCH] SPIGOT-6993: Allow #setVelocity to change the speed of a fireball and add a note to #setDirection about it By: DerFrZocker --- .../bukkit/craftbukkit/entity/CraftFireball.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index ed3857655e..9f212ebc46 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -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;