Skip to content

Commit

Permalink
add tall world feature to start tests at 4 or -60 depending on support
Browse files Browse the repository at this point in the history
  • Loading branch information
rom1504 committed Jan 12, 2022
1 parent 165e0e1 commit 6528a7e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions lib/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
]
2 changes: 1 addition & 1 deletion test/externalTests/exampleBlockFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/externalTests/exampleInventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions test/externalTests/plugins/testCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions test/externalTests/useChests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6528a7e

Please sign in to comment.