Parse and serialize minecraft packets, plus authentication and encryption.
dependabot[bot] on npm_and_yarn
Bump @types/node from 17.0.45 t… (compare)
<TheGameSpider> Hello, I am trying to send custom_payload
packet using
client.write("custom_payload", packet)
, and I am getting this error
Caught exception: RangeError [ERR_INVALID_ARG_VALUE]: The argument 'size' is invalid. Received NaN
at Function.allocUnsafe (node:buffer:371:3)
at CompiledProtodef.createPacketBuffer (/home/ubuntu/mc/node_modules/protodef/src/compiler.js:101:27)
at Serializer.createPacketBuffer (/home/ubuntu/mc/node_modules/protodef/src/serializer.js:12:23)
at Serializer._transform (/home/ubuntu/mc/node_modules/protodef/src/serializer.js:18:18)
at Serializer.Transform._read (/home/ubuntu/mc/node_modules/readable-stream/lib/_stream_transform.js:177:10)
at Serializer.Transform._write (/home/ubuntu/mc/node_modules/readable-stream/lib/_stream_transform.js:164:83)
at doWrite (/home/ubuntu/mc/node_modules/readable-stream/lib/_stream_writable.js:409:139)
at writeOrBuffer (/home/ubuntu/mc/node_modules/readable-stream/lib/_stream_writable.js:398:5)
at Serializer.Writable.write (/home/ubuntu/mc/node_modules/readable-stream/lib/_stream_writable.js:307:11)
at Client.write (/home/ubuntu/mc/node_modules/minecraft-protocol/src/client.js:221:21) {
code: 'ERR_INVALID_ARG_VALUE',
field: 'play.toServer'
}
<paradise> ```js
const mc = require('minecraft-protocol');
const handleServer = (server) => {
try {
var client = mc.createClient({
host: "localhost", // optional
port: 25565, // optional
username: "Symphony",
version: false
});
client.on('login', function(packet) {
client.write('chat', {message: "xyz"});
client.end();
});
} catch (e) { console.error(e); }
}
```