Update Position Read/Write Code

This commit is contained in:
Paulomart 2019-04-26 18:59:29 +02:00
parent 3e793db8e9
commit 49c4d7f0f3

View file

@ -36,7 +36,7 @@ import java.util.UUID;
public class NetUtil {
private static final int POSITION_X_SIZE = 38;
private static final int POSITION_Y_SIZE = 26;
private static final int POSITION_Y_SIZE = 12;
private static final int POSITION_Z_SIZE = 38;
private static final int POSITION_Y_SHIFT = 0xFFF;
private static final int POSITION_WRITE_SHIFT = 0x3FFFFFF;
@ -90,8 +90,8 @@ public class NetUtil {
long val = in.readLong();
int x = (int) (val >> POSITION_X_SIZE);
int y = (int) ((val >> POSITION_Y_SIZE) & POSITION_Y_SHIFT);
int z = (int) ((val << POSITION_Z_SIZE) >> POSITION_Z_SIZE);
int y = (int) (val & POSITION_Y_SHIFT);
int z = (int) (val << 26 >> POSITION_Z_SIZE);
return new Position(x, y, z);
}
@ -101,7 +101,7 @@ public class NetUtil {
long y = pos.getY() & POSITION_Y_SHIFT;
long z = pos.getZ() & POSITION_WRITE_SHIFT;
out.writeLong(x << POSITION_X_SIZE | y << POSITION_Y_SIZE | z);
out.writeLong(x << POSITION_X_SIZE | z << POSITION_Y_SIZE | y);
}
public static Rotation readRotation(NetInput in) throws IOException {