mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 14:25:43 +02:00
sneaky skill improvements
This commit is contained in:
parent
af8dcccceb
commit
e0a3192b4c
2 changed files with 11 additions and 4 deletions
|
@ -306,8 +306,9 @@ export const actionsList = [
|
||||||
{
|
{
|
||||||
name: '!stay',
|
name: '!stay',
|
||||||
description: 'Stay in the current location no matter what. Pauses all modes.',
|
description: 'Stay in the current location no matter what. Pauses all modes.',
|
||||||
perform: wrapExecution(async (agent) => {
|
params: {'type': { type: 'int', description: 'The number of seconds to stay. -1 for forever.', domain: [-1, Number.MAX_SAFE_INTEGER] }},
|
||||||
await skills.stay(agent.bot);
|
perform: wrapExecution(async (agent, seconds) => {
|
||||||
|
await skills.stay(agent.bot, seconds);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -716,6 +716,9 @@ export async function equip(bot, itemName) {
|
||||||
else if (itemName.includes('chestplate') || itemName.includes('elytra')) {
|
else if (itemName.includes('chestplate') || itemName.includes('elytra')) {
|
||||||
await bot.equip(item, 'torso');
|
await bot.equip(item, 'torso');
|
||||||
}
|
}
|
||||||
|
else if (itemName.includes('shield')) {
|
||||||
|
await bot.equip(item, 'off-hand');
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
await bot.equip(item, 'hand');
|
await bot.equip(item, 'hand');
|
||||||
}
|
}
|
||||||
|
@ -1082,10 +1085,11 @@ export async function avoidEnemies(bot, distance=16) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function stay(bot) {
|
export async function stay(bot, seconds=30) {
|
||||||
/**
|
/**
|
||||||
* Stay in the current position until interrupted. Disables all modes.
|
* Stay in the current position until interrupted. Disables all modes.
|
||||||
* @param {MinecraftBot} bot, reference to the minecraft bot.
|
* @param {MinecraftBot} bot, reference to the minecraft bot.
|
||||||
|
* @param {number} seconds, the number of seconds to stay. Defaults to 30. -1 for indefinite.
|
||||||
* @returns {Promise<boolean>} true if the bot stayed, false otherwise.
|
* @returns {Promise<boolean>} true if the bot stayed, false otherwise.
|
||||||
* @example
|
* @example
|
||||||
* await skills.stay(bot);
|
* await skills.stay(bot);
|
||||||
|
@ -1097,9 +1101,11 @@ export async function stay(bot) {
|
||||||
bot.modes.pause('hunting');
|
bot.modes.pause('hunting');
|
||||||
bot.modes.pause('torch_placing');
|
bot.modes.pause('torch_placing');
|
||||||
bot.modes.pause('item_collecting');
|
bot.modes.pause('item_collecting');
|
||||||
while (!bot.interrupt_code) {
|
let start = Date.now();
|
||||||
|
while (!bot.interrupt_code && (seconds === -1 || Date.now() - start < seconds*1000)) {
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
}
|
}
|
||||||
|
log(bot, `Stayed for ${(Date.now() - start)/1000} seconds.`);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue