mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
BlockPosition comments
This commit is contained in:
parent
134173d0f1
commit
4d05bb8155
@ -25,6 +25,14 @@ public class BlockPosition {
|
|||||||
this(position.getX(), position.getY(), position.getZ());
|
this(position.getX(), position.getY(), position.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add offsets to this block position
|
||||||
|
*
|
||||||
|
* @param x the X offset
|
||||||
|
* @param y the Y offset
|
||||||
|
* @param z the Z offset
|
||||||
|
* @return the instance of this block position
|
||||||
|
*/
|
||||||
public BlockPosition add(int x, int y, int z) {
|
public BlockPosition add(int x, int y, int z) {
|
||||||
this.x += x;
|
this.x += x;
|
||||||
this.y += y;
|
this.y += y;
|
||||||
@ -32,6 +40,14 @@ public class BlockPosition {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtract offsets to this block position
|
||||||
|
*
|
||||||
|
* @param x the X offset
|
||||||
|
* @param y the Y offset
|
||||||
|
* @param z the Z offset
|
||||||
|
* @return the instance of this block position
|
||||||
|
*/
|
||||||
public BlockPosition subtract(int x, int y, int z) {
|
public BlockPosition subtract(int x, int y, int z) {
|
||||||
this.x -= x;
|
this.x -= x;
|
||||||
this.y -= y;
|
this.y -= y;
|
||||||
@ -39,40 +55,92 @@ public class BlockPosition {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block X
|
||||||
|
*
|
||||||
|
* @return the block X
|
||||||
|
*/
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the X field
|
||||||
|
* <p>
|
||||||
|
* WARNING: this will not change the block position
|
||||||
|
*
|
||||||
|
* @param x the new X field
|
||||||
|
*/
|
||||||
public void setX(int x) {
|
public void setX(int x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block Y
|
||||||
|
*
|
||||||
|
* @return the block Y
|
||||||
|
*/
|
||||||
public int getY() {
|
public int getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the Y field
|
||||||
|
* <p>
|
||||||
|
* WARNING: this will not change the block position
|
||||||
|
*
|
||||||
|
* @param y the new Y field
|
||||||
|
*/
|
||||||
public void setY(int y) {
|
public void setY(int y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block Z
|
||||||
|
*
|
||||||
|
* @return the block Z
|
||||||
|
*/
|
||||||
public int getZ() {
|
public int getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the Z field
|
||||||
|
* <p>
|
||||||
|
* WARNING: this will not change the block position
|
||||||
|
*
|
||||||
|
* @param z the new Z field
|
||||||
|
*/
|
||||||
public void setZ(int z) {
|
public void setZ(int z) {
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the distance to another block position
|
||||||
|
*
|
||||||
|
* @param blockPosition the block position to check the distance
|
||||||
|
* @return the distance between 'this' and {@code blockPosition}
|
||||||
|
*/
|
||||||
public int getDistance(BlockPosition blockPosition) {
|
public int getDistance(BlockPosition blockPosition) {
|
||||||
return Math.abs(getX() - blockPosition.getX()) +
|
return Math.abs(getX() - blockPosition.getX()) +
|
||||||
Math.abs(getY() - blockPosition.getY()) +
|
Math.abs(getY() - blockPosition.getY()) +
|
||||||
Math.abs(getZ() - blockPosition.getZ());
|
Math.abs(getZ() - blockPosition.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clone this block position
|
||||||
|
*
|
||||||
|
* @return the cloned block position
|
||||||
|
*/
|
||||||
public BlockPosition clone() {
|
public BlockPosition clone() {
|
||||||
return new BlockPosition(x, y, z);
|
return new BlockPosition(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert this block position to a {@link Position}
|
||||||
|
*
|
||||||
|
* @return the converted {@link Position}
|
||||||
|
*/
|
||||||
public Position toPosition() {
|
public Position toPosition() {
|
||||||
return new Position(x, y, z);
|
return new Position(x, y, z);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user