chore: initial commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import type {Bot} from '@wp2508/mineflayer';
|
||||
import type {BaseFunction, FunctionArgument} from '../../../types/bot/function/function.ts';
|
||||
|
||||
export class init implements BaseFunction<number[]> {
|
||||
readonly name = 'left_click_slot';
|
||||
readonly i18n = {
|
||||
lang: 'zh-CN', name: '左键点击槽位', description: '在当前窗口左键点击一个物品槽位,使用原生拾取、放置或合并行为',
|
||||
};
|
||||
readonly args: FunctionArgument[] = [{
|
||||
name: 'slot', type: 'number',
|
||||
i18n: {lang: 'zh-CN', name: '物品槽位', description: '当前窗口中的槽位编号'},
|
||||
}];
|
||||
|
||||
async run(bot: Bot, args: number[]): Promise<boolean> {
|
||||
const window = bot.currentWindow ?? bot.inventory;
|
||||
if (!window || !Array.isArray(args) || args.length !== 1 || !Number.isSafeInteger(args[0])
|
||||
|| args[0] < 0 || args[0] >= window.slots.length) return false;
|
||||
try {
|
||||
await bot.clickWindow(args[0], 0, 0);
|
||||
return (bot.currentWindow ?? bot.inventory) === window;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user