From eb5ebc665016b40dcb2ad24d4baee5eab04a406f Mon Sep 17 00:00:00 2001 From: extremeheat Date: Fri, 7 Jan 2022 18:36:38 -0500 Subject: [PATCH] Bump bedrock-provider in tests (#172) --- examples/client/clientInternal.js | 4 ++-- package.json | 2 +- test/internal.js | 29 +++++++++++++++-------------- test/vanilla.js | 5 +++-- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/client/clientInternal.js b/examples/client/clientInternal.js index f30fe23..10da7f5 100644 --- a/examples/client/clientInternal.js +++ b/examples/client/clientInternal.js @@ -3,7 +3,7 @@ */ process.env.DEBUG = 'minecraft-protocol raknet' const { Client } = require('bedrock-protocol') -const { ChunkColumn, Version } = require('bedrock-provider') +const ChunkColumn = require('bedrock-provider').chunk('bedrock_1.17.10') async function test () { const client = new Client({ @@ -33,7 +33,7 @@ async function test () { }) client.on('level_chunk', async packet => { - const cc = new ChunkColumn(Version.v1_4_0, packet.x, packet.z) + const cc = new ChunkColumn(packet.x, packet.z) await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count) const blocks = [] for (let x = 0; x < 16; x++) { diff --git a/package.json b/package.json index 721e845..f747300 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@babel/eslint-parser": "^7.13.10", "babel-eslint": "^10.1.0", "bedrock-protocol": "file:.", - "bedrock-provider": "^1.0.0", + "bedrock-provider": "^2.0.0", "leveldb-zlib": "^1.0.1", "mocha": "^9.1.2", "protodef-yaml": "^1.1.0", diff --git a/test/internal.js b/test/internal.js index 7e61306..63e492e 100644 --- a/test/internal.js +++ b/test/internal.js @@ -3,6 +3,7 @@ const { dumpPackets } = require('../tools/genPacketDumps') const { ping } = require('../src/createClient') const { CURRENT_VERSION } = require('../src/options') const { join } = require('path') +const { waitFor } = require('../src/datatypes/util') // First we need to dump some packets that a vanilla server would send a vanilla // client. Then we can replay those back in our custom server. @@ -31,7 +32,7 @@ async function startTest (version = CURRENT_VERSION, ok) { console.assert(pongData, 'did not get valid pong data from server') const respawnPacket = get('packets/respawn.json') - const chunks = await requestChunks(respawnPacket.x, respawnPacket.z, 1) + const chunks = await requestChunks(version, respawnPacket.x, respawnPacket.z, 1) let loop @@ -150,31 +151,31 @@ async function startTest (version = CURRENT_VERSION, ok) { client.connect() } -const { ChunkColumn, Version } = require('bedrock-provider') -const { waitFor } = require('../src/datatypes/util') -const mcData = require('minecraft-data')('1.16') +async function requestChunks (version, x, z, radius) { + const ChunkColumn = require('bedrock-provider').chunk('bedrock_1.17.10') + // const mcData = require('minecraft-data')('1.16') -async function requestChunks (x, z, radius) { const cxStart = (x >> 4) - radius const cxEnd = (x >> 4) + radius const czStart = (z >> 4) - radius const czEnd = (z >> 4) + radius - const stone = mcData.blocksByName.stone + // const stone = mcData.blocksByName.stone const chunks = [] for (let cx = cxStart; cx < cxEnd; cx++) { for (let cz = czStart; cz < czEnd; cz++) { console.log('reading chunk at ', cx, cz) - const cc = new ChunkColumn(Version.v1_2_0_bis, x, z) + const cc = new ChunkColumn(x, z) - for (let x = 0; x < 16; x++) { - for (let y = 0; y < 60; y++) { - for (let z = 0; z < 16; z++) { - cc.setBlock(x, y, z, stone) - } - } - } + // Temporarily disable until 1.18 PR in bedrock-provider goes through + // for (let x = 0; x < 16; x++) { + // for (let y = 0; y < 60; y++) { + // for (let z = 0; z < 16; z++) { + // cc.setBlock({ x, y, z }, stone) + // } + // } + // } if (!cc) { console.log('no chunk') diff --git a/test/vanilla.js b/test/vanilla.js index 5d20b89..41033cc 100644 --- a/test/vanilla.js +++ b/test/vanilla.js @@ -2,9 +2,10 @@ const vanillaServer = require('../tools/startVanillaServer') const { Client } = require('../src/client') const { waitFor } = require('../src/datatypes/util') -const { ChunkColumn, Version } = require('bedrock-provider') async function test (version) { + const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + version) + // Start the server, wait for it to accept clients, throws on timeout const handle = await vanillaServer.startServerAndWait(version, 1000 * 220) console.log('Started server') @@ -45,7 +46,7 @@ async function test (version) { }, 200) client.on('level_chunk', async packet => { // Chunk read test - const cc = new ChunkColumn(Version.v1_4_0, packet.x, packet.z) + const cc = new ChunkColumn(packet.x, packet.z) await cc.networkDecodeNoCache(packet.payload, packet.sub_chunk_count) })