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/rayTrace.js
Views: 789
1
const assert = require('assert')
2
const { BlockFace } = require('prismarine-world').iterators
3
4
module.exports = () => async (bot) => {
5
const { position } = bot.entity
6
await bot.lookAt(position.offset(0, 3, 0), true)
7
8
let block = bot.blockAtCursor()
9
assert.strictEqual(block, null)
10
11
block = bot.blockInSight()
12
assert.strictEqual(block, undefined)
13
14
await bot.lookAt(position.offset(0, -3, 0), true)
15
16
block = bot.blockAtCursor()
17
const relBlock = bot.blockAt(position.offset(0, -1, 0))
18
relBlock.face = BlockFace.TOP
19
20
assert.deepStrictEqual(block.position, relBlock.position)
21
assert.deepStrictEqual(block.face, relBlock.face)
22
23
block = bot.blockInSight()
24
assert.deepStrictEqual(block.position, relBlock.position)
25
assert.deepStrictEqual(block.face, relBlock.face)
26
}
27
28