mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 18:27:41 +01:00
[Bleeding] Directly set direction in EntityFireball. Fixes BUKKIT-1154
Because EntityFireball.setDirection() adds a random offset to passed parameters, it is not appropriate for use in an API method. As such, the values need to be directly set to remain accurate. By: t00thpick1 <t00thpick1dirko@gmail.com>
This commit is contained in:
parent
9b8c0edb02
commit
7179c931c0
@ -1,8 +1,9 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFireball;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.MathHelper;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fireball;
|
||||
@ -49,7 +50,14 @@ public class CraftFireball extends AbstractProjectile implements Fireball {
|
||||
}
|
||||
|
||||
public void setDirection(Vector direction) {
|
||||
getHandle().setDirection(direction.getX(), direction.getY(), direction.getZ());
|
||||
Validate.notNull(direction, "Direction can not be null");
|
||||
double x = direction.getX();
|
||||
double y = direction.getY();
|
||||
double z = direction.getZ();
|
||||
double magnitude = (double) MathHelper.sqrt(x * x + y * y + z * z);
|
||||
getHandle().dirX = x / magnitude;
|
||||
getHandle().dirY = y / magnitude;
|
||||
getHandle().dirZ = z / magnitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user