### Install and Build Submodule Dependencies (sh) Source: https://github.com/leo4life2/minepal/blob/main/README.md Navigates into the 'libs' directory, iterates through each subdirectory (submodule), installs its dependencies, and runs 'build' and 'prepare' scripts if they exist in the submodule's package.json. ```sh cd libs for dir in */; do cd "$dir" npm install if [ -f "package.json" ] && grep -q "\"build\"" "package.json"; then npm run build fi if [ -f "package.json" ] && grep -q "\"prepare\"" "package.json"; then npm run prepare fi cd .. done cd .. ``` -------------------------------- ### Run the MinePal App (npm) Source: https://github.com/leo4life2/minepal/blob/main/README.md Starts the MinePal application by executing the 'start' script defined in the root package.json, which typically launches the Electron app. ```sh npm start ``` -------------------------------- ### Install Project Dependencies (npm) Source: https://github.com/leo4life2/minepal/blob/main/README.md Installs the main project dependencies listed in the root package.json file using npm. ```sh npm install ``` -------------------------------- ### Install mineflayer-pathfinder Plugin Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Command to install the mineflayer-pathfinder plugin using npm. ```bash npm install mineflayer-pathfinder ``` -------------------------------- ### Basic Usage Example with Chat Command Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Demonstrates initializing a Mineflayer bot, loading the pathfinder plugin, setting up default movements, and using a chat command ('come') to pathfind to a player's location. ```javascript const mineflayer = require('mineflayer') const pathfinder = require('mineflayer-pathfinder').pathfinder const Movements = require('mineflayer-pathfinder').Movements const { GoalNear } = require('mineflayer-pathfinder').goals const bot = mineflayer.createBot({ username: 'Player' }) bot.loadPlugin(pathfinder) bot.once('spawn', () => { const defaultMove = new Movements(bot) bot.on('chat', function(username, message) { if (username === bot.username) return const target = bot.players[username] ? bot.players[username].entity : null if (message === 'come') { if (!target) { bot.chat('I don\'t see you !') return } const p = target.position bot.pathfinder.setMovements(defaultMove) bot.pathfinder.setGoal(new GoalNear(p.x, p.y, p.z, 1)) } }) }) ``` -------------------------------- ### Build Local App Version (npm) Source: https://github.com/leo4life2/minepal/blob/main/README.md Executes the 'buildLocal' script defined in the root package.json, typically used to build a local development or testing version of the Electron application. ```sh npm run buildLocal ``` -------------------------------- ### API: bot.pathfinder.getPathFromTo Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Returns a generator that computes a path from a starting position to a goal, allowing for incremental computation and various options. ```javascript bot.pathfinder.getPathFromTo* (movements, startPos, goal, options = {}) ``` -------------------------------- ### Create Near Block Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal representing a target block position (`x`, `y`, `z`) that the bot should pathfind to get within a specified `range` (radius) of. ```TypeScript new GoalNear(x: number, y: number, z: number, range: number) ``` -------------------------------- ### Create Near XZ Plane Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal useful for pathfinding near a target location when the exact Y level is unknown. The bot will pathfind to get within a specified `range` of the `x` and `z` coordinates, finding an appropriate Y level. ```TypeScript new GoalNearXZ(x: number, z: number, range: number) ``` -------------------------------- ### Define Abstract Goal Class - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Represents the base class for all pathfinder goals. It defines the required abstract methods (`heuristic`, `isEnd`) that concrete goal implementations must provide to guide the pathfinding algorithm. It also includes default implementations for optional methods (`isValid`, `hasChanged`). Do not instantiate this class directly. ```TypeScript abstract class Goal { abstract heuristic(node: any): number; abstract isEnd(node: any): boolean; isValid(): boolean { return true; } hasChanged(node: any): boolean { return false; } } ``` -------------------------------- ### API: bot.pathfinder.goto Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Initiates pathfinding to a specified goal, returning a Promise that resolves upon reaching the goal or rejects on error. ```javascript bot.pathfinder.goto(goal) ``` -------------------------------- ### Create Block Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal representing a single target block position (`x`, `y`, `z`) that the bot should pathfind to and stand inside at foot level. ```TypeScript new GoalBlock(x: number, y: number, z: number) ``` -------------------------------- ### Configuring mineflayer-pathfinder Movements in JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Demonstrates how to create a custom Movements instance, modify its properties (like disabling 1x1 towers and digging, adding scaffolding blocks), and assign it to the bot's pathfinder to customize movement behavior. This is typically done after the bot spawns. ```javascript const { Movements } = require('mineflayer-pathfinder') // Import the Movements class from pathfinder bot.once('spawn', () => { // A new movement instance for specific behavior const defaultMove = new Movements(bot) defaultMove.allow1by1towers = false // Do not build 1x1 towers when going up defaultMove.canDig = false // Disable breaking of blocks when pathing defaultMove.scafoldingBlocks.push(bot.registry.itemsByName['netherrack'].id) // Add nether rack to allowed scaffolding items bot.pathfinder.setMovements(defaultMove) // Update the movement instance pathfinder uses // Do pathfinder things // ... }) ``` -------------------------------- ### API: bot.pathfinder.setGoal Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Sets the current pathfinding goal for the bot, optionally making it dynamic. ```javascript bot.pathfinder.setGoal(Goal, dynamic) ``` -------------------------------- ### API: bot.pathfinder.getPathTo Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Computes a path to a goal using specified movements, with an optional timeout. ```javascript bot.pathfinder.getPathTo(movements, goal, timeout) ``` -------------------------------- ### Create Any Composite Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A composite goal that is satisfied if *any* of the provided sub-goals are met. The pathfinder will attempt to reach the easiest sub-goal. ```TypeScript new GoalCompositeAny(goals?: Goal[]) ``` -------------------------------- ### Create Follow Entity Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A goal to follow a specific `entity`, attempting to stay within a certain `range` of it. ```TypeScript new GoalFollow(entity: Entity, range: number) ``` -------------------------------- ### Create All Composite Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A composite goal that is satisfied only if *all* of the provided sub-goals are met. The pathfinder will attempt to satisfy all conditions. ```TypeScript new GoalCompositeAll(goals?: Goal[]) ``` -------------------------------- ### API: bot.pathfinder.bestHarvestTool Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Finds the most effective tool in the bot's inventory for harvesting a given block. ```javascript bot.pathfinder.bestHarvestTool(block) ``` -------------------------------- ### Create XZ Plane Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal useful for long-range pathfinding where a specific Y level is not required. The bot will pathfind to the specified `x` and `z` coordinates, finding an appropriate Y level automatically. ```TypeScript new GoalXZ(x: number, z: number) ``` -------------------------------- ### Create Y Level Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal to pathfind to a specific Y level. The bot will attempt to reach the specified `y` coordinate. ```TypeScript new GoalY(y: number) ``` -------------------------------- ### Create Adjacent Block Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A concrete goal to pathfind to a position directly adjacent to the target block at (`x`, `y`, `z`), rather than entering the block itself. Useful for interacting with blocks like chests. ```TypeScript new GoalGetToBlock(x: number, y: number, z: number) ``` -------------------------------- ### Define Step Exclusion Areas - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md An array of custom functions used to add extra cost to stepping on specific blocks. Each function receives a `Block` object and should return a non-negative number representing the cost; 100 indicates an impossible step. This allows dynamic exclusion or prioritization of blocks. ```TypeScript Array<(block: Block) => number> ``` -------------------------------- ### Configure Safe Walking Blocks - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md Defines a set of block IDs or types that the pathfinder considers safe to walk through, typically blocks with small collision boxes like carpets. This set is used internally by the pathfinding algorithm to determine traversable terrain. ```TypeScript Set ``` -------------------------------- ### Define Place Exclusion Areas - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md An array of custom functions used to add extra cost to placing blocks in specific locations during pathfinding. Each function receives the target `Block` (usually air or replaceable) and should return a non-negative number representing the cost; 100 indicates an impossible placement. This allows dynamic exclusion or prioritization of placement locations. ```TypeScript Array<(block: Block) => number> ``` -------------------------------- ### Create Inverted Goal - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A goal that inverts the condition of another goal. It is satisfied when the wrapped `goal` is *not* satisfied, and vice-versa. ```TypeScript new GoalInvert(goal: Goal) ``` -------------------------------- ### Define Break Exclusion Areas - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md An array of custom functions used to add extra cost to breaking specific blocks during pathfinding. Each function receives a `Block` object and should return a non-negative number representing the cost; 100 indicates an impossible break. This allows dynamic exclusion or prioritization of blocks for breaking. ```TypeScript Array<(block: Block) => number> ``` -------------------------------- ### Configure Fence Gate Opening - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A boolean flag to enable or disable the pathfinder's ability to open fence gates. Note that this feature is described as unreliable and potentially buggy. ```JavaScript false ``` -------------------------------- ### Track Entity Intersections - Pathfinder - JavaScript Source: https://github.com/leo4life2/minepal/blob/main/mineflayer-pathfinder/readme.md A dictionary mapping block coordinates ('x,y,z') to the number of entities intersecting that block's floor space. This is automatically updated before path generation but can be manually modified. It's used to add cost to paths that pass through entity-occupied blocks. ```TypeScript { [coord: string]: number } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.