mcraft-fun-mineflayer
Version:
Mineflayer viewer (connector) for mcraft.fun project and vanilla Minecraft client! Both TCP and WebSockets servers are supported.
86 lines (85 loc) • 2 kB
TypeScript
import type { Bot } from 'mineflayer';
import type { MineflayerPluginSettings } from './server';
import type { Client } from 'minecraft-protocol';
export declare const CHANNEL_NAME = "minecraft-web-client:data";
export declare const registerCustomChannel: (bot: Bot, options: MineflayerPluginSettings, getClients: () => Client[]) => {
send: (packet: CustomChannelPacketFromServer, client?: Client) => void;
receivedProcessor: (packet: CustomChannelPacketFromClient) => void;
registerChannel: (client: Client) => void;
newConnection: (client: Client) => void;
};
export type CustomChannelPacketFromClient = {
type: 'eval';
code: string;
} | {
type: 'method';
method: string;
args: any[];
} | {
type: 'ui';
id: string;
param: string;
value: number | string | boolean;
} | {
type: 'setControlState';
control: string;
value: boolean;
} | {
type: 'setLook';
yaw: number;
pitch: number;
};
export type UiLilDef = {
type: 'lil';
title?: string;
/** @default true */
opened?: boolean;
params: {
[key: string]: number | string | boolean;
};
buttons: string[];
};
export type UIDefinition = UiLilDef | {
type: 'text';
text: string;
x: number;
y: number;
/** @default false */
onTab?: boolean;
/** @default true */
motion?: boolean;
/** @default true */
formatted?: boolean;
/** @default false */
/** @default "" */
css?: string;
} | {
type: 'image';
url: string;
x: number;
y: number;
width?: number;
height?: number;
};
export type CustomChannelPacketFromServer = {
type: 'eval';
result: any;
isError: boolean;
} | {
type: 'method';
result: any;
} | {
type: 'stats';
botPing: number;
botUptime: number;
} | {
type: 'ui';
update: {
id: string;
data: UIDefinition | null;
};
} | {
type: 'console';
level: 'log' | 'warn' | 'error';
message: string;
};