mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 06:03:33 -04:00
fix proxy relatively to the unexposing of createPacketBuffer
also fix a small bug in serializer.js
This commit is contained in:
parent
917b6adda1
commit
7871ac446a
@ -128,8 +128,8 @@ srv.on('login', function(client) {
|
|||||||
targetClient.on('raw', function(buffer, meta) {
|
targetClient.on('raw', function(buffer, meta) {
|
||||||
if(client.state != states.PLAY || meta.state != states.PLAY)
|
if(client.state != states.PLAY || meta.state != states.PLAY)
|
||||||
return;
|
return;
|
||||||
var packetData = mc.parsePacketData(buffer, meta.state, false, {"packet": 1}).data;
|
var packetData = targetClient.deserializer.parsePacketData(buffer).data;
|
||||||
var packetBuff = mc.createPacketBuffer(meta.name, meta.state, packetData, true);
|
var packetBuff = client.serializer.createPacketBuffer(meta.name, packetData);
|
||||||
if(buffertools.compare(buffer, packetBuff) != 0) {
|
if(buffertools.compare(buffer, packetBuff) != 0) {
|
||||||
console.log("client<-server: Error in packet " + state + "." + meta.name);
|
console.log("client<-server: Error in packet " + state + "." + meta.name);
|
||||||
console.log(buffer.toString('hex'));
|
console.log(buffer.toString('hex'));
|
||||||
@ -148,8 +148,8 @@ srv.on('login', function(client) {
|
|||||||
client.on('raw', function(buffer, meta) {
|
client.on('raw', function(buffer, meta) {
|
||||||
if(meta.state != states.PLAY || targetClient.state != states.PLAY)
|
if(meta.state != states.PLAY || targetClient.state != states.PLAY)
|
||||||
return;
|
return;
|
||||||
var packetData = mc.parsePacketData(buffer, meta.state, true, {"packet": 1}).data;
|
var packetData = client.deserializer.parsePacketData(buffer).data;
|
||||||
var packetBuff = mc.createPacketBuffer(meta.name, meta.state, packetData, false);
|
var packetBuff = targetClient.serializer.createPacketBuffer(meta.name, packetData);
|
||||||
if(buffertools.compare(buffer, packetBuff) != 0) {
|
if(buffertools.compare(buffer, packetBuff) != 0) {
|
||||||
console.log("client->server: Error in packet " + state + "." + meta.name);
|
console.log("client->server: Error in packet " + state + "." + meta.name);
|
||||||
console.log(buffer.toString('hex'));
|
console.log(buffer.toString('hex'));
|
||||||
|
@ -65,7 +65,7 @@ class Serializer extends Transform {
|
|||||||
createPacketBuffer(packetName, params) {
|
createPacketBuffer(packetName, params) {
|
||||||
var direction = !this.isServer ? 'toServer' : 'toClient';
|
var direction = !this.isServer ? 'toServer' : 'toClient';
|
||||||
var packetId = this.packetIds[this.protocolState][direction][packetName];
|
var packetId = this.packetIds[this.protocolState][direction][packetName];
|
||||||
assert.notEqual(packetId, undefined, `${this.protocolState}.${this.isServer}.${packetName} : ${packetId}`);
|
assert.notEqual(packetId, undefined, `${this.protocolState}.${direction}.${packetName} : ${packetId}`);
|
||||||
var packet = this.packetFields[this.protocolState][direction][packetName];
|
var packet = this.packetFields[this.protocolState][direction][packetName];
|
||||||
packet=packet ? packet : null;
|
packet=packet ? packet : null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user