Files
bworld/common/mod_api/shared.ts
T
2026-09-24 23:28:01 -03:00

34 lines
742 B
TypeScript

// types every side of a mod shares. these are the api mods see, not the engine's own classes:
// items are { id, count, data } here, like on the network
export type Id = string;
export interface ItemStack {
readonly id: Id;
count: number;
// any json value, set by server scripts
data?: unknown;
}
export interface ModInfo {
readonly id: string;
readonly version: string;
}
export interface Position {
x: number;
y: number;
z: number;
}
export type Face = "west" | "east" | "bottom" | "top" | "north" | "south";
// KeyboardEvent.code values, like "KeyE" or "Digit1"
export type KeyCode = string;
export type Unsubscribe = () => void;
export interface EventSignal<T> {
subscribe(handler: (event: T) => void): Unsubscribe;
}