diff --git a/examples/proxy/proxy.js b/examples/proxy/proxy.js index ea92d21..4bd71a0 100644 --- a/examples/proxy/proxy.js +++ b/examples/proxy/proxy.js @@ -128,8 +128,8 @@ srv.on('login', function(client) { targetClient.on('raw', function(buffer, meta) { if(client.state != states.PLAY || meta.state != states.PLAY) return; - var packetData = mc.parsePacketData(buffer, meta.state, false, {"packet": 1}).data; - var packetBuff = mc.createPacketBuffer(meta.name, meta.state, packetData, true); + var packetData = targetClient.deserializer.parsePacketData(buffer).data; + var packetBuff = client.serializer.createPacketBuffer(meta.name, packetData); if(buffertools.compare(buffer, packetBuff) != 0) { console.log("client<-server: Error in packet " + state + "." + meta.name); console.log(buffer.toString('hex')); @@ -148,8 +148,8 @@ srv.on('login', function(client) { client.on('raw', function(buffer, meta) { if(meta.state != states.PLAY || targetClient.state != states.PLAY) return; - var packetData = mc.parsePacketData(buffer, meta.state, true, {"packet": 1}).data; - var packetBuff = mc.createPacketBuffer(meta.name, meta.state, packetData, false); + var packetData = client.deserializer.parsePacketData(buffer).data; + var packetBuff = targetClient.serializer.createPacketBuffer(meta.name, packetData); if(buffertools.compare(buffer, packetBuff) != 0) { console.log("client->server: Error in packet " + state + "." + meta.name); console.log(buffer.toString('hex')); diff --git a/src/transforms/serializer.js b/src/transforms/serializer.js index 2d98bee..1f030ff 100644 --- a/src/transforms/serializer.js +++ b/src/transforms/serializer.js @@ -65,7 +65,7 @@ class Serializer extends Transform { createPacketBuffer(packetName, params) { var direction = !this.isServer ? 'toServer' : 'toClient'; 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]; packet=packet ? packet : null;