From 6528a7e262c53229a23fbdc1cac7d74f6cc99905 Mon Sep 17 00:00:00 2001 From: Romain Beaumont Date: Wed, 12 Jan 2022 00:48:09 +0000 Subject: [PATCH] add tall world feature to start tests at 4 or -60 depending on support --- lib/features.json | 5 +++++ test/externalTests/exampleBlockFinder.js | 2 +- test/externalTests/exampleInventory.js | 4 ++-- test/externalTests/plugins/testCommon.js | 8 ++++---- test/externalTests/useChests.js | 12 +++++++----- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/features.json b/lib/features.json index b7c2655f1..75fab0a24 100644 --- a/lib/features.json +++ b/lib/features.json @@ -323,5 +323,10 @@ "name": "armAnimationBeforeUse", "description": "arm animation packet sent before use entity packet", "versions": ["1.8", "1.8.9"] + }, + { + "name": "tallWorld", + "description": "world starts at -64 and ends at 384", + "versions": ["1.18", "1.18"] } ] diff --git a/test/externalTests/exampleBlockFinder.js b/test/externalTests/exampleBlockFinder.js index 9eb1f099f..781b393b9 100644 --- a/test/externalTests/exampleBlockFinder.js +++ b/test/externalTests/exampleBlockFinder.js @@ -3,7 +3,7 @@ const assert = require('assert') module.exports = () => async (bot) => { await bot.test.runExample('examples/blockfinder.js', async (name, cb) => { assert.strictEqual(name, 'finder') - await bot.test.wait(8000) + await bot.test.wait(2000) await bot.test.tellAndListen(name, 'find dirt', (message) => { const matches = message.match(/I found ([0-9]+) (.+?) blocks in (.+?) ms/) if (matches.length !== 4 || matches[1] === '0' || matches[2] !== 'dirt' || parseFloat(matches[3]) > 500) { diff --git a/test/externalTests/exampleInventory.js b/test/externalTests/exampleInventory.js index 511e39952..68e93b55a 100644 --- a/test/externalTests/exampleInventory.js +++ b/test/externalTests/exampleInventory.js @@ -52,7 +52,7 @@ module.exports = () => async (bot) => { assert.strictEqual(name, 'inventory') bot.chat('/op inventory') // to counteract spawn protection bot.chat('/clear inventory') - bot.chat('/setblock 52 4 0 crafting_table') // to make stone bricks stairs + bot.chat(`/setblock 52 ${bot.test.groundY} 0 crafting_table`) // to make stone bricks stairs bot.chat('/give inventory dirt 64') bot.chat('/give inventory stick 7') bot.chat('/give inventory iron_ore 64') @@ -67,7 +67,7 @@ module.exports = () => async (bot) => { await bot.test.wait(100) } // cleanup - bot.chat('/setblock 52 4 0 air') + bot.chat(`/setblock 52 ${bot.test.groundY} 0 air`) cb() function makeTest (inStr, outStr) { diff --git a/test/externalTests/plugins/testCommon.js b/test/externalTests/plugins/testCommon.js index 91fc5cb55..407068393 100644 --- a/test/externalTests/plugins/testCommon.js +++ b/test/externalTests/plugins/testCommon.js @@ -14,6 +14,7 @@ function inject (bot) { const Item = require('prismarine-item')(bot.version) bot.test = {} + bot.test.groundY = bot.supportFeature('tallWorld') ? -60 : 4 bot.test.sayEverywhere = sayEverywhere bot.test.clearInventory = callbackify(clearInventory) bot.test.becomeSurvival = callbackify(becomeSurvival) @@ -66,8 +67,7 @@ function inject (bot) { ] async function resetBlocksToSuperflat () { - const groundY = 4 - for (let y = groundY + 4; y >= groundY - 1; y--) { + for (let y = bot.test.groundY + 4; y >= bot.test.groundY - 1; y--) { bot.chat(`/fill ~-5 ${y} ~-5 ~5 ${y} ~5 ` + layerNames[y]) } await bot.test.wait(100) @@ -85,7 +85,7 @@ function inject (bot) { await becomeCreative() await clearInventory() bot.creative.startFlying() - await teleport(new Vec3(0, 4, 0)) + await teleport(new Vec3(0, bot.test.groundY, 0)) await bot.waitForChunksToLoad() await resetBlocksToSuperflat() await sleep(1000) @@ -197,7 +197,7 @@ function inject (bot) { checkCondition: message => message.json.translate === 'multiplayer.player.joined' }) childBotName = message.json.with[0].insertion - bot.chat(`/tp ${childBotName} 50 4 0`) + bot.chat(`/tp ${childBotName} 50 ${bot.test.groundY} 0`) setTimeout(() => { bot.chat('loaded') }, 5000) diff --git a/test/externalTests/useChests.js b/test/externalTests/useChests.js index faa6910c5..c7bcf9e56 100644 --- a/test/externalTests/useChests.js +++ b/test/externalTests/useChests.js @@ -6,12 +6,14 @@ module.exports = () => async (bot) => { const mcData = require('minecraft-data')(bot.version) const Item = require('prismarine-item')(bot.version) - const smallChestLocation = new Vec3(0, 4, -1) - const largeChestLocations = [new Vec3(0, 4, 1), new Vec3(1, 4, 1)] - const smallTrappedChestLocation = new Vec3(1, 4, 0) + bot.test.groundY = bot.supportFeature('tallWorld') ? -60 : 4 + + const smallChestLocation = new Vec3(0, bot.test.groundY, -1) + const largeChestLocations = [new Vec3(0, bot.test.groundY, 1), new Vec3(1, bot.test.groundY, 1)] + const smallTrappedChestLocation = new Vec3(1, bot.test.groundY, 0) const largeTrappedChestLocations = [ - new Vec3(-1, 4, 1), - new Vec3(-1, 4, 0) + new Vec3(-1, bot.test.groundY, 1), + new Vec3(-1, bot.test.groundY, 0) ] const chestSlot = 36 const trappedChestSlot = 37