Gets rid of the rest of the modX and modY usages, and removes some unused code
This commit is contained in:
@ -8,9 +8,9 @@ import org.bukkit.Material;
|
||||
*/
|
||||
public class BlockChangeRequest {
|
||||
|
||||
private BlockLocation blockLocation;
|
||||
private Material newMaterial;
|
||||
private Axis newAxis;
|
||||
private final BlockLocation blockLocation;
|
||||
private final Material newMaterial;
|
||||
private final Axis newAxis;
|
||||
|
||||
/**
|
||||
* Instantiates a new block change request
|
||||
@ -34,15 +34,6 @@ public class BlockChangeRequest {
|
||||
return blockLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location of the block
|
||||
*
|
||||
* @param blockLocation <p>The new location of the block</p>
|
||||
*/
|
||||
public void setBlockLocation(BlockLocation blockLocation) {
|
||||
this.blockLocation = blockLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the material to change the block into
|
||||
*
|
||||
@ -52,15 +43,6 @@ public class BlockChangeRequest {
|
||||
return newMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the material to change the block into
|
||||
*
|
||||
* @param material <p>The new material</p>
|
||||
*/
|
||||
public void setMaterial(Material material) {
|
||||
newMaterial = material;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the axis to orient the block along
|
||||
*
|
||||
@ -70,13 +52,4 @@ public class BlockChangeRequest {
|
||||
return newAxis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the axis to orient the block along
|
||||
*
|
||||
* @param axis <p>The new axis to orient the block along</p>
|
||||
*/
|
||||
public void setAxis(Axis axis) {
|
||||
newAxis = axis;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,73 +62,53 @@ public class BlockLocation extends Location {
|
||||
* @param z <p>The z position relative to this block's position</p>
|
||||
* @return <p>A new block location</p>
|
||||
*/
|
||||
public BlockLocation makeRelative(int x, int y, int z) {
|
||||
public BlockLocation makeRelativeBlockLocation(int x, int y, int z) {
|
||||
return (BlockLocation) this.clone().add(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a location relative to the block location
|
||||
*
|
||||
* @param x <p>The x position relative to this block's position</p>
|
||||
* @param y <p>The y position relative to this block's position</p>
|
||||
* @param z <p>The z position relative to this block's position</p>
|
||||
* @param yaw <p>The yaw of the location</p>
|
||||
* @param rotY <p>The y rotation of the location</p>
|
||||
* @param x <p>The x position relative to this block's position</p>
|
||||
* @param y <p>The y position relative to this block's position</p>
|
||||
* @param z <p>The z position relative to this block's position</p>
|
||||
* @param yaw <p>The yaw of the location</p>
|
||||
* @return <p>A new location</p>
|
||||
*/
|
||||
public Location makeRelativeLoc(double x, double y, double z, float yaw, float rotY) {
|
||||
public Location makeRelativeLocation(double x, double y, double z, float yaw) {
|
||||
Location newLocation = this.clone();
|
||||
newLocation.setYaw(yaw);
|
||||
newLocation.setPitch(rotY);
|
||||
newLocation.setPitch(0);
|
||||
return newLocation.add(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a location relative to this block location
|
||||
*
|
||||
* @param vector <p>The relative block vector describing the relative location</p>
|
||||
* @param yaw <p>The yaw pointing in the distance direction</p>
|
||||
* @param relativeVector <p>The relative block vector describing the relative location</p>
|
||||
* @param yaw <p>The yaw pointing in the distance direction</p>
|
||||
* @return <p>A location relative to this location</p>
|
||||
*/
|
||||
public BlockLocation getRelativeLocation(RelativeBlockVector vector, double yaw) {
|
||||
Vector combined = DirectionHelper.getCoordinateVectorFromRelativeVector(vector.getRight(), vector.getDepth(),
|
||||
vector.getDistance(), yaw);
|
||||
return makeRelative(combined.getBlockX(), combined.getBlockY(), combined.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a block location relative to the current origin according to given parameters
|
||||
*
|
||||
* <p>See {@link RelativeBlockVector} to understand better. modX or modZ should always be 0 while the other is 1
|
||||
* or -1.</p>
|
||||
*
|
||||
* @param right <p>The amount of right steps from the top-left origin</p>
|
||||
* @param depth <p>The amount of downward steps from the top-left origin</p>
|
||||
* @param distance <p>The distance outward from the top-left origin</p>
|
||||
* @param modX <p>X modifier. If modX = -1, X will increase as right increases</p>
|
||||
* @param modY <p>Y modifier. modY = 1 for Y decreasing as depth increases</p>
|
||||
* @param modZ <p>Z modifier. If modZ = 1, X will increase as distance increases</p>
|
||||
* @return A new location relative to this block location
|
||||
*/
|
||||
public BlockLocation modRelative(int right, int depth, int distance, int modX, int modY, int modZ) {
|
||||
return makeRelative(-right * modX + distance * modZ, -depth * modY, -right * modZ + -distance * modX);
|
||||
public BlockLocation getRelativeLocation(RelativeBlockVector relativeVector, double yaw) {
|
||||
Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(relativeVector.getRight(),
|
||||
relativeVector.getDepth(), relativeVector.getDistance(), yaw);
|
||||
return makeRelativeBlockLocation(realVector.getBlockX(), realVector.getBlockY(), realVector.getBlockZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a location relative to the current location according to given parameters
|
||||
*
|
||||
* @param right <p></p>
|
||||
* @param depth <p>The y position relative to the current position</p>
|
||||
* @param distance <p>The distance away from the previous location to the new location</p>
|
||||
* @param yaw <p>The yaw of the location</p>
|
||||
* @param rotY <p>Unused</p>
|
||||
* @param modX <p>x modifier. Defines movement along the x-axis. 0 for no movement</p>
|
||||
* @param modY <p>Unused</p>
|
||||
* @param modZ <p>z modifier. Defines movement along the z-axis. 0 for no movement</p>
|
||||
* @param right <p>The amount of blocks to go right when looking the opposite direction from the yaw</p>
|
||||
* @param depth <p>The amount of blocks to go downwards when looking the opposite direction from the yaw</p>
|
||||
* @param distance <p>The amount of blocks to go outwards when looking the opposite direction from the yaw</p>
|
||||
* @param portalYaw <p>The yaw when looking out from the portal</p>
|
||||
* @param yaw <p>The yaw of the travelling entity</p>
|
||||
* @return A new location relative to this block location
|
||||
*/
|
||||
public Location modRelativeLoc(double right, double depth, double distance, float yaw, float rotY, int modX, int modY, int modZ) {
|
||||
return makeRelativeLoc(0.5 + -right * modX + distance * modZ, depth, 0.5 + -right * modZ + -distance * modX, yaw, 0);
|
||||
public Location getRelativeLocation(double right, double depth, double distance, float portalYaw, float yaw) {
|
||||
Vector realVector = DirectionHelper.getCoordinateVectorFromRelativeVector(right, depth, distance, portalYaw);
|
||||
return makeRelativeLocation(0.5 + realVector.getBlockX(), realVector.getBlockY(),
|
||||
0.5 + realVector.getBlockZ(), yaw);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,7 +173,7 @@ public class BlockLocation extends Location {
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
parent = this.makeRelative(offsetX, offsetY, offsetZ);
|
||||
parent = this.makeRelativeBlockLocation(offsetX, offsetY, offsetZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user