forked from PrismarineJS/mineflayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_totem.js
29 lines (26 loc) · 848 Bytes
/
auto_totem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* This script will automatically set if a totem is in the inventory or the off-hand.
* It checks for a totem every tick.
*/
const mineflayer = require('mineflayer')
if (process.argv.length < 4 || process.argv.length > 6) {
console.log('Usage : node auto_totem.js <host> <port> [<name>] [<password>]')
process.exit(1)
}
const bot = mineflayer.createBot({
host: process.argv[2],
port: parseInt(process.argv[3]),
username: process.argv[4] ? process.argv[4] : 'totem',
password: process.argv[5]
})
bot.on('spawn', () => {
const totemId = bot.registry.itemsByName.totem_of_undying.id // Get the correct id
if (bot.registry.itemsByName.totem_of_undying) {
setInterval(() => {
const totem = bot.inventory.findInventoryItem(totemId, null)
if (totem) {
bot.equip(totem, 'off-hand')
}
}, 50)
}
})