mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
#949: Add Vector#fromJOML() overloads for read-only vector types
This commit is contained in:
parent
f29cb80158
commit
5f027d2d1a
1 changed files with 36 additions and 0 deletions
|
@ -12,8 +12,11 @@ import org.bukkit.configuration.serialization.SerializableAs;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.RoundingMode;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3dc;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
import org.joml.Vector3i;
|
||||
import org.joml.Vector3ic;
|
||||
|
||||
/**
|
||||
* Represents a mutable vector. Because the components of Vectors are mutable,
|
||||
|
@ -948,6 +951,39 @@ public class Vector implements Cloneable, ConfigurationSerializable {
|
|||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3fc}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3fc vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3dc}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3dc vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a vector with components that match the provided JOML {@link Vector3ic}.
|
||||
*
|
||||
* @param vector the vector to match
|
||||
* @return the new vector
|
||||
*/
|
||||
@NotNull
|
||||
public static Vector fromJOML(@NotNull Vector3ic vector) {
|
||||
return new Vector(vector.x(), vector.y(), vector.z());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, Object> serialize() {
|
||||
|
|
Loading…
Add table
Reference in a new issue