Simplify crafting, forever.
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)
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))()
It must be installed via a node package manager.
node: npm i mineflayer-crafting-util
yarn: yarn add mineflayer-crafting-util
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(wantedItem: Item): CraftingPlan
Parameter |
Type |
Description |
wantedItem |
Item |
The item to craft |
The static function provided is the same as bot.planCraft
.
Property |
Type |
Description |
id |
number |
The item id |
count |
number |
The item count |
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 |
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 |
Parameter |
Type |
Description |
item |
Item |
The item to craft |
opts |
CraftOptions |
The options for crafting |
Returns |
Type |
Description |
CraftingPlan |
CraftingPlan |
The crafting plan |