summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authort00thpick1 <t00thpick1dirko@gmail.com>2014-01-21 22:50:15 -0500
committerNate Mortensen <nate.richard.mortensen@gmail.com>2014-01-30 21:47:44 -0700
commitb4c4c8ed78393b85c0c149864cf387a5e2dc5eef (patch)
tree8a3f9badfd4b7e241ad92da0a6b13d4ba0e24f2c /src/main/java/org
parent1fa4b69bd81fa163b11fcd80d47edbf1967ea65c (diff)
downloadcraftbukkit-b4c4c8ed78393b85c0c149864cf387a5e2dc5eef.tar
craftbukkit-b4c4c8ed78393b85c0c149864cf387a5e2dc5eef.tar.gz
craftbukkit-b4c4c8ed78393b85c0c149864cf387a5e2dc5eef.tar.lz
craftbukkit-b4c4c8ed78393b85c0c149864cf387a5e2dc5eef.tar.xz
craftbukkit-b4c4c8ed78393b85c0c149864cf387a5e2dc5eef.zip
[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.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
index 3a987176..6f0b9423 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java
@@ -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