Merge pull request #270 from JurassikLizard/contrib

Add recipe item hints to craftRecipe in skills.js
This commit is contained in:
Max Robinson 2024-11-02 13:20:27 -05:00 committed by GitHub
commit 8e562efece
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,6 +43,11 @@ export async function craftRecipe(bot, itemName, num=1) {
**/
let placedTable = false;
if (mc.getItemCraftingRecipes(itemName).length == 0) {
log(bot, `${itemName} is either not an item, or it does not have a crafting recipe!`);
return false;
}
// get recipes that don't require a crafting table
let recipes = bot.recipesFor(mc.getItemId(itemName), null, 1, null);
let craftingTable = null;
@ -76,7 +81,7 @@ export async function craftRecipe(bot, itemName, num=1) {
}
}
if (!recipes || recipes.length === 0) {
log(bot, `You do not have the resources to craft a ${itemName}.`);
log(bot, `You do not have the resources to craft a ${itemName}. It requires: ${Object.entries(mc.getItemCraftingRecipes(itemName)[0]).map(([key, value]) => `${key}: ${value}`).join(', ')}.`);
if (placedTable) {
await collectBlock(bot, 'crafting_table', 1);
}