| // Craft 8 oak_planks from 2 oak_log (do the recipe 2 times): craftItem(bot, "oak_planks", 2); | |
| // You must place a crafting table before calling this function | |
| async function craftItem(bot, name, count = 1) { | |
| const item = mcData.itemsByName[name]; | |
| const craftingTable = bot.findBlock({ | |
| matching: mcData.blocksByName.crafting_table.id, | |
| maxDistance: 32, | |
| }); | |
| await bot.pathfinder.goto( | |
| new GoalLookAtBlock(craftingTable.position, bot.world) | |
| ); | |
| const recipe = bot.recipesFor(item.id, null, 1, craftingTable)[0]; | |
| await bot.craft(recipe, count, craftingTable); | |
| } | |