Added target block ray trace functionality.

By: Raphfrk <raphfrk@gmail.com>
This commit is contained in:
Bukkit/Spigot
2011-02-13 17:03:57 +00:00
parent 09916f398f
commit 5ba9ae942a
4 changed files with 455 additions and 2 deletions

View File

@@ -175,6 +175,26 @@ public class Location implements Cloneable {
return pitch;
}
/**
* Gets a Vector pointing in the direction that this Location is facing
*
* @return Vector
*/
public Vector getDirection() {
Vector vector = new Vector();
double rotX = this.getYaw();
double rotY = this.getPitch();
vector.setY(-Math.sin(Math.toRadians(rotY)));
double h = Math.cos(Math.toRadians(rotY));
vector.setX(-h*Math.sin(Math.toRadians(rotX)));
vector.setZ(h*Math.cos(Math.toRadians(rotX)));
return vector;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {