mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-12 18:31:41 +01:00
Pos improvements
This commit is contained in:
parent
ab9e16dfe7
commit
602472fc65
@ -1,8 +1,11 @@
|
||||
package net.minestom.server.utils.incubator;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Pos implements Vec {
|
||||
public static final Pos ZERO = new Pos();
|
||||
|
||||
private final double x, y, z;
|
||||
private final float yaw, pitch;
|
||||
|
||||
@ -14,6 +17,24 @@ public class Pos implements Vec {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public Pos(double x, double y, double z) {
|
||||
this(x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
public Pos() {
|
||||
this(0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull Pos withYaw(float yaw) {
|
||||
return new Pos(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull Pos withPitch(float pitch) {
|
||||
return new Pos(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pos with(double x, double y, double z) {
|
||||
return new Pos(x, y, z, pitch, yaw);
|
||||
@ -41,4 +62,9 @@ public class Pos implements Vec {
|
||||
public float pitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pos asPosition() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,11 @@ public interface Vec {
|
||||
return operator.apply(this);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
default @NotNull Pos asPosition() {
|
||||
return new Pos(x(), y(), z());
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
double x();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user