mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Deprecate previous coordinate classes
This commit is contained in:
parent
4414baf89b
commit
da4acf7966
@ -1,8 +1,7 @@
|
||||
package net.minestom.server.utils;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.utils.clone.PublicCloneable;
|
||||
import net.minestom.server.utils.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -11,8 +10,11 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Represents the position of a block, so with integers instead of floating numbers.
|
||||
*
|
||||
* @deprecated use {@link net.minestom.server.utils.coordinate.Vec} instead
|
||||
*/
|
||||
public class BlockPosition implements PublicCloneable<BlockPosition> {
|
||||
@Deprecated
|
||||
public class BlockPosition implements Point {
|
||||
|
||||
private int x, y, z;
|
||||
|
||||
@ -212,15 +214,24 @@ public class BlockPosition implements PublicCloneable<BlockPosition> {
|
||||
MathUtils.square(getZ() - blockPosition.getZ());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public BlockPosition clone() {
|
||||
try {
|
||||
return (BlockPosition) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
return null;
|
||||
}
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Point clone() {
|
||||
return new BlockPosition(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,7 @@
|
||||
package net.minestom.server.utils;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.utils.clone.PublicCloneable;
|
||||
import net.minestom.server.utils.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -10,8 +9,11 @@ import java.util.Objects;
|
||||
/**
|
||||
* Represents a position.
|
||||
* The instance is not contained.
|
||||
*
|
||||
* @deprecated use {@link net.minestom.server.utils.coordinate.Pos} instead
|
||||
*/
|
||||
public class Position implements PublicCloneable<Position> {
|
||||
@Deprecated
|
||||
public class Position implements Point {
|
||||
|
||||
private double x, y, z;
|
||||
private float yaw, pitch;
|
||||
@ -201,15 +203,24 @@ public class Position implements PublicCloneable<Position> {
|
||||
this.z = position.getZ();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Position clone() {
|
||||
try {
|
||||
return (Position) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
return null;
|
||||
}
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Position clone() {
|
||||
return new Position(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -368,9 +379,9 @@ public class Position implements PublicCloneable<Position> {
|
||||
*/
|
||||
private float fixYaw(float yaw) {
|
||||
yaw = yaw % 360;
|
||||
if(yaw < -180.0F) {
|
||||
if (yaw < -180.0F) {
|
||||
yaw += 360.0F;
|
||||
} else if(yaw > 180.0F) {
|
||||
} else if (yaw > 180.0F) {
|
||||
yaw -= 360.0F;
|
||||
}
|
||||
return yaw;
|
||||
|
@ -2,9 +2,14 @@ package net.minestom.server.utils;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.utils.clone.PublicCloneable;
|
||||
import net.minestom.server.utils.coordinate.Point;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Vector implements PublicCloneable<Vector> {
|
||||
/**
|
||||
* @deprecated use {@link net.minestom.server.utils.coordinate.Vec} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class Vector implements Point {
|
||||
|
||||
private static final double epsilon = 0.000001;
|
||||
|
||||
@ -484,15 +489,24 @@ public class Vector implements PublicCloneable<Vector> {
|
||||
'}';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Vector clone() {
|
||||
try {
|
||||
return (Vector) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
throw new IllegalStateException("Weird thing happened");
|
||||
}
|
||||
public double x() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double y() {
|
||||
return y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double z() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Vector clone() {
|
||||
return new Vector(x,y,z);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
|
@ -80,4 +80,13 @@ public interface Point {
|
||||
(y() == castedY) ? castedY : castedY + 1,
|
||||
(int) Math.floor(z()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated present for backward compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract(pure = true)
|
||||
default @NotNull Point clone() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user