handle equipped armor fo inventory

This commit is contained in:
MaxRobinsonTheGreat 2024-10-15 17:04:19 -05:00
parent cc6fc66be2
commit ce5faa94aa
2 changed files with 20 additions and 2 deletions

View file

@ -66,6 +66,23 @@ export const queryList = [
else if (agent.bot.game.gameMode === 'creative') {
res += '\n(You have infinite items in creative mode. You do not need to gather resources!!)';
}
let helmet = bot.inventory.slots[5];
let chestplate = bot.inventory.slots[6];
let leggings = bot.inventory.slots[7];
let boots = bot.inventory.slots[8];
res += '\nWEARING: ';
if (helmet)
res += `\nHead: ${helmet.name}`;
if (chestplate)
res += `\nTorso: ${chestplate.name}`;
if (leggings)
res += `\nLegs: ${leggings.name}`;
if (boots)
res += `\nFeet: ${boots.name}`;
if (!helmet && !chestplate && !leggings && !boots)
res += 'None';
return pad(res);
}
},

View file

@ -673,7 +673,7 @@ export async function equip(bot, itemName) {
* @example
* await skills.equip(bot, "iron_pickaxe");
**/
let item = bot.inventory.items().find(item => item.name === itemName);
let item = bot.inventory.slots.find(slot => slot && slot.name === itemName);
if (!item) {
log(bot, `You do not have any ${itemName} to equip.`);
return false;
@ -687,12 +687,13 @@ export async function equip(bot, itemName) {
else if (itemName.includes('helmet')) {
await bot.equip(item, 'head');
}
else if (itemName.includes('chestplate')) {
else if (itemName.includes('chestplate') || itemName.includes('elytra')) {
await bot.equip(item, 'torso');
}
else {
await bot.equip(item, 'hand');
}
log(bot, `Equipped ${itemName}.`);
return true;
}