mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-04-22 06:02:07 +02:00
logs are smeltable, can use log/planks as fuel
This commit is contained in:
parent
da4987fd52
commit
43bf6c31cf
4 changed files with 57 additions and 22 deletions
|
@ -345,17 +345,17 @@ export const actionsList = [
|
||||||
return 'Self-prompting stopped.';
|
return 'Self-prompting stopped.';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
// { // commented for now, causes confusion with goal command
|
||||||
name: '!npcGoal',
|
// name: '!npcGoal',
|
||||||
description: 'Set a simple goal for an item or building to automatically work towards. Do not use for complex goals.',
|
// description: 'Set a simple goal for an item or building to automatically work towards. Do not use for complex goals.',
|
||||||
params: {
|
// params: {
|
||||||
'name': { type: 'string', description: 'The name of the goal to set. Can be item or building name. If empty will automatically choose a goal.' },
|
// 'name': { type: 'string', description: 'The name of the goal to set. Can be item or building name. If empty will automatically choose a goal.' },
|
||||||
'quantity': { type: 'int', description: 'The quantity of the goal to set. Default is 1.', domain: [1, Number.MAX_SAFE_INTEGER] }
|
// 'quantity': { type: 'int', description: 'The quantity of the goal to set. Default is 1.', domain: [1, Number.MAX_SAFE_INTEGER] }
|
||||||
},
|
// },
|
||||||
perform: async function (agent, name=null, quantity=1) {
|
// perform: async function (agent, name=null, quantity=1) {
|
||||||
await agent.npc.setGoal(name, quantity);
|
// await agent.npc.setGoal(name, quantity);
|
||||||
agent.bot.emit('idle'); // to trigger the goal
|
// agent.bot.emit('idle'); // to trigger the goal
|
||||||
return 'Set npc goal: ' + agent.npc.data.curr_goal.name;
|
// return 'Set npc goal: ' + agent.npc.data.curr_goal.name;
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
|
@ -212,7 +212,6 @@ export async function executeCommand(agent, message) {
|
||||||
if (parsed.args) {
|
if (parsed.args) {
|
||||||
numArgs = parsed.args.length;
|
numArgs = parsed.args.length;
|
||||||
}
|
}
|
||||||
console.log('parsed command:', parsed);
|
|
||||||
if (numArgs !== numParams(command))
|
if (numArgs !== numParams(command))
|
||||||
return `Command ${command.name} was given ${numArgs} args, but requires ${numParams(command)} args.`;
|
return `Command ${command.name} was given ${numArgs} args, but requires ${numParams(command)} args.`;
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -120,11 +120,11 @@ export async function smeltItem(bot, itemName, num=1) {
|
||||||
* await skills.smeltItem(bot, "raw_iron");
|
* await skills.smeltItem(bot, "raw_iron");
|
||||||
* await skills.smeltItem(bot, "beef");
|
* await skills.smeltItem(bot, "beef");
|
||||||
**/
|
**/
|
||||||
const foods = ['beef', 'chicken', 'cod', 'mutton', 'porkchop', 'rabbit', 'salmon', 'tropical_fish'];
|
|
||||||
if (!itemName.includes('raw') && !foods.includes(itemName)) {
|
if (!mc.isSmeltable(itemName)) {
|
||||||
log(bot, `Cannot smelt ${itemName}, must be a "raw" item, like "raw_iron".`);
|
log(bot, `Cannot smelt ${itemName}. Hint: make sure you are smelting the 'raw' item.`);
|
||||||
return false;
|
return false;
|
||||||
} // TODO: allow cobblestone, sand, clay, etc.
|
}
|
||||||
|
|
||||||
let placedFurnace = false;
|
let placedFurnace = false;
|
||||||
let furnaceBlock = undefined;
|
let furnaceBlock = undefined;
|
||||||
|
@ -173,10 +173,19 @@ export async function smeltItem(bot, itemName, num=1) {
|
||||||
|
|
||||||
// fuel the furnace
|
// fuel the furnace
|
||||||
if (!furnace.fuelItem()) {
|
if (!furnace.fuelItem()) {
|
||||||
let fuel = bot.inventory.items().find(item => item.name === 'coal' || item.name === 'charcoal');
|
let fuel = mc.getSmeltingFuel(bot);
|
||||||
let put_fuel = Math.ceil(num / 8);
|
if (!fuel) {
|
||||||
if (!fuel || fuel.count < put_fuel) {
|
log(bot, `You have no fuel to smelt ${num} ${itemName}, you need ${put_fuel} coal, charcoal, or wood.`);
|
||||||
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;
|
||||||
|
}
|
||||||
|
log(bot, `Using ${fuel.name} as fuel.`);
|
||||||
|
|
||||||
|
const put_fuel = Math.ceil(num / mc.getFuelSmeltOutput(fuel.name));
|
||||||
|
|
||||||
|
if (fuel.count < put_fuel) {
|
||||||
|
log(bot, `You don't have enough ${fuel.name} to smelt ${num} ${itemName}; you need ${put_fuel}.`);
|
||||||
if (placedFurnace)
|
if (placedFurnace)
|
||||||
await collectBlock(bot, 'furnace', 1);
|
await collectBlock(bot, 'furnace', 1);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -193,6 +193,33 @@ export function getItemCraftingRecipes(itemName) {
|
||||||
return recipes;
|
return recipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isSmeltable(itemName) {
|
||||||
|
const misc_smeltables = ['beef', 'chicken', 'cod', 'mutton', 'porkchop', 'rabbit', 'salmon', 'tropical_fish', 'potato', 'kelp', 'sand', 'cobblestone', 'clay_ball'];
|
||||||
|
return itemName.includes('raw') || itemName.includes('log') || misc_smeltables.includes(itemName);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSmeltingFuel(bot) {
|
||||||
|
let fuel = bot.inventory.items().find(i => i.name === 'coal' || i.name === 'charcoal')
|
||||||
|
if (fuel)
|
||||||
|
return fuel;
|
||||||
|
fuel = bot.inventory.items().find(i => i.name.includes('log') || i.name.includes('planks'))
|
||||||
|
if (fuel)
|
||||||
|
return fuel;
|
||||||
|
return bot.inventory.items().find(i => i.name === 'coal_block' || i.name === 'lava_bucket');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFuelSmeltOutput(fuelName) {
|
||||||
|
if (fuelName === 'coal' || fuelName === 'charcoal')
|
||||||
|
return 8;
|
||||||
|
if (fuelName.includes('log') || fuelName.includes('planks'))
|
||||||
|
return 1.5
|
||||||
|
if (fuelName === 'coal_block')
|
||||||
|
return 80;
|
||||||
|
if (fuelName === 'lava_bucket')
|
||||||
|
return 100;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
export function getItemSmeltingIngredient(itemName) {
|
export function getItemSmeltingIngredient(itemName) {
|
||||||
return {
|
return {
|
||||||
baked_potato: 'potato',
|
baked_potato: 'potato',
|
||||||
|
|
Loading…
Add table
Reference in a new issue