diff --git a/bots/andy/assist.json b/bots/andy/assist.json deleted file mode 100644 index 680b4be..0000000 --- a/bots/andy/assist.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "andy", - "bio": "You are playing minecraft and assisting other players in tasks.", - "memory": "", - "turns": [] -} \ No newline at end of file diff --git a/src/agent/agent.js b/src/agent/agent.js index 680bf93..1f14e88 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -174,9 +174,8 @@ export class Agent { console.log('Agent died: ', message); this.handleMessage('system', `You died with the final message: '${message}'. Previous actions were stopped and you have respawned. Notify the user and perform any necessary actions.`); } - }); - - this.bot.on('idle', async () => { + }) + this.bot.on('idle', () => { this.bot.modes.unPauseAll(); this.coder.executeResume(); }); diff --git a/src/agent/coder.js b/src/agent/coder.js index 68457ea..90e3c9d 100644 --- a/src/agent/coder.js +++ b/src/agent/coder.js @@ -146,12 +146,12 @@ export class Coder { } async executeResume(func=null, name=null, timeout=10) { - console.log('resuming code...') if (func != null) { this.resume_func = func; this.resume_name = name; } if (this.resume_func != null && this.agent.isIdle()) { + console.log('resuming code...') this.interruptible = true; let res = await this.execute(this.resume_func, timeout); this.interruptible = false; diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index c69baef..0b8943d 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -144,9 +144,18 @@ export const actionsList = [ 'num': '(number) The number of times to craft the recipe. This is NOT the number of output items, as it may craft many more items depending on the recipe.' }, perform: wrapExecution(async (agent, recipe_name, num) => { - for (let i=0; i { + await skills.smeltItem(agent.bot, recipe_name, num); }) }, { diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 4de3458..2c4be54 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -116,6 +116,7 @@ export async function smeltItem(bot, itemName, num=1) { return false; } // TODO: allow cobblestone, sand, clay, etc. + let placedFurnace = false; let furnaceBlock = undefined; furnaceBlock = world.getNearestBlock(bot, 'furnace', 6); if (!furnaceBlock){ @@ -125,6 +126,7 @@ export async function smeltItem(bot, itemName, num=1) { let pos = world.getNearestFreeSpace(bot, 1, 6); await placeBlock(bot, 'furnace', pos.x, pos.y, pos.z); furnaceBlock = world.getNearestBlock(bot, 'furnace', 6); + placedFurnace = true; } } if (!furnaceBlock){ @@ -141,12 +143,16 @@ export async function smeltItem(bot, itemName, num=1) { // TODO: check if furnace is currently burning fuel. furnace.fuel is always null, I think there is a bug. // This only checks if the furnace has an input item, but it may not be smelting it and should be cleared. log(bot, `The furnace is currently smelting ${mc.getItemName(input_item.type)}.`); + if (placedFurnace) + await collectBlock(bot, 'furnace', 1); return false; } // check if the bot has enough items to smelt let inv_counts = world.getInventoryCounts(bot); if (!inv_counts[itemName] || inv_counts[itemName] < num) { log(bot, `You do not have enough ${itemName} to smelt.`); + if (placedFurnace) + await collectBlock(bot, 'furnace', 1); return false; } @@ -156,6 +162,8 @@ export async function smeltItem(bot, itemName, num=1) { let put_fuel = Math.ceil(num / 8); if (!fuel || fuel.count < put_fuel) { log(bot, `You do not have enough coal or charcoal to smelt ${num} ${itemName}, you need ${put_fuel} coal or charcoal`); + if (placedFurnace) + await collectBlock(bot, 'furnace', 1); return false; } await furnace.putFuel(fuel.type, null, put_fuel); @@ -189,6 +197,9 @@ export async function smeltItem(bot, itemName, num=1) { } } + if (placedFurnace) { + await collectBlock(bot, 'furnace', 1); + } if (total === 0) { log(bot, `Failed to smelt ${itemName}.`); return false;