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/sign.js
Views: 789
1
const assert = require('assert')
2
const Vec3 = require('vec3')
3
4
module.exports = () => async (bot) => {
5
const Item = require('prismarine-item')(bot.registry)
6
const lowerBlock = bot.blockAt(bot.entity.position.offset(0, -1, 0))
7
8
let signItem = null
9
for (const name in bot.registry.itemsByName) {
10
if (name.includes('sign') && !name.includes('hanging')) signItem = bot.registry.itemsByName[name]
11
}
12
assert.notStrictEqual(signItem, null)
13
14
const p = new Promise((resolve) => {
15
bot._client.once('open_sign_entity', (packet) => {
16
const sign = bot.blockAt(new Vec3(packet.location))
17
bot.updateSign(sign, '1\n2\n3\n')
18
19
setTimeout(() => {
20
// Get updated sign
21
const sign = bot.blockAt(bot.entity.position)
22
23
assert.strictEqual(sign.signText.trimEnd(), '1\n2\n3')
24
25
if (sign.blockEntity) {
26
// Check block update
27
bot.activateBlock(sign)
28
assert.notStrictEqual(sign.blockEntity, undefined)
29
}
30
31
resolve()
32
}, 500)
33
})
34
})
35
36
await bot.lookAt(lowerBlock.position, true)
37
await bot.test.setInventorySlot(36, new Item(signItem.id, 1, 0))
38
await bot.placeBlock(lowerBlock, new Vec3(0, 1, 0))
39
return p
40
}
41
42