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
|
@AllArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class Location implements Serializable{
|
public class Location implements Serializable, Cloneable{
|
||||||
private double x, y, z;
|
private double x, y, z;
|
||||||
|
|
||||||
private static int floor_double(double value) {
|
private static int floor_double(double value) {
|
||||||
@@ -19,14 +19,6 @@ public class Location implements Serializable{
|
|||||||
return value < (double)i ? i - 1 : i;
|
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 () {
|
public static Location startPointLocation () {
|
||||||
return new Location(0,10,0);
|
return new Location(0,10,0);
|
||||||
}
|
}
|
||||||
@@ -73,9 +65,19 @@ public class Location implements Serializable{
|
|||||||
return (int) z;
|
return (int) z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public long toLong() {
|
public long toLong() {
|
||||||
return ((floor_double(x) & 0x3FFFFFF) << 38)
|
return ((floor_double(x) & 0x3FFFFFF) << 38)
|
||||||
| ((floor_double(y) & 0xFFF) << 26)
|
| ((floor_double(y) & 0xFFF) << 26)
|
||||||
| (floor_double(z) & 0x3FFFFFF);
|
| (floor_double(z) & 0x3FFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location clone() {
|
||||||
|
try {
|
||||||
|
return (Location) super.clone();
|
||||||
|
} catch (CloneNotSupportedException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class TeleportManager {
|
|||||||
teleportId = RAND.nextInt(9999);
|
teleportId = RAND.nextInt(9999);
|
||||||
} while (teleportMap.containsKey(teleportId));
|
} while (teleportMap.containsKey(teleportId));
|
||||||
|
|
||||||
teleportMap.put(teleportId, new TpData(player, Location.copyOf(location)));
|
teleportMap.put(teleportId, new TpData(player, location.clone()));
|
||||||
return teleportId;
|
return teleportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user