Skip to content

Commit

Permalink
add location with_x/y/z/yaw/pitch/world tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 25, 2019
1 parent 73d25fa commit ede51c6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ public String run(Attribute attribute, dObject object) {
return null;
}
try {
double x = aH.getDoubleFrom(attribute.getContext(1));
double x = attribute.getDoubleContext(1);
dCuboid cuboid = ((dCuboid) object).clone();
if (x < cuboid.pairs.get(0).low.getX()) {
cuboid.pairs.get(0).low = new dLocation(cuboid.pairs.get(0).low.getWorld(), x, cuboid.pairs.get(0).low.getY(), cuboid.pairs.get(0).low.getZ());
Expand Down Expand Up @@ -1201,7 +1201,7 @@ public String run(Attribute attribute, dObject object) {
return null;
}
try {
double y = aH.getDoubleFrom(attribute.getContext(1));
double y = attribute.getDoubleContext(1);
dCuboid cuboid = ((dCuboid) object).clone();
if (y < cuboid.pairs.get(0).low.getY()) {
cuboid.pairs.get(0).low = new dLocation(cuboid.pairs.get(0).low.getWorld(), cuboid.pairs.get(0).low.getX(), y, cuboid.pairs.get(0).low.getZ());
Expand Down Expand Up @@ -1232,7 +1232,7 @@ public String run(Attribute attribute, dObject object) {
return null;
}
try {
double z = aH.getDoubleFrom(attribute.getContext(1));
double z = attribute.getDoubleContext(1);
dCuboid cuboid = ((dCuboid) object).clone();
if (z < cuboid.pairs.get(0).low.getZ()) {
cuboid.pairs.get(0).low = new dLocation(cuboid.pairs.get(0).low.getWorld(), cuboid.pairs.get(0).low.getX(), cuboid.pairs.get(0).low.getY(), z);
Expand Down
73 changes: 73 additions & 0 deletions plugin/src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,79 @@ public int compare(dEntity ent1, dEntity ent2) {
return new Element(getZ()).getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_x[<number>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed X value.
// -->
if (attribute.matches("with_x") && attribute.hasContext(1)) {
dLocation output = clone();
output.setX(attribute.getDoubleContext(1));
return output.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_y[<number>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed Y value.
// -->
if (attribute.matches("with_y") && attribute.hasContext(1)) {
dLocation output = clone();
output.setY(attribute.getDoubleContext(1));
return output.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_z[<number>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed Z value.
// -->
if (attribute.matches("with_z") && attribute.hasContext(1)) {
dLocation output = clone();
output.setZ(attribute.getDoubleContext(1));
return output.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_yaw[<number>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed yaw value.
// -->
if (attribute.matches("with_yaw") && attribute.hasContext(1)) {
dLocation output = clone();
output.setYaw((float) attribute.getDoubleContext(1));
return output.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_pitch[<number>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed pitch value.
// -->
if (attribute.matches("with_pitch") && attribute.hasContext(1)) {
dLocation output = clone();
output.setPitch((float) attribute.getDoubleContext(1));
return output.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <l@location.with_world[<world>]>
// @returns dLocation
// @description
// Returns a copy of the location with a changed world value.
// -->
if (attribute.matches("with_world") && attribute.hasContext(1)) {
dLocation output = clone();
dWorld world = dWorld.valueOf(attribute.getContext(1));
output.setWorld(world.getWorld());
return output.getAttribute(attribute.fulfill(1));
}

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

0 comments on commit ede51c6

Please sign in to comment.