fix position encoding

This commit is contained in:
Bixilon 2020-06-24 17:09:01 +02:00
parent 082e4929b0
commit 1b13b4981b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -176,20 +176,11 @@ public class InByteBuffer {
}
public BlockPosition readPosition() {
//ToDo: here is something wrong with z :(
// this is the correct example! wiki.vg is clearly wrong with this!
Long raw = readLong();
int x = (int) (raw >> 38);
short y = (short) (raw & 0xFFF);
int z = (int) (raw >> 12) & 0x3FFFFFF;
if (x >= (2 ^ 25)) {
x -= 2 ^ 26;
}
if (y >= (2 ^ 11)) {
y -= 2 ^ 12;
}
if (z >= (2 ^ 25)) {
z -= 2 ^ 26;
}
short y = (short) ((raw >> 26) & 0xFFF);
int z = (int) (raw & 0x3FFFFFF);
return new BlockPosition(x, y, z);
}