Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/examples/perfectShotBow.js
Views: 789
const mineflayer = require('mineflayer')1const minecraftHawkEye = require('minecrafthawkeye')23const bot = mineflayer.createBot({4host: process.argv[2],5port: parseInt(process.argv[3]),6username: process.argv[4] ? process.argv[4] : 'Archer',7password: process.argv[5]8})9bot.loadPlugin(minecraftHawkEye)1011bot.on('spawn', function () {12bot.chat(`/give ${bot.username} bow{Enchantments:[{id:unbreaking,lvl:100}]} 1`)13bot.chat(`/give ${bot.username} crossbow{Enchantments:[{id:quick_charge,lvl:3},{id:unbreaking,lvl:100}]} 1`)14bot.chat(`/give ${bot.username} minecraft:arrow 300`)15bot.chat('/time set day')16bot.chat('/kill @e[type=minecraft:arrow]')1718bot.chat('Ready!')1920// Get target for block position, use whatever you need21const target = bot.hawkEye.getPlayer()2223if (!target) {24return false25}2627// const validWeapons = ['bow', 'crossbow', 'snowball', 'ender_pearl', 'egg', 'splash_potion']28const weapon = 'crossbow'2930// Auto attack every 1,2 secs with bow31// With crossbow attack when crossbow is charget (enchant 3 = 0.5s)32// ['snowball', 'ender_pearl', 'egg', 'splash_potion'] auto attack every 0,1 sec, no recommended use autoAttack for these items, instead use "bot.hawkEye.oneShot(target, weapon)"3334bot.hawkEye.autoAttack(target, weapon)35// If you force stop attack use:36// hawkEye.stop();3738// Use one shot time with calc:39// bot.hawkEye.oneShot(target, weapon);4041// If you want to shot in XYZ position:42/*43const blockPosition = {44position: {45x: 244.5,46y: 75.5,47z: -22048},49isValid: true // Fake to is "alive"50}51// bot.hawkEye.oneShot(blockPosition, weapon);52// bot.hawkEye.autoAttack(blockPosition);53*/54})5556bot.on('die', () => {57bot.hawkEye.stop()58})596061