refactor(mover): 🔥 remove unused code + comments, minor fixes
Refactoring and fixing code. No major functionality change. Probably will have less bugs. - carry over how mcData is loaded - stop bot on unload - fix wrong magma block name
This commit is contained in:
parent
f2281a7cb3
commit
68e60921b1
|
@ -1,31 +1,26 @@
|
||||||
// import { EntityFilters } from "mineflayer-statemachine"
|
|
||||||
// import v from "vec3"
|
|
||||||
|
|
||||||
// import { Movements } from "mineflayer-pathfinder"
|
|
||||||
|
|
||||||
// const mineflayer = require('mineflayer')
|
|
||||||
const { Movements } = require('mineflayer-pathfinder')
|
const { Movements } = require('mineflayer-pathfinder')
|
||||||
// const { GoalBLah } = require('mineflayer-pathfinder').goals
|
|
||||||
const v = require('vec3')
|
const v = require('vec3')
|
||||||
|
|
||||||
let cfg = {}
|
let cfg = {}
|
||||||
let bot = {}
|
let bot = {}
|
||||||
// let moving
|
// let moving
|
||||||
let pathfinder
|
let pathfinder
|
||||||
|
let mcData
|
||||||
let movements = []
|
let movements = []
|
||||||
|
|
||||||
|
|
||||||
function initMoves(bot = bot, mcData = require('minecraft-data')(bot.version)) {
|
function initMoves(bot = bot, mcData = bot.mcData) {
|
||||||
console.info(movements)
|
console.info(movements)
|
||||||
if (movements.length > 0) {
|
if (movements.length > 0) {
|
||||||
bot.pathfinder.setMovements(defaultMove)
|
bot.pathfinder.setMovements(movements.defaultMove)
|
||||||
return console.warn("movements already initialized!")
|
return console.warn("movements already initialized!")
|
||||||
}
|
}
|
||||||
let defaultMove = new Movements(bot, mcData)
|
let defaultMove = new Movements(bot, mcData)
|
||||||
defaultMove.canDig = false
|
defaultMove.canDig = false
|
||||||
defaultMove.scafoldingBlocks.push(mcData.blocksByName.slime_block.id)
|
defaultMove.scafoldingBlocks.push(mcData.blocksByName.slime_block.id)
|
||||||
// defaultMove.blocksCantBreak.add(mcData.blocksByName.glass.id)
|
defaultMove.blocksCantBreak.add(mcData.blocksByName.glass.id)
|
||||||
// defaultMove.blocksToAvoid.add(mcData.blocksByName.magma.id)
|
defaultMove.blocksToAvoid.add(mcData.blocksByName.magma_block.id)
|
||||||
movements.push(defaultMove)
|
movements.push(defaultMove)
|
||||||
movements.defaultMove = movements[0]
|
movements.defaultMove = movements[0]
|
||||||
|
|
||||||
|
@ -46,8 +41,6 @@ function follow(entity, dynamic = true) {
|
||||||
console.assert(entity)
|
console.assert(entity)
|
||||||
const { GoalFollow } = require('mineflayer-pathfinder').goals
|
const { GoalFollow } = require('mineflayer-pathfinder').goals
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cfg.quiet && console.log(entity)
|
cfg.quiet && console.log(entity)
|
||||||
|| bot.chat(
|
|| bot.chat(
|
||||||
`following ${entity.type
|
`following ${entity.type
|
||||||
|
@ -83,19 +76,16 @@ const load = (config) => {
|
||||||
movements: []
|
movements: []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcData = bot.mcData || (bot.mcData = require('minecraft-data')(bot.version))
|
||||||
pathfinder = bot.pathfinder || bot.loadPlugin(require('mineflayer-pathfinder').pathfinder)
|
pathfinder = bot.pathfinder || bot.loadPlugin(require('mineflayer-pathfinder').pathfinder)
|
||||||
|
|
||||||
// initMoves(bot, mcData)
|
// initMoves(bot, mcData)
|
||||||
setTimeout(initMoves, 500, bot)
|
setTimeout(initMoves, 500, bot, mcData)
|
||||||
|
|
||||||
// bot.loadPlugin(pathfinder)
|
|
||||||
|
|
||||||
// bot.on('time', hello)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const unload = () => {
|
const unload = () => {
|
||||||
// TODO stop pathfinding maybe?
|
stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { load, unload, stop, initMoves, moveNear, follow }
|
module.exports = { load, unload, stop, initMoves, moveNear, follow }
|
Loading…
Reference in New Issue
Block a user