#949: Add Vector#fromJOML() overloads for read-only vector types

This commit is contained in:
Parker Hawke 2023-12-19 19:11:12 +11:00 committed by md_5
parent f29cb80158
commit 5f027d2d1a
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11

View file

@ -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() {