mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 21:52:17 -04:00
fix readPosition (see http://wiki.vg/index.php?title=Data_Types&diff=6529&oldid=6491) thanks Fenhl
This commit is contained in:
parent
a43e1af1d5
commit
456331b952
@ -1095,14 +1095,17 @@ function readBool(buffer, offset) {
|
||||
}
|
||||
|
||||
function readPosition(buffer, offset) {
|
||||
var longVal = readLong(buffer, offset).value; // I wish I could do destructuring...
|
||||
var x = longVal[0] >> 6;
|
||||
var y = ((longVal[0] & 0x3F) << 6) | ((longVal[1] >> 26) & 0x3f);
|
||||
var z = longVal[1] & 0x3FFFFFF;
|
||||
return {
|
||||
value: { x: x, y: y, z: z },
|
||||
size: 8
|
||||
};
|
||||
var longVal = readLong(buffer, offset).value; // I wish I could do destructuring...
|
||||
var x = longVal[0] >> 6;
|
||||
if(x>33554432) x-=67108864;
|
||||
var y = ((longVal[0] & 0x3F) << 6) | ((longVal[1] >> 26) & 0x3f);
|
||||
if(y>2048) y-=4096;
|
||||
var z = longVal[1] & 0x3FFFFFF;
|
||||
if(z>33554432) z-=67108864;
|
||||
return {
|
||||
value: { x: x, y: y, z: z },
|
||||
size: 8
|
||||
};
|
||||
}
|
||||
|
||||
function readSlot(buffer, offset) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user