简体   繁体   中英

Mineflayer-pathfinder goto coordinates

I want to program that I can enter coordinates in the Minecraft chat and the bot will go to them. But I don't know how to program something like that? Can anyone help?

I am new to this field and would like to test something simple, but I just can't do it.

This is the code I try to use but it wont work:

var mineflayer = require('mineflayer')
const { pathfinder, Movements, GoalBlock } = require('mineflayer-pathfinder')
const pathfinder = require('mineflayer-pathfinder').pathfinder
const Movements = require('mineflayer-pathfinder').Movements
const { GoalNear } = require('mineflayer-pathfinder').goals
const inventoryViewer = require('mineflayer-web-inventory')

var bot = mineflayer.createBot({
  host: "localhost",   
  username: "MLGPlayer9",
  version: "1.18.1"
})

inventoryViewer(bot)

bot.loadPlugin(pathfinder)

function greeting() {
  bot.chat("Mooooooin");
}

bot.once("spawn", greeting);
 
function goto() {
  bot.pathfinder.goto(1, 1, 1);
  
}

bot.once("spawn", goto);

bot.pathfinder.setGoal(new GoalNear(1, 1, 1, 1)) The last one is for how close

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM