我在制作雷人机器人,他跟着我,想杀了我,所以当我远离他的时候,他就停止跟踪我,他还有其他的问题,比如当他架桥的时候,他摔倒的时候很蠢,所以我怎么能让他在他遵循我的代码的时候让他冲刺:
const { versions } = require('minecraft-data')
const MinecraftData = require('minecraft-data')
const mineflayer = require('mineflayer')
const { pathfinder, Movements, goals } = require('mineflayer-pathfinder')
const GoalFollow = goals.GoalFollow
const pvp = require('mineflayer-pvp').plugin
const armorM = require('mineflayer-armor-manager')
const bot = mineflayer.createBot({
host: 'EventWG.aternos.me',
username: 'bot'
})
//Follow the player
function followPlayer() {
bot.on('chat', (namee, msgg)=>{
const player = bot.players[namee]
if (msgg == "attack") {
bot.chat("ok " + namee)
bot.chat("/effect give @p minecraft:resistance 111111 255")
if (!player || !player.entity){
bot.chat("I can't see you " + namee)
return
}
const data = require('minecraft-data')(bot.version)
const movements = new Movements(bot, data)
bot.pathfinder.setMovements(movements)
const goal = new GoalFollow(player.entity, 2)
bot.pathfinder.setGoal(goal, true)
setInterval(() => {
const playerFilter = p => p.type === "player"
const playerr = bot.nearestEntity(playerFilter)
bot.pvp.attack(player.entity)
const sword = bot.inventory.items().find(item => item.name.includes('sword'))
if(sword) bot.equip(sword, "hand")
}, 2000);
}
})
}
bot.on('spawn', lookAtPlayer)
bot.on('spawn', followPlayer)发布于 2022-09-14 02:57:21
您可以简单地使用bot.setControlState,就像
bot.setControlState('sprint', true);https://stackoverflow.com/questions/73352764
复制相似问题