chore: load plugins
This commit is contained in:
@@ -4,15 +4,13 @@ import { useLogg } from '@guiiai/logg'
|
||||
import pathfinderModel from 'mineflayer-pathfinder'
|
||||
import { registerCommand } from '../composables/command'
|
||||
|
||||
const { goals, Movements, pathfinder } = pathfinderModel
|
||||
const { goals, Movements } = pathfinderModel
|
||||
|
||||
export function createFollowComponent(ctx: BotContext, config?: {
|
||||
rangeGoal: number
|
||||
}): ComponentLifecycle {
|
||||
const logger = useLogg('follow').useGlobalConfig()
|
||||
|
||||
ctx.bot.loadPlugin(pathfinder)
|
||||
|
||||
const state = {
|
||||
following: undefined as string | undefined,
|
||||
movements: new Movements(ctx.bot),
|
||||
|
||||
@@ -4,15 +4,12 @@ import { useLogg } from '@guiiai/logg'
|
||||
import pathfinderModel from 'mineflayer-pathfinder'
|
||||
import { registerCommand } from '../composables/command'
|
||||
|
||||
const { goals, Movements, pathfinder } = pathfinderModel
|
||||
const { goals, Movements } = pathfinderModel
|
||||
|
||||
export function createPathFinderComponent(ctx: BotContext, config?: {
|
||||
rangeGoal: number
|
||||
}): ComponentLifecycle {
|
||||
const logger = useLogg('pathfinder').useGlobalConfig()
|
||||
logger.log('Loading pathfinder plugin')
|
||||
|
||||
ctx.bot.loadPlugin(pathfinder)
|
||||
|
||||
let defaultMove: any
|
||||
|
||||
|
||||
@@ -3,6 +3,11 @@ import type { Action } from '../agents/actions'
|
||||
import type { BotInternalEventHandlers, BotInternalEvents } from './events'
|
||||
import { useLogg } from '@guiiai/logg'
|
||||
import mineflayer, { type Bot, type BotOptions } from 'mineflayer'
|
||||
import armorManager from 'mineflayer-armor-manager'
|
||||
import { loader as autoEat } from 'mineflayer-auto-eat'
|
||||
import { plugin as collectblock } from 'mineflayer-collectblock'
|
||||
import { pathfinder } from 'mineflayer-pathfinder'
|
||||
import { plugin as pvp } from 'mineflayer-pvp'
|
||||
|
||||
const logger = useLogg('bot').useGlobalConfig()
|
||||
|
||||
@@ -93,6 +98,17 @@ export function createBot(options: BotOptions): Bot {
|
||||
},
|
||||
}
|
||||
|
||||
logger.log('Loading plugins')
|
||||
ctx.bot.loadPlugin(pathfinder)
|
||||
ctx.bot.loadPlugin(pvp)
|
||||
ctx.bot.loadPlugin(collectblock)
|
||||
ctx.bot.loadPlugin(autoEat)
|
||||
ctx.bot.loadPlugin(armorManager) // auto equip armor
|
||||
ctx.bot.once('resourcePack', () => {
|
||||
ctx?.bot.acceptResourcePack()
|
||||
})
|
||||
logger.log('Plugins loaded')
|
||||
|
||||
ctx.bot.on('time', () => {
|
||||
if (!ctx)
|
||||
return
|
||||
|
||||
@@ -33,10 +33,7 @@ async function main() {
|
||||
|
||||
await initAgent(ctx)
|
||||
|
||||
const ticker = createTicker()
|
||||
ticker.on('tick', async ({ delta }) => {
|
||||
// logger.log(`Tick ${delta}ms`)
|
||||
})
|
||||
createTicker()
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
cleanup()
|
||||
|
||||
Reference in New Issue
Block a user