2021-02-07 03:37:25 +01:00
|
|
|
package net.knarcraft.stargate;
|
|
|
|
|
|
|
|
/**
|
2021-02-16 21:58:31 +01:00
|
|
|
* This stores a block location as a vector relative to a position
|
2021-02-12 00:26:47 +01:00
|
|
|
*
|
2021-02-16 21:58:31 +01:00
|
|
|
* <p>A relative block vector stores a vector relative to some origin. The origin in this plugin is usually the
|
|
|
|
* top-left block of a gate. The right is therefore the distance from the top-left corner towards the top-right corner.
|
|
|
|
* Depth is the distance from the top-left corner to the bottom-left corner. Distance is the distance outward from the
|
|
|
|
* gate.</p>
|
2021-02-07 03:37:25 +01:00
|
|
|
*/
|
|
|
|
public class RelativeBlockVector {
|
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
private int right;
|
|
|
|
private int depth;
|
|
|
|
private int distance;
|
2021-02-07 03:37:25 +01:00
|
|
|
|
2021-02-12 00:26:47 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new relative block vector
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
|
|
|
* @param right <p>The distance to the right relative to the origin</p>
|
|
|
|
* @param depth <p>The distance downward relative to the origin</p>
|
2021-02-16 21:58:31 +01:00
|
|
|
* @param distance <p>The distance outward relative to the origin</p>
|
2021-02-12 00:26:47 +01:00
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public RelativeBlockVector(int right, int depth, int distance) {
|
|
|
|
this.right = right;
|
|
|
|
this.depth = depth;
|
|
|
|
this.distance = distance;
|
|
|
|
}
|
|
|
|
|
2021-02-16 21:58:31 +01:00
|
|
|
/**
|
|
|
|
* Gets the distance to the right relative to the origin
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-16 21:58:31 +01:00
|
|
|
* @return The distance to the right relative to the origin
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public int getRight() {
|
|
|
|
return right;
|
|
|
|
}
|
|
|
|
|
2021-02-16 21:58:31 +01:00
|
|
|
/**
|
|
|
|
* Gets the distance downward relative to the origin
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-16 21:58:31 +01:00
|
|
|
* @return The distance downward relative to the origin
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public int getDepth() {
|
|
|
|
return depth;
|
|
|
|
}
|
|
|
|
|
2021-02-16 21:58:31 +01:00
|
|
|
/**
|
|
|
|
* Gets the distance outward relative to the origin
|
2021-02-20 13:57:04 +01:00
|
|
|
*
|
2021-02-16 21:58:31 +01:00
|
|
|
* @return The distance outward relative to the origin
|
|
|
|
*/
|
2021-02-07 03:37:25 +01:00
|
|
|
public int getDistance() {
|
|
|
|
return distance;
|
|
|
|
}
|
|
|
|
|
2021-02-22 15:49:44 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return String.format("right = %d, depth = %d, distance = %d", right, depth, distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
if (!(other instanceof RelativeBlockVector)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
RelativeBlockVector otherVector = (RelativeBlockVector) other;
|
|
|
|
return this.right == otherVector.right && this.depth == otherVector.depth &&
|
|
|
|
this.distance == otherVector.distance;
|
|
|
|
}
|
|
|
|
|
2021-02-07 03:37:25 +01:00
|
|
|
}
|