Skip to content

Commit

Permalink
add tags Location.rotate_yaw/pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 15, 2020
1 parent 5fcfce0 commit fbb40aa
Showing 1 changed file with 26 additions and 2 deletions.
Expand Up @@ -1671,6 +1671,30 @@ else if (object.getBlockTypeForTag(attribute) == Material.FLOWER_POT) {
}
});

// <--[tag]
// @attribute <LocationTag.rotate_yaw[<#.#>]>
// @returns LocationTag
// @description
// Returns the location with the yaw rotated the specified amount (eg 180 to face the location backwards).
// -->
registerTag("rotate_yaw", (attribute, object) -> {
LocationTag loc = LocationTag.valueOf(object.identify());
loc.setYaw(loc.getYaw() + (float) attribute.getDoubleContext(1));
return loc;
});

// <--[tag]
// @attribute <LocationTag.rotate_pitch[<#.#>]>
// @returns LocationTag
// @description
// Returns the location with the pitch rotated the specified amount. Note that this is capped to +/- 90.
// -->
registerTag("rotate_pitch", (attribute, object) -> {
LocationTag loc = LocationTag.valueOf(object.identify());
loc.setPitch(Math.max(-90, Math.min(90, loc.getPitch() + (float) attribute.getDoubleContext(1))));
return loc;
});

// <--[tag]
// @attribute <LocationTag.face[<location>]>
// @returns LocationTag
Expand Down Expand Up @@ -1699,7 +1723,7 @@ else if (object.getBlockTypeForTag(attribute) == Material.FLOWER_POT) {
int degrees = 45;
LocationTag facingLoc;
if (LocationTag.matches(attribute.getContext(1))) {
facingLoc = LocationTag.valueOf(attribute.getContext(1));
facingLoc = object.clone();
}
else if (EntityTag.matches(attribute.getContext(1))) {
facingLoc = EntityTag.valueOf(attribute.getContext(1)).getLocation();
Expand Down Expand Up @@ -1771,7 +1795,7 @@ else if (context.split(",").length == 2) {
pitch = Float.parseFloat(split[0]);
yaw = Float.parseFloat(split[1]);
}
LocationTag loc = LocationTag.valueOf(object.identify());
LocationTag loc = object.clone();
loc.setPitch(pitch);
loc.setYaw(yaw);
return loc;
Expand Down

0 comments on commit fbb40aa

Please sign in to comment.