mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 22:23:21 -04:00
fix player position and look. closes #10
This commit is contained in:
parent
3f0ee115ee
commit
79695daa23
19
index.js
19
index.js
@ -163,13 +163,15 @@ Client.prototype.connect = function(port, host) {
|
|||||||
self.socket.on('data', function(data) {
|
self.socket.on('data', function(data) {
|
||||||
if (self.encryptionEnabled) data = new Buffer(self.decipher.update(data), 'binary');
|
if (self.encryptionEnabled) data = new Buffer(self.decipher.update(data), 'binary');
|
||||||
incomingBuffer = Buffer.concat([incomingBuffer, data]);
|
incomingBuffer = Buffer.concat([incomingBuffer, data]);
|
||||||
var parsed;
|
var parsed, packet;
|
||||||
while (true) {
|
while (true) {
|
||||||
parsed = parsePacket(incomingBuffer);
|
parsed = parsePacket(incomingBuffer);
|
||||||
if (! parsed) break;
|
if (! parsed) break;
|
||||||
|
packet = parsed.results;
|
||||||
|
hax(packet); // fuck you, notch
|
||||||
incomingBuffer = incomingBuffer.slice(parsed.size);
|
incomingBuffer = incomingBuffer.slice(parsed.size);
|
||||||
self.emit('packet', parsed.results);
|
self.emit('packet', packet);
|
||||||
self.emit('packet-' + parsed.results.id, parsed.results);
|
self.emit('packet-' + packet.id, packet);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -832,3 +834,14 @@ function getLoginSession(email, password, cb) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hax(packet) {
|
||||||
|
// bullshit post-parsing hax that we have to do due to mojang incompetence
|
||||||
|
var tmp;
|
||||||
|
if (packet.id === 0x0d) {
|
||||||
|
// when 0x0d is sent from the server, the Y and the Stance fields are swapped.
|
||||||
|
tmp = packet.y;
|
||||||
|
packet.y = packet.stance;
|
||||||
|
packet.stance = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user