mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-11 01:35:34 +02:00
merge with main
This commit is contained in:
commit
e0c43d5c90
5 changed files with 26 additions and 13 deletions
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
"name": "andy",
|
||||
"bio": "You are playing minecraft and assisting other players in tasks.",
|
||||
"memory": "",
|
||||
"turns": []
|
||||
}
|
|
@ -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();
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<num; i++) {
|
||||
await skills.craftRecipe(agent.bot, recipe_name);
|
||||
}
|
||||
await skills.craftRecipe(agent.bot, recipe_name, num);
|
||||
})
|
||||
},
|
||||
{
|
||||
name: '!smeltItem',
|
||||
description: 'Smelt the given item the given number of times.',
|
||||
params: {
|
||||
'item_name': '(string) The name of the input item to smelt.',
|
||||
'num': '(number) The number of times to smelt the item.'
|
||||
},
|
||||
perform: wrapExecution(async (agent, recipe_name, num) => {
|
||||
await skills.smeltItem(agent.bot, recipe_name, num);
|
||||
})
|
||||
},
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue