diff --git a/lib/packet.js b/lib/packet.js index cc9af86..d5bc3df 100644 --- a/lib/packet.js +++ b/lib/packet.js @@ -23,7 +23,6 @@ const { Writable } = require('stream') const varint = require('varint') -const Int64 = require('node-int64') const PROTOCOL_VERSION = 736 // Minecraft 1.16.1 @@ -45,7 +44,9 @@ module.exports.createHandshakePacket = (address, port) => { } module.exports.createPingPacket = (timestamp) => { - return createPacket(1, new Int64(timestamp).toBuffer()) + let timestampBuffer = Buffer.allocUnsafe(8) + timestampBuffer.writeBigInt64BE(BigInt(timestamp), 0) + return createPacket(1, timestampBuffer) } function createPacket (packetId, data) { @@ -140,7 +141,7 @@ function decodeHandshakeResponse (packet) { function decodePong (packet) { return new Promise((resolve, reject) => { // Decode timestamp - let timestamp = new Int64(packet.data) + let timestamp = Number(BigInt(`0x${packet.data.toString('hex')}`)) packet.result = Date.now() - timestamp resolve(packet) diff --git a/package.json b/package.json index c4af753..8fa62d7 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "standard": "^7.1.2" }, "dependencies": { - "node-int64": "^0.4.0", "varint": "^4.0.1" } }