mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-12-20 12:32:26 -05:00
21 lines
757 B
JavaScript
21 lines
757 B
JavaScript
|
const { createSerializer, createDeserializer, states } = require('minecraft-protocol')
|
||
|
const mcPackets = require('minecraft-packets')
|
||
|
|
||
|
const serializer = createSerializer({ state: states.PLAY, version: '1.16.5', isServer: true })
|
||
|
const deserializer = createDeserializer({ state: states.PLAY, version: '1.16.5' })
|
||
|
|
||
|
function convertBufferToObject (buffer) {
|
||
|
return deserializer.parsePacketBuffer(buffer)
|
||
|
}
|
||
|
|
||
|
function convertObjectToBuffer (object) {
|
||
|
return serializer.createPacketBuffer(object)
|
||
|
}
|
||
|
|
||
|
const buffer = mcPackets.pc['1.16.5']['from-server'].abilities[0].raw
|
||
|
const parsed = convertBufferToObject(buffer).data
|
||
|
const parsedBuffer = convertObjectToBuffer(parsed)
|
||
|
console.log(buffer)
|
||
|
console.log(parsedBuffer)
|
||
|
console.log(buffer.equals(parsedBuffer))
|