* add new raknet library option (raknet-node) * fix lint * fix lint & add new options * fix lint * fix user option & add rust-raknet test. * fix lint. * add raknet backend option. * remove useNativeRaknet option. * add not found log. * add test timeout size. * fix js raknet return error. * restore useNativeRaknet option. * update doc. * update options handling, back compat * fix server doc * Fix tests * fix tests. * fix lint. * delay timeout. * Update rak.js * update raknet-node version. * increase timeout. * Update vanilla.js * Update proxy.js * Update internal.js * update raknet-node version. * update rust-raknet version. * increase timeout test time * increase timeout test time * update backend version. * change timeout Co-authored-by: extremeheat <extreme@protonmail.ch>
71 lines
2 KiB
JavaScript
71 lines
2 KiB
JavaScript
// process.env.DEBUG = 'minecraft-protocol raknet'
|
|
const vanillaServer = require('../tools/startVanillaServer')
|
|
const { Client } = require('../src/client')
|
|
const { waitFor } = require('../src/datatypes/util')
|
|
|
|
async function test (version) {
|
|
const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + (version.includes('1.19') ? '1.18.30' : version)) // TODO: Fix prismarine-chunk
|
|
|
|
// Start the server, wait for it to accept clients, throws on timeout
|
|
const handle = await vanillaServer.startServerAndWait2(version, 1000 * 220)
|
|
console.log('Started server')
|
|
|
|
const client = new Client({
|
|
host: '127.0.0.1',
|
|
port: 19130,
|
|
username: 'Notch',
|
|
version,
|
|
raknetBackend: 'raknet-node',
|
|
offline: true
|
|
})
|
|
|
|
console.log('Started client')
|
|
client.connect()
|
|
|
|
let loop
|
|
|
|
await waitFor((res) => {
|
|
client.once('resource_packs_info', (packet) => {
|
|
client.write('resource_pack_client_response', {
|
|
response_status: 'completed',
|
|
resourcepackids: []
|
|
})
|
|
|
|
client.once('resource_pack_stack', (stack) => {
|
|
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 })
|
|
|
|
clearInterval(loop)
|
|
loop = setInterval(() => {
|
|
client.queue('tick_sync', { request_time: BigInt(Date.now()), response_time: BigInt(Date.now()) })
|
|
}, 200)
|
|
|
|
client.on('level_chunk', async packet => { // Chunk read test
|
|
const cc = new ChunkColumn(packet.x, packet.z)
|
|
await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count)
|
|
})
|
|
|
|
console.log('Awaiting join')
|
|
|
|
client.on('spawn', () => {
|
|
console.log('✔ Client has spawned')
|
|
client.close()
|
|
handle.kill()
|
|
res()
|
|
})
|
|
})
|
|
}, 1000 * 60, () => {
|
|
client.close()
|
|
handle.kill()
|
|
throw Error('❌ client timed out ')
|
|
})
|
|
clearInterval(loop)
|
|
}
|
|
|
|
module.exports = { clientTest: test }
|