Skip to content

Commit

Permalink
Add a points_between tag to location
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 21, 2016
1 parent 7aa8bec commit 85f0446
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -744,6 +744,30 @@ else if (type == Material.TRAP_DOOR
}
}

// <--[tag]
// @attribute <l@location.points_between[<location>]>
// @returns dList(dLocation)
// @description
// Finds all locations between this location and another, separated by 1 block-width each.
// -->
if (attribute.startsWith("points_between")) {
dLocation target = dLocation.valueOf(attribute.getContext(1));
if (target == null) {
return null;
}
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++) {
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));
}

// <--[tag]
// @attribute <l@location.facing_blocks[<#>]>
// @returns dList(dLocation)
Expand Down

0 comments on commit 85f0446

Please sign in to comment.