Gets rid of the rest of the modX and modY usages, and removes some unused code

This commit is contained in:
2021-10-08 18:23:42 +02:00
parent a68dc4b464
commit fff4d8d78b
20 changed files with 150 additions and 279 deletions

View File

@ -14,6 +14,8 @@ public class RelativeBlockVector {
private final int depth;
private final int distance;
public enum Property {RIGHT, DEPTH, DISTANCE}
/**
* Instantiates a new relative block vector
*
@ -27,6 +29,35 @@ public class RelativeBlockVector {
this.distance = distance;
}
/**
* Adds a value to one of the properties of this relative block vector
*
* @param propertyToAddTo <p>The property to change</p>
* @param valueToAdd <p>The value to add to the property</p>
* @return <p>A new relative block vector with the property altered</p>
*/
public RelativeBlockVector addToVector(Property propertyToAddTo, int valueToAdd) {
switch (propertyToAddTo) {
case RIGHT:
return new RelativeBlockVector(this.right + valueToAdd, this.depth, this.distance);
case DEPTH:
return new RelativeBlockVector(this.right, this.depth + valueToAdd, this.distance);
case DISTANCE:
return new RelativeBlockVector(this.right, this.depth, this.distance + valueToAdd);
default:
throw new IllegalArgumentException("Invalid relative block vector property given");
}
}
/**
* Gets a relative block vector which is this inverted (pointing in the opposite direction)
*
* @return <p>This vector, but inverted</p>
*/
public RelativeBlockVector invert() {
return new RelativeBlockVector(-this.right, -this.depth, -this.distance);
}
/**
* Gets the distance to the right relative to the origin
*