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/examples/raycast.js
Views: 789
1
const mineflayer = require('mineflayer')
2
3
if (process.argv.length < 4 || process.argv.length > 6) {
4
console.log('Usage : node raycast.js <host> <port> [<name>] [<password>]')
5
process.exit(1)
6
}
7
8
const bot = mineflayer.createBot({
9
host: process.argv[2],
10
port: parseInt(process.argv[3]),
11
username: process.argv[4] ? process.argv[4] : 'raycast',
12
password: process.argv[5]
13
})
14
15
bot.on('message', (cm) => {
16
if (cm.toString().includes('block')) {
17
block()
18
}
19
})
20
21
function block () {
22
const block = bot.blockAtCursor()
23
24
if (!block) {
25
return bot.chat('Looking at Air')
26
}
27
28
bot.chat(`Looking at ${block.displayName}`)
29
}
30
31