Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS
GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/test/externalTests/dimensionData.js
9427 views
1
const assert = require('assert')
2
3
module.exports = () => {
4
const tests = []
5
6
function addTest (name, f) {
7
tests[name] = (bot) => f(bot)
8
}
9
10
addTest('overworld properties', async (bot) => {
11
// After spawn, bot.game.dimension should be set to 'overworld'
12
assert.ok(bot.game.dimension, 'bot.game.dimension should be set after spawn')
13
assert.strictEqual(bot.game.dimension, 'overworld', 'Dimension should be overworld on spawn')
14
15
// minY and height should be populated from the dimension codec
16
assert.strictEqual(typeof bot.game.minY, 'number', 'bot.game.minY should be a number')
17
assert.strictEqual(typeof bot.game.height, 'number', 'bot.game.height should be a number')
18
assert.ok(bot.game.height > 0, 'Height should be positive')
19
20
// Overworld in modern versions has minY=-64, height=384; older versions have minY=0, height=256
21
if (bot.supportFeature('dimensionDataInCodec')) {
22
assert.strictEqual(bot.game.minY, -64, 'Overworld minY should be -64 for 1.18+')
23
assert.strictEqual(bot.game.height, 384, 'Overworld height should be 384 for 1.18+')
24
} else {
25
assert.ok(bot.game.minY <= 0, 'minY should be <= 0')
26
assert.ok(bot.game.height >= 256, 'Height should be at least 256')
27
}
28
})
29
30
return tests
31
}
32
33