Export functions to create packet serializer and deserializer.
This commit is contained in:
parent
328785d8af
commit
abefe2c7bf
3 changed files with 27 additions and 1 deletions
|
|
@ -102,6 +102,15 @@ ping({ host: 'play.cubecraft.net', port: 19132 }).then(res => {
|
|||
})
|
||||
```
|
||||
|
||||
### Serializer/Deserializer
|
||||
|
||||
The `createSerializer` and `createDeserializer` functions provide direct access to the packet serialization and deserialization layer of bedrock-protocol. This is particularly useful when you need to:
|
||||
|
||||
- Work with packet data without establishing a full client/server connection
|
||||
- Write unit tests for your packet handling logic
|
||||
- Analyze or debug packet structures between different Minecraft versions
|
||||
- Save and replay packet sequences for testing or benchmarking
|
||||
|
||||
## Documentation
|
||||
|
||||
For documentation on the protocol, and packets/fields see the [protocol documentation](https://prismarinejs.github.io/minecraft-data/protocol).
|
||||
|
|
|
|||
14
index.d.ts
vendored
14
index.d.ts
vendored
|
|
@ -237,4 +237,18 @@ declare module 'bedrock-protocol' {
|
|||
host: string
|
||||
port: number
|
||||
}): Promise<ServerAdvertisement>
|
||||
|
||||
/**
|
||||
* Creates a packet serializer for the specified Minecraft Bedrock version.
|
||||
* @param version The Minecraft Bedrock version to create the serializer for.
|
||||
* @returns A serializer that can convert minecraft bedrock packets to binary packet data.
|
||||
*/
|
||||
export function createSerializer(version: Version): any
|
||||
|
||||
/**
|
||||
* Creates a packet deserializer for the specified Minecraft Bedrock version.
|
||||
* @param version The Minecraft Bedrock version to create the deserializer for.
|
||||
* @returns A deserializer that can convert binary packet data to JavaScript objects.
|
||||
*/
|
||||
export function createDeserializer(version: Version): any
|
||||
}
|
||||
|
|
|
|||
5
index.js
5
index.js
|
|
@ -11,6 +11,7 @@ const { createClient, ping } = require('./src/createClient')
|
|||
const { createServer } = require('./src/createServer')
|
||||
const { Titles } = require('prismarine-auth')
|
||||
const { ServerAdvertisement } = require('./src/server/advertisement')
|
||||
const { createSerializer, createDeserializer } = require('./src/transforms/serializer')
|
||||
|
||||
module.exports = {
|
||||
Client,
|
||||
|
|
@ -20,5 +21,7 @@ module.exports = {
|
|||
ping,
|
||||
createServer,
|
||||
title: Titles,
|
||||
ServerAdvertisement
|
||||
ServerAdvertisement,
|
||||
createSerializer,
|
||||
createDeserializer
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue