Skip to content

Commit

Permalink
Add location.direction.vector
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Aug 27, 2013
1 parent 4bae903 commit aa9d9e3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,21 @@ public int compare(dEntity ent1, dEntity ent2) {
if (attribute.startsWith("block.material"))
return new Element(getBlock().getType().toString()).getAttribute(attribute.fulfill(2));



// <--[tag]
// @attribute <l@location.direction.vector>
// @returns dLocation
// @description
// Returns the location's direction as a one-length vector.
// -->
if (attribute.startsWith("direction.vector")) {
double xzLen = Math.cos((getPitch() % 360) * (Math.PI/180));
double nx = xzLen * Math.cos(getYaw() * (Math.PI/180));
double ny = Math.sin(getPitch() * (Math.PI/180));
double nz = xzLen * Math.sin(-getYaw() * (Math.PI/180));
return new dLocation(getWorld(), -nx, -ny, nz).getAttribute(attribute.fulfill(2));
}

// <--[tag]
// @attribute <l@location.direction>
// @returns Element
Expand Down

0 comments on commit aa9d9e3

Please sign in to comment.