Skip to content

Commit

Permalink
add tag cuboid.shift
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 3, 2020
1 parent ea6132b commit 671438f
Showing 1 changed file with 27 additions and 0 deletions.
Expand Up @@ -1174,6 +1174,25 @@ public static void registerTags() {
}
});

// <--[tag]
// @attribute <CuboidTag.shift[<vector>]>
// @returns CuboidTag
// @description
// Returns a copy of this cuboid, with the first member shifted by the given vector LocationTag.
// For example, a cuboid from 5,5,5 to 10,10,10, shifted 100,0,100, would return a cuboid from 105,5,105 to 110,10,110.
// -->
registerTag("shift", (attribute, cuboid) -> {
if (!attribute.hasContext(1)) {
attribute.echoError("The tag CuboidTag.shift[...] must have a value.");
return null;
}
LocationTag vector = attribute.contextAsType(1, LocationTag.class);
if (vector != null) {
return cuboid.shifted(vector);
}
return null;
});

// <--[tag]
// @attribute <CuboidTag.include[<location>/<cuboid>]>
// @returns CuboidTag
Expand Down Expand Up @@ -1505,6 +1524,14 @@ public static void registerTags() {
});
}

public CuboidTag shifted(LocationTag vec) {
CuboidTag cuboid = clone();
LocationTag low = cuboid.pairs.get(0).low.clone().add(vec);
LocationTag high = cuboid.pairs.get(0).high.clone().add(vec);
cuboid.pairs.get(0).regenerate(low, high);
return cuboid;
}

public CuboidTag including(Location loc) {
loc = loc.clone();
CuboidTag cuboid = clone();
Expand Down

0 comments on commit 671438f

Please sign in to comment.