Archived
0

Merge branch 'develop' into merge_branch

# Conflicts:
#	core/src/main/java/mc/core/Location.java
This commit is contained in:
Forwolk
2018-08-02 15:56:19 +03:00
8 changed files with 62 additions and 35 deletions

View File

@@ -14,6 +14,11 @@ import java.io.Serializable;
public class Location implements Serializable{
private double x, y, z;
private static int floor_double(double value) {
int i = (int)value;
return value < (double)i ? i - 1 : i;
}
public static Location copyOf(Location location) {
return new Location(
location.x,
@@ -26,12 +31,22 @@ public class Location implements Serializable{
return new Location(0,10,0);
}
public Location(long compactValue) {
set(compactValue);
}
public void set(Location location) {
this.x = location.x;
this.y = location.y;
this.z = location.z;
}
public void set(long compactValue) {
this.x = compactValue >> 38;
this.y = (compactValue >> 26) & 0xFFF;
this.z = compactValue << 38 >> 38; // is normal?
}
public Location diff(Location location) {
return new Location(
this.x - location.x,
@@ -51,4 +66,10 @@ public class Location implements Serializable{
public int getBlockZ() {
return (int) z;
}
public long toLong() {
return ((floor_double(x) & 0x3FFFFFF) << 38)
| ((floor_double(y) & 0xFFF) << 26)
| (floor_double(z) & 0x3FFFFFF);
}
}