client example updates

This commit is contained in:
extremeheat 2021-03-26 04:38:25 -04:00
commit 0bdd071876
4 changed files with 27 additions and 14 deletions

View file

@ -1,10 +1,13 @@
process.env.DEBUG = 'minecraft-protocol raknet'
const { Client } = require('bedrock-protocol')
const { ChunkColumn, Version } = require('bedrock-provider')
async function test () {
const client = new Client({
hostname: '127.0.0.1',
port: 19132
port: 19130
// You can specify version by adding :
// version: '1.16.210'
})
client.once('resource_packs_info', (packet) => {
@ -20,23 +23,22 @@ async function test () {
})
})
// client.once('resource_packs_info', (packet) => {
// client.write('resource_pack_client_response', {
// response_status: 'completed',
// resourcepackids: []
// })
// })
client.queue('client_cache_status', { enabled: false })
client.queue('request_chunk_radius', { chunk_radius: 1 })
client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: 0n })
})
// var read = 0;
// client.on('level_chunk', (packet) => {
// read++
// fs.writeFileSync(`level_chunk-${read}.json`, JSON.stringify(packet, null, 2))
// })
client.on('level_chunk', async packet => {
const cc = new ChunkColumn(Version.v1_4_0, packet.x, packet.z)
await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count)
let blocks = []
for (let x = 0; x < 16; x++) {
for (let z = 0; z < 16; z++) {
blocks.push(cc.getBlock(x, 0, z)) // Read some blocks in this chunk
}
}
})
}
test()