chore: initial commit

This commit is contained in:
2026-10-22 17:07:08 +08:00
commit 0acef64f48
200 changed files with 35546 additions and 0 deletions
+27
View File
@@ -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;
}
}
}