diff --git a/core/src/main/java/mc/core/Location.java b/core/src/main/java/mc/core/Location.java index adee609..adc1dc3 100644 --- a/core/src/main/java/mc/core/Location.java +++ b/core/src/main/java/mc/core/Location.java @@ -11,7 +11,7 @@ import java.io.Serializable; @AllArgsConstructor @Data -public class Location implements Serializable{ +public class Location implements Serializable, Cloneable{ private double x, y, z; private static int floor_double(double value) { @@ -19,14 +19,6 @@ public class Location implements Serializable{ return value < (double)i ? i - 1 : i; } - public static Location copyOf(Location location) { - return new Location( - location.x, - location.y, - location.z - ); - } - public static Location startPointLocation () { return new Location(0,10,0); } @@ -73,9 +65,19 @@ public class Location implements Serializable{ return (int) z; } + public long toLong() { return ((floor_double(x) & 0x3FFFFFF) << 38) | ((floor_double(y) & 0xFFF) << 26) | (floor_double(z) & 0x3FFFFFF); } + + @Override + public Location clone() { + try { + return (Location) super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + } } diff --git a/proto_1.12.2/src/main/java/mc/core/network/proto_1_12_2/TeleportManager.java b/proto_1.12.2/src/main/java/mc/core/network/proto_1_12_2/TeleportManager.java index 31424bd..90c735f 100644 --- a/proto_1.12.2/src/main/java/mc/core/network/proto_1_12_2/TeleportManager.java +++ b/proto_1.12.2/src/main/java/mc/core/network/proto_1_12_2/TeleportManager.java @@ -38,7 +38,7 @@ public class TeleportManager { teleportId = RAND.nextInt(9999); } while (teleportMap.containsKey(teleportId)); - teleportMap.put(teleportId, new TpData(player, Location.copyOf(location))); + teleportMap.put(teleportId, new TpData(player, location.clone())); return teleportId; }