Skip to content

Commit

Permalink
Add points_between.distance
Browse files Browse the repository at this point in the history
Follow up to previous commit
  • Loading branch information
mcmonkey4eva committed Jan 21, 2016
1 parent 85f0446 commit 6780dcc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -755,17 +755,26 @@ else if (type == Material.TRAP_DOOR
if (target == null) {
return null;
}
attribute = attribute.fulfill(1);
// <--[tag]
// @attribute <l@location.points_between[<location>].distance[<#.#>]>
// @returns dList(dLocation)
// @description
// Finds all locations between this location and another, separated by the specified distance each.
// -->
double rad = 1d;
if (attribute.startsWith("distance")) {
rad = attribute.getIntContext(1);
attribute = attribute.fulfill(1);
}
dList list = new dList();
org.bukkit.util.Vector rel = this.toVector().subtract(target.toVector());
double len = rel.length();
rel = rel.multiply(1d / len);
for (int i = 0; i < len; i++) {
for (double i = 0d; i < len; i += rad) {
list.add(new dLocation(this.clone().add(rel.clone().multiply(i))).identify());
}
if (len > Math.floor(len)) {
list.add(target.identify());
}
return list.getAttribute(attribute.fulfill(1));
return list.getAttribute(attribute);
}

// <--[tag]
Expand Down

0 comments on commit 6780dcc

Please sign in to comment.