Skip to content

Latest commit

 

History

History
111 lines (78 loc) · 3.05 KB

README.md

File metadata and controls

111 lines (78 loc) · 3.05 KB

mineflayer-crafting-util

Simplify crafting, forever.

Bot example usage

const mineflayer = require("mineflayer")

const crafter = require("mineflayer-crafting-util").plugin

const bot = mineflayer.createBot({
    host: "localhost", // optional
    port: 25565,       // optional
    username: "bot"
})


bot.loadPlugin(crafter)


const sticks = {id: bot.registry.itemsByName.stick.id, count: 1}
const plan = bot.planCraft(sticks)    

Static usage

const mcVersion = "1.18.2"

async function main(mcVersion: string) {

  const mcData = require("minecraft-data")(mcVersion)
  const crafter = await require("mineflayer-crafting-util").buildStatic(mcVersion) // buildStatic is async

  const sticks = {id: mcData.itemsByName.stick.id, count: 1}
  const plan = crafter(sticks)

}

(async () => main(mcVersion))()

Installation

It must be installed via a node package manager. node: npm i mineflayer-crafting-util yarn: yarn add mineflayer-crafting-util

API

Functions

Bot Functions

bot.planCraft

bot.planCraft(item: Item, opts?: CraftOptions): CraftingPlan
Parameter Type Description
item Item the type and count of item to craft
opts CraftOptions The options for crafting

bot.planCraftInventory

bot.planCraftInventory(wantedItem: Item): CraftingPlan
Parameter Type Description
wantedItem Item The item to craft

Static Functions

The static function provided is the same as bot.planCraft.

Types

Item

Property Type Description
id number The item id
count number The item count

CraftingPlan

Property Type Description
success boolean Whether the crafting plan was successful
itemsRequired Item[] The items required to craft the item
recipesToDo Array<{ recipeApplications: number; recipe: Recipe }> The recipes to craft the item

CraftOptions

Property Type Default Description
availableItems Item[] The items available to the bot
careAboutExisting boolean false Whether to care about existing items
includeRecursion boolean false Whether to include recursion
multipleRecipes boolean false Whether to include multiple recipes

CraftingFunc

Parameter Type Description
item Item The item to craft
opts CraftOptions The options for crafting
Returns Type Description
CraftingPlan CraftingPlan The crafting plan