Add Vector & BlockPosition copyCoordinates

This commit is contained in:
KrystilizeNevaDies 2020-12-04 15:17:25 +10:00
parent ddf8cc383d
commit d6c0a24bed
2 changed files with 24 additions and 0 deletions

View File

@ -219,6 +219,17 @@ public class BlockPosition {
return new BlockPosition(x, y, z);
}
/**
* Sets the x/y/z fields of this block position to the value of {@code block position}.
*
* @param blockPosition the block position to copy the values from
*/
public void copyCoordinates(@NotNull BlockPosition blockPosition) {
this.x = blockPosition.getX();
this.y = blockPosition.getY();
this.z = blockPosition.getZ();
}
/**
* Converts this block position to a {@link Position}.
*

View File

@ -1,5 +1,7 @@
package net.minestom.server.utils;
import org.jetbrains.annotations.NotNull;
public class Vector {
private static final double epsilon = 0.000001;
@ -91,6 +93,17 @@ public class Vector {
return this;
}
/**
* Sets the x/y/z fields of this vector to the value of {@code vector}.
*
* @param vector the vector to copy the values from
*/
public void copyCoordinates(@NotNull Vector vector) {
this.x = vector.getX();
this.y = vector.getY();
this.z = vector.getZ();
}
/**
* Gets the magnitude of the vector, defined as sqrt(x^2+y^2+z^2). The
* value of this method is not cached and uses a costly square-root