Merge remote-tracking branch 'origin/forwolk/location-cloning' into dmitriymx/location-refactory
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user