chore: initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import type {Bot} from '@wp2508/mineflayer';
|
||||
import type {BaseFunction, FunctionArgument} from '../../../types/bot/function/function.ts';
|
||||
|
||||
export class init implements BaseFunction<boolean[]> {
|
||||
readonly name = 'use_item';
|
||||
readonly i18n = {
|
||||
lang: 'zh-CN', name: '使用手持物品', description: '发起主手或副手物品的使用,不等待使用完成,也不自动停止持续使用',
|
||||
};
|
||||
readonly args: FunctionArgument[] = [{
|
||||
name: 'off_hand', type: 'boolean',
|
||||
i18n: {lang: 'zh-CN', name: '使用副手', description: 'false 使用主手,true 使用副手'},
|
||||
}];
|
||||
|
||||
async run(bot: Bot, args: boolean[]): Promise<boolean> {
|
||||
if (!Array.isArray(args) || args.length !== 1 || typeof args[0] !== 'boolean') return false;
|
||||
try {
|
||||
const off_hand = args[0];
|
||||
if (off_hand) {
|
||||
if (bot.supportFeature('doesntHaveOffHandSlot') || !bot.inventory?.slots[45]) return false;
|
||||
} else if (!bot.heldItem) return false;
|
||||
bot.activateItem(off_hand);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user