CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PrismarineJS

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: PrismarineJS/mineflayer
Path: blob/master/test/externalTests/gamemode.js
Views: 789
1
// test to see if bot retains creative gamemode in bot object on death
2
3
const assert = require('assert')
4
const { onceWithCleanup } = require('../../lib/promise_utils')
5
6
module.exports = () => {
7
const tests = []
8
9
function addTest (name, f) {
10
tests[name] = (bot) => f(bot)
11
}
12
13
addTest('change', async (bot) => {
14
await bot.test.becomeSurvival()
15
assert.strictEqual(bot.game.gameMode, 'survival', 'Wrong gamemode after switching gamemode')
16
await bot.test.becomeCreative()
17
assert.strictEqual(bot.game.gameMode, 'creative', 'Wrong gamemode after switching gamemode')
18
})
19
20
addTest('after respawn', async (bot) => {
21
await bot.test.becomeCreative()
22
bot.test.selfKill()
23
await onceWithCleanup(bot, 'respawn', { timeout: 5000 })
24
// Respawn packets send the gamemode. If the bot is in creative mode, it should respawn in creative mode. Tested <1.20
25
assert.strictEqual(bot.game.gameMode, 'creative', 'Wrong gamemode after respawn')
26
})
27
28
return tests
29
}
30
31