mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-26 19:18:12 +01:00
Add Vector & BlockPosition copyCoordinates
This commit is contained in:
parent
ddf8cc383d
commit
d6c0a24bed
@ -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}.
|
||||
*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user