kustom-mc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +809 -0
- package/dist/commands/build.d.ts +2 -0
- package/dist/commands/build.js +447 -0
- package/dist/commands/bundle.d.ts +2 -0
- package/dist/commands/bundle.js +134 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +219 -0
- package/dist/commands/list.d.ts +10 -0
- package/dist/commands/list.js +167 -0
- package/dist/commands/login.d.ts +9 -0
- package/dist/commands/login.js +167 -0
- package/dist/commands/new.d.ts +2 -0
- package/dist/commands/new.js +132 -0
- package/dist/commands/prepare.d.ts +9 -0
- package/dist/commands/prepare.js +267 -0
- package/dist/commands/push.d.ts +9 -0
- package/dist/commands/push.js +205 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +191 -0
- package/dist/compiler/async-transform.d.ts +21 -0
- package/dist/compiler/async-transform.js +158 -0
- package/dist/compiler/inline.d.ts +32 -0
- package/dist/compiler/inline.js +87 -0
- package/dist/compiler/postprocess.d.ts +19 -0
- package/dist/compiler/postprocess.js +134 -0
- package/dist/compiler/rhino-plugin.d.ts +17 -0
- package/dist/compiler/rhino-plugin.js +324 -0
- package/dist/compiler/transform.d.ts +18 -0
- package/dist/compiler/transform.js +59 -0
- package/dist/config.d.ts +86 -0
- package/dist/config.js +166 -0
- package/dist/credentials.d.ts +65 -0
- package/dist/credentials.js +136 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +28 -0
- package/dist/runtime.d.ts +116 -0
- package/dist/runtime.js +96 -0
- package/dist/types/globals.d.ts +80 -0
- package/dist/types/globals.js +10 -0
- package/dist/types/index.d.ts +2094 -0
- package/dist/types/index.js +9 -0
- package/package.json +57 -0
- package/templates/project/kustom.config.json +26 -0
- package/templates/project/scripts/example.ts +17 -0
- package/templates/project/scripts/lib/utils.ts +19 -0
- package/templates/project/tsconfig.json +27 -0
- package/templates/scripts/block.ts.hbs +14 -0
- package/templates/scripts/gui.ts.hbs +28 -0
- package/templates/scripts/item.ts.hbs +13 -0
- package/templates/scripts/script.ts.hbs +18 -0
|
@@ -0,0 +1,2094 @@
|
|
|
1
|
+
import './globals.js';
|
|
2
|
+
/**
|
|
3
|
+
* A fully qualified namespaced identifier.
|
|
4
|
+
* Format: packId:type/name (e.g., "mypack:item/sword")
|
|
5
|
+
*
|
|
6
|
+
* Used to uniquely identify resources across different packs.
|
|
7
|
+
*/
|
|
8
|
+
export interface NamespacedId {
|
|
9
|
+
/** The pack ID (e.g., "mypack") */
|
|
10
|
+
readonly packId: string;
|
|
11
|
+
/** The resource type (e.g., "script", "item", "block") */
|
|
12
|
+
readonly type: string;
|
|
13
|
+
/** The resource name (e.g., "sword", "main") */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse a namespaced ID string into its components.
|
|
18
|
+
* Returns null if the string is not a valid namespaced ID.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const id = parseNamespacedId("mypack:item/sword");
|
|
23
|
+
* // { packId: "mypack", type: "item", name: "sword" }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseNamespacedId(fullId: string): NamespacedId | null;
|
|
27
|
+
/**
|
|
28
|
+
* Check if a string is a fully qualified namespaced ID.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* isNamespacedId("mypack:item/sword"); // true
|
|
33
|
+
* isNamespacedId("sword"); // false
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function isNamespacedId(id: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Create a fully qualified namespaced ID string.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* createNamespacedId("mypack", "item", "sword"); // "mypack:item/sword"
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createNamespacedId(packId: string, type: string, name: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Cross-pack import information.
|
|
48
|
+
* Returned when parsing a cross-pack import path.
|
|
49
|
+
*/
|
|
50
|
+
export interface CrossPackImport {
|
|
51
|
+
/** The pack ID being imported from */
|
|
52
|
+
readonly packId: string;
|
|
53
|
+
/** The path within the pack */
|
|
54
|
+
readonly path: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Check if an import path is a cross-pack import.
|
|
58
|
+
* Cross-pack imports use the format: packId:path
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* isCrossPackImport("core-pack:scripts/utils"); // true
|
|
63
|
+
* isCrossPackImport("./utils"); // false
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function isCrossPackImport(importPath: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Parse a cross-pack import path.
|
|
69
|
+
* Returns null if not a valid cross-pack import.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* parseCrossPackImport("core-pack:scripts/utils");
|
|
74
|
+
* // { packId: "core-pack", path: "scripts/utils" }
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseCrossPackImport(importPath: string): CrossPackImport | null;
|
|
78
|
+
/**
|
|
79
|
+
* Event schema for typed events.
|
|
80
|
+
* Define events with Props types, just like props.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* events: {
|
|
85
|
+
* onSuccess: Props.Boolean(),
|
|
86
|
+
* onError: Props.String(),
|
|
87
|
+
* onProgress: Props.Number(),
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export type EventSchema = Record<string, PropAPI>;
|
|
92
|
+
/**
|
|
93
|
+
* Empty event schema marker for scripts without events.
|
|
94
|
+
*/
|
|
95
|
+
export type EmptyEventSchema = Record<string, never>;
|
|
96
|
+
/**
|
|
97
|
+
* Infer the event payload type from an EventSchema.
|
|
98
|
+
*/
|
|
99
|
+
export type InferEventPayload<E extends EventSchema, K extends keyof E> = InferPropType<E[K]>;
|
|
100
|
+
export interface ScriptConfig<P extends PropSchema, E extends EventSchema = EmptyEventSchema> {
|
|
101
|
+
/** Props schema with types and defaults */
|
|
102
|
+
props?: P;
|
|
103
|
+
/**
|
|
104
|
+
* Events schema with typed payloads.
|
|
105
|
+
* Define events that this script can emit to parent processes.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* events: {
|
|
110
|
+
* onSuccess: Props.Boolean(),
|
|
111
|
+
* onUnlock: Props.String(),
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
events?: E;
|
|
116
|
+
/**
|
|
117
|
+
* Script entry point.
|
|
118
|
+
* The `this` context is the McModuleAPI (process), allowing direct access to:
|
|
119
|
+
* - this.exit(value) - Exit the script with a return value
|
|
120
|
+
* - this.emit(event, ...args) - Emit events to parent process
|
|
121
|
+
* - this.getPlayer(name) - Get a player by name
|
|
122
|
+
*
|
|
123
|
+
* @param ctx Script context with props, executor, and subsystems
|
|
124
|
+
*/
|
|
125
|
+
run: (this: TypedMcModuleAPI<E>, ctx: ScriptContext<InferProps<P>, E>) => void;
|
|
126
|
+
}
|
|
127
|
+
export interface ScriptDefinition<P extends PropSchema, E extends EventSchema = EmptyEventSchema> {
|
|
128
|
+
props?: P;
|
|
129
|
+
events?: E;
|
|
130
|
+
/** Internal run function - called by Java runtime with process context */
|
|
131
|
+
readonly __run: (this: TypedMcModuleAPI<E>, ctx: ScriptContext<InferProps<P>, E>) => void;
|
|
132
|
+
/** Internal type marker - set by defineScript */
|
|
133
|
+
readonly __type: "script";
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Exported script type - what defineScript() returns.
|
|
137
|
+
* Combines the definition metadata with a callable run() method for imports.
|
|
138
|
+
*
|
|
139
|
+
* When a script is imported, it has:
|
|
140
|
+
* - props/events schemas for type inference
|
|
141
|
+
* - run(props) method that creates a new process
|
|
142
|
+
*/
|
|
143
|
+
export type ExportedScript<P extends PropSchema, E extends EventSchema = EmptyEventSchema> = Omit<ScriptDefinition<P, E>, '__run'> & ScriptModule<P, E>;
|
|
144
|
+
export interface BlockConfig {
|
|
145
|
+
/** Unique identifier for the block (e.g., "tower", "custom_chair") */
|
|
146
|
+
id: string;
|
|
147
|
+
/** Model path (e.g., "kustom:block/tower") or BetterModel ID */
|
|
148
|
+
model: string;
|
|
149
|
+
/** Collision type: "full" (1x1x1), "slab" (half), "none", or custom dimensions */
|
|
150
|
+
collision?: "full" | "slab" | "none" | CollisionConfig;
|
|
151
|
+
/** Auto-generate placement item for this block */
|
|
152
|
+
autoPlace?: boolean;
|
|
153
|
+
/** Called when a player clicks the block */
|
|
154
|
+
onClick?: (event: BlockClickEvent) => void;
|
|
155
|
+
/** Called when the block is broken. Return false to prevent breaking. */
|
|
156
|
+
onBreak?: (event: BlockBreakEvent) => boolean | void;
|
|
157
|
+
/** Called when the block is placed */
|
|
158
|
+
onPlace?: (event: BlockPlaceEvent) => void;
|
|
159
|
+
}
|
|
160
|
+
export interface BlockDefinition extends BlockConfig {
|
|
161
|
+
readonly __type: "block";
|
|
162
|
+
}
|
|
163
|
+
export interface CollisionConfig {
|
|
164
|
+
/** Width in blocks (X axis) */
|
|
165
|
+
width: number;
|
|
166
|
+
/** Height in blocks (Y axis) */
|
|
167
|
+
height: number;
|
|
168
|
+
/** Depth in blocks (Z axis) */
|
|
169
|
+
depth: number;
|
|
170
|
+
/** Corner offset X */
|
|
171
|
+
cornerX?: number;
|
|
172
|
+
/** Corner offset Y */
|
|
173
|
+
cornerY?: number;
|
|
174
|
+
/** Corner offset Z */
|
|
175
|
+
cornerZ?: number;
|
|
176
|
+
}
|
|
177
|
+
export interface BlockClickEvent {
|
|
178
|
+
/** The block instance that was clicked */
|
|
179
|
+
readonly instance: ShaperBlockInstance;
|
|
180
|
+
/** The player who clicked */
|
|
181
|
+
readonly player: ScriptablePlayer;
|
|
182
|
+
/** Collision hit information, if available */
|
|
183
|
+
readonly collisionInfo: ScriptableCollisionInfo | null;
|
|
184
|
+
/** Cancel the click event */
|
|
185
|
+
cancel(): void;
|
|
186
|
+
/** Check if the event is cancelled */
|
|
187
|
+
isCancelled(): boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface BlockBreakEvent {
|
|
190
|
+
/** The block instance being broken */
|
|
191
|
+
readonly instance: ShaperBlockInstance;
|
|
192
|
+
/** The player breaking the block (null for non-player causes) */
|
|
193
|
+
readonly player: ScriptablePlayer | null;
|
|
194
|
+
/** Collision hit information, if available */
|
|
195
|
+
readonly collisionInfo: ScriptableCollisionInfo | null;
|
|
196
|
+
/** Cancel the break event */
|
|
197
|
+
cancel(): void;
|
|
198
|
+
/** Check if the event is cancelled */
|
|
199
|
+
isCancelled(): boolean;
|
|
200
|
+
}
|
|
201
|
+
export interface BlockPlaceEvent {
|
|
202
|
+
/** The newly placed block instance */
|
|
203
|
+
readonly instance: ShaperBlockInstance;
|
|
204
|
+
/** The location where the block was placed */
|
|
205
|
+
readonly location: ScriptableLocation;
|
|
206
|
+
/** The player who placed the block (null for non-player placement) */
|
|
207
|
+
readonly player: ScriptablePlayer | null;
|
|
208
|
+
/** Cancel the place event */
|
|
209
|
+
cancel(): void;
|
|
210
|
+
/** Check if the event is cancelled */
|
|
211
|
+
isCancelled(): boolean;
|
|
212
|
+
}
|
|
213
|
+
export interface ItemConfig {
|
|
214
|
+
/** Unique identifier for the item (e.g., "magic_wand") */
|
|
215
|
+
id: string;
|
|
216
|
+
/** Base material (e.g., "STICK", "DIAMOND_SWORD") */
|
|
217
|
+
material: string;
|
|
218
|
+
/** Model path (e.g., "kustom:item/magic_wand") */
|
|
219
|
+
model: string;
|
|
220
|
+
/** Display name with MiniMessage formatting (e.g., "<gold>Magic Wand") */
|
|
221
|
+
displayName?: string;
|
|
222
|
+
/** Item description/lore */
|
|
223
|
+
description?: string;
|
|
224
|
+
/** Hide from creative menu / give commands */
|
|
225
|
+
hidden?: boolean;
|
|
226
|
+
/** Block ID this item places when right-clicked */
|
|
227
|
+
placesBlock?: string;
|
|
228
|
+
/** Called when right-clicking with the item */
|
|
229
|
+
onRightClick?: (event: ItemInteractEvent) => void;
|
|
230
|
+
/** Called when left-clicking with the item */
|
|
231
|
+
onLeftClick?: (event: ItemInteractEvent) => void;
|
|
232
|
+
/** Called when the item is dropped */
|
|
233
|
+
onDrop?: (event: ItemDropEvent) => void;
|
|
234
|
+
/** Called when the item is picked up */
|
|
235
|
+
onPickup?: (event: ItemPickupEvent) => void;
|
|
236
|
+
/** Called when the item is consumed (food/potion) */
|
|
237
|
+
onConsume?: (event: ItemConsumeEvent) => void;
|
|
238
|
+
/** Called when damaging an entity with the item */
|
|
239
|
+
onDamageEntity?: (event: ItemDamageEntityEvent) => void;
|
|
240
|
+
/** Called when shooting a bow/crossbow */
|
|
241
|
+
onShootBow?: (event: ItemShootBowEvent) => void;
|
|
242
|
+
/** Called when the item is selected in hotbar */
|
|
243
|
+
onHoldStart?: (event: ItemHoldEvent) => void;
|
|
244
|
+
/** Called when the item is deselected from hotbar */
|
|
245
|
+
onHoldEnd?: (event: ItemHoldEvent) => void;
|
|
246
|
+
/** Called when swapping item between hands */
|
|
247
|
+
onSwapHand?: (event: ItemSwapHandEvent) => void;
|
|
248
|
+
/** Called when item durability changes */
|
|
249
|
+
onDurabilityChange?: (event: ItemDurabilityEvent) => void;
|
|
250
|
+
/** Called when the item breaks from durability */
|
|
251
|
+
onBreak?: (event: ItemBreakEvent) => void;
|
|
252
|
+
/** Called when interacting with an entity */
|
|
253
|
+
onInteractEntity?: (event: ItemEntityInteractEvent) => void;
|
|
254
|
+
/** Called when breaking a block with the item */
|
|
255
|
+
onBlockBreak?: (event: ItemBlockBreakEvent) => void;
|
|
256
|
+
/** Called when placing a block with the item */
|
|
257
|
+
onBlockPlace?: (event: ItemBlockPlaceEvent) => void;
|
|
258
|
+
}
|
|
259
|
+
export interface ItemDefinition extends ItemConfig {
|
|
260
|
+
readonly __type: "item";
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Context passed to script run function.
|
|
264
|
+
* Contains all APIs and subsystems available to scripts.
|
|
265
|
+
*/
|
|
266
|
+
export interface ScriptContext<P = Record<string, unknown>, E extends EventSchema = EmptyEventSchema> {
|
|
267
|
+
/** Process API for script management (typed for events if declared) */
|
|
268
|
+
process: TypedMcModuleAPI<E>;
|
|
269
|
+
/** Validated props */
|
|
270
|
+
props: P;
|
|
271
|
+
/** Who executed this script */
|
|
272
|
+
executor: ProcessExecutorAPI;
|
|
273
|
+
/** Camera system for cinematic views */
|
|
274
|
+
camera: CameraAPI;
|
|
275
|
+
/** Chat session system */
|
|
276
|
+
session: SessionAPI;
|
|
277
|
+
/** Chat GUI system */
|
|
278
|
+
chatGUI: ChatGUIAPI;
|
|
279
|
+
/** Command registration system */
|
|
280
|
+
command: CommandManager;
|
|
281
|
+
/** BetterModel entity system */
|
|
282
|
+
entity: BetterModelEntityAPI;
|
|
283
|
+
/** Shaper (custom block) system */
|
|
284
|
+
shaper: ShaperAPI;
|
|
285
|
+
/** Custom item system */
|
|
286
|
+
items: ItemAPI;
|
|
287
|
+
/** Model definition builder */
|
|
288
|
+
definition: DefinitionBuilder;
|
|
289
|
+
/** Persistent storage system */
|
|
290
|
+
storage: StorageAPI;
|
|
291
|
+
}
|
|
292
|
+
export interface PropSchema {
|
|
293
|
+
[key: string]: PropAPI;
|
|
294
|
+
}
|
|
295
|
+
export interface StringPropAPI {
|
|
296
|
+
readonly __brand: 'StringPropAPI';
|
|
297
|
+
readonly defaultValue?: string;
|
|
298
|
+
}
|
|
299
|
+
export interface NumberPropAPI {
|
|
300
|
+
readonly __brand: 'NumberPropAPI';
|
|
301
|
+
readonly defaultValue?: number;
|
|
302
|
+
}
|
|
303
|
+
export interface BooleanPropAPI {
|
|
304
|
+
readonly __brand: 'BooleanPropAPI';
|
|
305
|
+
readonly defaultValue?: boolean;
|
|
306
|
+
}
|
|
307
|
+
export interface ObjectPropAPI {
|
|
308
|
+
readonly __brand: 'ObjectPropAPI';
|
|
309
|
+
readonly defaultValue?: object;
|
|
310
|
+
}
|
|
311
|
+
export interface ArrayPropAPI {
|
|
312
|
+
readonly __brand: 'ArrayPropAPI';
|
|
313
|
+
readonly defaultValue?: unknown[];
|
|
314
|
+
}
|
|
315
|
+
export interface UnionPropAPI<T = unknown> {
|
|
316
|
+
readonly __brand: 'UnionPropAPI';
|
|
317
|
+
readonly defaultValue?: T;
|
|
318
|
+
}
|
|
319
|
+
export interface GenericPropAPI<T = unknown> {
|
|
320
|
+
readonly __brand: 'GenericPropAPI';
|
|
321
|
+
readonly defaultValue?: T;
|
|
322
|
+
}
|
|
323
|
+
/** Base PropAPI type - union of all specific prop types */
|
|
324
|
+
export type PropAPI = StringPropAPI | NumberPropAPI | BooleanPropAPI | ObjectPropAPI | ArrayPropAPI | UnionPropAPI | GenericPropAPI;
|
|
325
|
+
export type InferProps<P extends PropSchema> = {
|
|
326
|
+
[K in keyof P]: InferPropType<P[K]>;
|
|
327
|
+
};
|
|
328
|
+
/**
|
|
329
|
+
* Infer the actual type from a PropAPI definition.
|
|
330
|
+
* Used for both props and events.
|
|
331
|
+
*/
|
|
332
|
+
export type InferPropType<T> = T extends StringPropAPI ? string : T extends NumberPropAPI ? number : T extends BooleanPropAPI ? boolean : T extends ObjectPropAPI ? object : T extends ArrayPropAPI ? unknown[] : T extends UnionPropAPI<infer U> ? U : T extends GenericPropAPI<infer U> ? U : unknown;
|
|
333
|
+
export interface ScreenConstructor {
|
|
334
|
+
/** Create a screen with vanilla background (no custom texture) */
|
|
335
|
+
new (size: number, options?: ScreenOptions): Screen;
|
|
336
|
+
/** Create a screen with custom texture */
|
|
337
|
+
new (texture: string, size: number, options?: ScreenOptions): Screen;
|
|
338
|
+
}
|
|
339
|
+
export interface ElementFactory {
|
|
340
|
+
item(item: ScriptableItem): Element;
|
|
341
|
+
button(texture: string, title: string | null): Element;
|
|
342
|
+
display(texture: string): Element;
|
|
343
|
+
/** Create a content slot that accepts player items */
|
|
344
|
+
contentSlot(): Element;
|
|
345
|
+
/** Create a content slot with a placeholder texture */
|
|
346
|
+
contentSlotWithPlaceholder(placeholderTexture: string): Element;
|
|
347
|
+
}
|
|
348
|
+
export interface ScriptableLocationFactory {
|
|
349
|
+
create(x: number, y: number, z: number, worldName: string): ScriptableLocation;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Screen constructor - create new screens for GUIs.
|
|
353
|
+
* Actual value is injected by Java at runtime.
|
|
354
|
+
* Build system strips imports, resolving to Java-injected global.
|
|
355
|
+
*/
|
|
356
|
+
export declare const Screen: ScreenConstructor;
|
|
357
|
+
/**
|
|
358
|
+
* Container constructor - create child containers within screens.
|
|
359
|
+
* Actual value is injected by Java at runtime.
|
|
360
|
+
*/
|
|
361
|
+
export declare const Container: ContainerConstructor;
|
|
362
|
+
/**
|
|
363
|
+
* Element factory - create GUI elements (buttons, items, slots).
|
|
364
|
+
* Actual value is injected by Java at runtime.
|
|
365
|
+
*/
|
|
366
|
+
export declare const Element: ElementFactory;
|
|
367
|
+
/**
|
|
368
|
+
* Props factory - create property type definitions for scripts.
|
|
369
|
+
* Actual value is injected by Java at runtime.
|
|
370
|
+
*/
|
|
371
|
+
export declare const Props: PropsAPI;
|
|
372
|
+
/**
|
|
373
|
+
* CellState utility - slot state management constants and helpers.
|
|
374
|
+
* Actual value is injected by Java at runtime.
|
|
375
|
+
*/
|
|
376
|
+
export declare const CellState: CellStateUtils;
|
|
377
|
+
/**
|
|
378
|
+
* ScriptableLocation factory - create location objects.
|
|
379
|
+
* Actual value is injected by Java at runtime.
|
|
380
|
+
*/
|
|
381
|
+
export declare const ScriptableLocation: ScriptableLocationFactory;
|
|
382
|
+
declare global {
|
|
383
|
+
function setTimeout(callback: () => void, delay: number): number;
|
|
384
|
+
function clearTimeout(id: number): void;
|
|
385
|
+
function setInterval(callback: () => void, delay: number): number;
|
|
386
|
+
function clearInterval(id: number): void;
|
|
387
|
+
interface Console {
|
|
388
|
+
log(...args: unknown[]): void;
|
|
389
|
+
warn(...args: unknown[]): void;
|
|
390
|
+
error(...args: unknown[]): void;
|
|
391
|
+
info(...args: unknown[]): void;
|
|
392
|
+
debug(...args: unknown[]): void;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Lightweight class for per-slot background color overrides.
|
|
397
|
+
* Used to set a specific color for a single slot, overriding the inherited color.
|
|
398
|
+
*/
|
|
399
|
+
export interface BackgroundSlot {
|
|
400
|
+
/**
|
|
401
|
+
* Set the background color for this slot.
|
|
402
|
+
* @param hex Color in hex format (e.g., "#FF0000")
|
|
403
|
+
* @returns this for chaining
|
|
404
|
+
*/
|
|
405
|
+
setColor(hex: string): BackgroundSlot;
|
|
406
|
+
/**
|
|
407
|
+
* Clear the override and use inherited color from parent.
|
|
408
|
+
*/
|
|
409
|
+
clear(): void;
|
|
410
|
+
/**
|
|
411
|
+
* Check if this slot has an explicit color override.
|
|
412
|
+
*/
|
|
413
|
+
hasOverride(): boolean;
|
|
414
|
+
/**
|
|
415
|
+
* Get the local index of this slot within its parent.
|
|
416
|
+
*/
|
|
417
|
+
getLocalIndex(): number;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Cell state enum representing the state of a GUI slot.
|
|
421
|
+
* Used to determine slot behavior for item movement and click events.
|
|
422
|
+
*/
|
|
423
|
+
export type CellState = "EMPTY" | "CONTENT" | "BUTTON";
|
|
424
|
+
/**
|
|
425
|
+
* Utility interface for CellState operations.
|
|
426
|
+
* Access via CellState global constant.
|
|
427
|
+
*/
|
|
428
|
+
export interface CellStateUtils {
|
|
429
|
+
/** Empty slot - allows item placement */
|
|
430
|
+
readonly EMPTY: CellState;
|
|
431
|
+
/** Content slot - contains player-placed items, allows movement */
|
|
432
|
+
readonly CONTENT: CellState;
|
|
433
|
+
/** Button slot - interactive element, blocks item movement */
|
|
434
|
+
readonly BUTTON: CellState;
|
|
435
|
+
/** Get the priority of a cell state (BUTTON > CONTENT > EMPTY) */
|
|
436
|
+
getPriority(state: CellState): number;
|
|
437
|
+
/** Check if the state allows item movement (EMPTY and CONTENT do) */
|
|
438
|
+
allowsItemMovement(state: CellState): boolean;
|
|
439
|
+
/** Check if the state fires click events (BUTTON does) */
|
|
440
|
+
firesClickEvents(state: CellState): boolean;
|
|
441
|
+
/** Get the higher priority state between two states */
|
|
442
|
+
max(a: CellState, b: CellState): CellState;
|
|
443
|
+
}
|
|
444
|
+
export interface ContainerConstructor {
|
|
445
|
+
new (config: ContainerConfig): Container;
|
|
446
|
+
}
|
|
447
|
+
export interface ScreenOptions {
|
|
448
|
+
persistenceKey?: string;
|
|
449
|
+
/**
|
|
450
|
+
* Use player inventory slots for GUI components (default: false).
|
|
451
|
+
* - When false: Player sees their normal inventory below the chest with "Inventory" label
|
|
452
|
+
* - When true: Player inventory becomes extended GUI space (slots 54-89), items stored, no label
|
|
453
|
+
*/
|
|
454
|
+
usePlayerInventorySlots?: boolean;
|
|
455
|
+
/** Unique identifier for persistence path */
|
|
456
|
+
id?: string;
|
|
457
|
+
/**
|
|
458
|
+
* Enable content slot persistence for this screen and its children.
|
|
459
|
+
* Default: true when persistenceKey is set, false otherwise.
|
|
460
|
+
* Children inherit this value unless they override it.
|
|
461
|
+
*/
|
|
462
|
+
persist?: boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Enable scroll position persistence for this screen and its children.
|
|
465
|
+
* Default: false. Children inherit this value unless they override it.
|
|
466
|
+
*/
|
|
467
|
+
persistScroll?: boolean;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Screen is the root component of the new GUI system.
|
|
471
|
+
* It manages the inventory, title rendering, and component tree.
|
|
472
|
+
* Note: In runtime, Screen extends Container, but for type safety we define it separately.
|
|
473
|
+
*/
|
|
474
|
+
export interface Screen {
|
|
475
|
+
createContainer(config: ContainerConfig): Container;
|
|
476
|
+
add(component: GuiComponentType): Screen;
|
|
477
|
+
/** Add a button at a specific slot */
|
|
478
|
+
addButton(slot: number, texture: string, title: string | null, onClick?: (event: ElementClickEvent) => void): Element;
|
|
479
|
+
removeButton(slot: number): void;
|
|
480
|
+
getButton(slot: number): Element | null;
|
|
481
|
+
appendText(text: string, size: number, y: number, centered: boolean): GuiText;
|
|
482
|
+
clearText(): void;
|
|
483
|
+
/**
|
|
484
|
+
* Set the background color for this screen.
|
|
485
|
+
* All child containers and slots inherit this color unless they override it.
|
|
486
|
+
* Default is #C6C6C6 (vanilla inventory gray).
|
|
487
|
+
* @param hex Color in hex format (e.g., "#222222")
|
|
488
|
+
*/
|
|
489
|
+
setBackgroundColor(hex: string): void;
|
|
490
|
+
/**
|
|
491
|
+
* Get or create a background slot override for a specific screen slot.
|
|
492
|
+
* Use this to set a custom color for a single slot.
|
|
493
|
+
* @param slot The screen slot index
|
|
494
|
+
* @returns BackgroundSlot for chaining (e.g., putBackground(0).setColor("#FF0000"))
|
|
495
|
+
*/
|
|
496
|
+
putBackground(slot: number): BackgroundSlot;
|
|
497
|
+
open(player: ScriptablePlayer | string): void;
|
|
498
|
+
close(): void;
|
|
499
|
+
refresh(): void;
|
|
500
|
+
/**
|
|
501
|
+
* Set or remove the custom texture.
|
|
502
|
+
* Pass null or empty string to switch to vanilla background.
|
|
503
|
+
*/
|
|
504
|
+
setTexture(texture: string | null): void;
|
|
505
|
+
/** Get the current texture name, or null if using vanilla background */
|
|
506
|
+
getTexture(): string | null;
|
|
507
|
+
getSize(): number;
|
|
508
|
+
getId(): string;
|
|
509
|
+
getPersistenceKey(): string | null;
|
|
510
|
+
isPersistent(): boolean;
|
|
511
|
+
getViewerCount(): number;
|
|
512
|
+
/** Get total slots including player inventory if enabled */
|
|
513
|
+
getTotalSlots(): number;
|
|
514
|
+
/** Check if a screen slot maps to the player's inventory */
|
|
515
|
+
isPlayerInventorySlot(screenSlot: number): boolean;
|
|
516
|
+
/** Convert a screen slot to a player inventory slot (0-35) */
|
|
517
|
+
toPlayerInventorySlot(screenSlot: number): number;
|
|
518
|
+
/** Convert a player inventory slot (0-35) to a screen slot */
|
|
519
|
+
fromPlayerInventorySlot(playerSlot: number): number;
|
|
520
|
+
/**
|
|
521
|
+
* Check if player inventory slots are being used for GUI components.
|
|
522
|
+
* When true, player inventory becomes extended GUI space (slots 54-89).
|
|
523
|
+
*/
|
|
524
|
+
isUsingPlayerInventorySlots(): boolean;
|
|
525
|
+
/**
|
|
526
|
+
* Enable/disable using player inventory slots for GUI components.
|
|
527
|
+
* - When false (default): Player sees vanilla inventory below chest with "Inventory" label
|
|
528
|
+
* - When true: Player inventory becomes extended GUI (items stored, no label, covered)
|
|
529
|
+
*/
|
|
530
|
+
setUsePlayerInventorySlots(enabled: boolean): void;
|
|
531
|
+
/** Get the cell state at a specific slot */
|
|
532
|
+
getCellState(slot: number): CellState;
|
|
533
|
+
/** Save the screen state to disk (content slots and scroll positions) */
|
|
534
|
+
save(): void;
|
|
535
|
+
/** Load persisted state from disk (called automatically on first open) */
|
|
536
|
+
load(): void;
|
|
537
|
+
/** Destroy the screen and delete persisted data */
|
|
538
|
+
destroy(): void;
|
|
539
|
+
onEvent(eventName: "open" | "close", callback: (player: ScriptablePlayer) => void): Screen;
|
|
540
|
+
/** Register an event callback */
|
|
541
|
+
on(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
542
|
+
}
|
|
543
|
+
export interface ContainerConfig {
|
|
544
|
+
startSlot?: number;
|
|
545
|
+
rows?: number;
|
|
546
|
+
cols?: number;
|
|
547
|
+
/** Layout type: "grid" (default) or "flex" */
|
|
548
|
+
layout?: "grid" | "flex";
|
|
549
|
+
/** Flow direction: "row" (default) or "column" */
|
|
550
|
+
direction?: "row" | "column";
|
|
551
|
+
/** Gap between children (for flex layout) */
|
|
552
|
+
gap?: number;
|
|
553
|
+
/** Enable scrolling */
|
|
554
|
+
scrollable?: boolean;
|
|
555
|
+
/** Maximum number of children */
|
|
556
|
+
maxCapacity?: number;
|
|
557
|
+
/**
|
|
558
|
+
* Unique identifier for persistence.
|
|
559
|
+
* Required if persist is true and container has content to save.
|
|
560
|
+
*/
|
|
561
|
+
id?: string;
|
|
562
|
+
/**
|
|
563
|
+
* Enable content slot persistence.
|
|
564
|
+
* Default: inherited from parent (true if screen has persistenceKey).
|
|
565
|
+
*/
|
|
566
|
+
persist?: boolean;
|
|
567
|
+
/**
|
|
568
|
+
* Enable scroll position persistence.
|
|
569
|
+
* Default: inherited from parent (false).
|
|
570
|
+
*/
|
|
571
|
+
persistScroll?: boolean;
|
|
572
|
+
}
|
|
573
|
+
export interface ContentAreaConfig {
|
|
574
|
+
startSlot: number;
|
|
575
|
+
rows: number;
|
|
576
|
+
cols: number;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Container groups elements in a region of the GUI.
|
|
580
|
+
* Supports both static (grid) and scrollable layouts.
|
|
581
|
+
*/
|
|
582
|
+
export interface Container {
|
|
583
|
+
/** Add a child at the next available index */
|
|
584
|
+
addChild(child: Element | Container): Container;
|
|
585
|
+
/** Add a child at a specific virtual index */
|
|
586
|
+
addChildAt(index: number, child: Element | Container): Container;
|
|
587
|
+
/** Remove a child at a specific index */
|
|
588
|
+
removeChildAt(index: number): Container;
|
|
589
|
+
/** Get a child at a specific index */
|
|
590
|
+
getChildAt(index: number): Element | Container | null;
|
|
591
|
+
/** Get the number of children */
|
|
592
|
+
getChildCount(): number;
|
|
593
|
+
/** Clear all children */
|
|
594
|
+
clear(): Container;
|
|
595
|
+
/** Add a button at the next available index */
|
|
596
|
+
addButton(texture: string, title: string | null, onClick?: (event: ElementClickEvent) => void): Element;
|
|
597
|
+
/** Add a button at a specific index */
|
|
598
|
+
addButtonAt(index: number, texture: string, title: string | null, onClick?: (event: ElementClickEvent) => void): Element;
|
|
599
|
+
/** Add a content slot at the next available index */
|
|
600
|
+
addContentSlot(): Element;
|
|
601
|
+
/** Add a content slot at a specific index */
|
|
602
|
+
addContentSlotAt(index: number): Element;
|
|
603
|
+
/** Add a nested container at the next available index */
|
|
604
|
+
addContainer(config: ContainerConfig): Container;
|
|
605
|
+
/** Add a nested container at a specific index */
|
|
606
|
+
addContainerAt(index: number, config: ContainerConfig): Container;
|
|
607
|
+
/** Alias for addChild */
|
|
608
|
+
add(element: Element | Container): Container;
|
|
609
|
+
/** Alias for addChildAt */
|
|
610
|
+
addAt(index: number, element: Element | Container): Container;
|
|
611
|
+
/** Push a button at the next available index */
|
|
612
|
+
pushButton(texture: string, title: string | null, onClick?: (event: ElementClickEvent) => void): Element;
|
|
613
|
+
/** Put a button at a specific index */
|
|
614
|
+
putButton(index: number, texture: string, title: string | null, onClick?: (event: ElementClickEvent) => void): Element;
|
|
615
|
+
/** Push a content slot at the next available index */
|
|
616
|
+
pushContentSlot(): Element;
|
|
617
|
+
/** Put a content slot at a specific index */
|
|
618
|
+
putContentSlot(index: number): Element;
|
|
619
|
+
/** Push a nested container at the next available index */
|
|
620
|
+
pushContainer(config: ContainerConfig): Container;
|
|
621
|
+
/** Put a nested container at a specific index */
|
|
622
|
+
putContainer(index: number, config: ContainerConfig): Container;
|
|
623
|
+
/**
|
|
624
|
+
* Set the background color for this container.
|
|
625
|
+
* All slots within this container inherit this color unless they have an explicit override.
|
|
626
|
+
* @param hex Color in hex format (e.g., "#333333")
|
|
627
|
+
*/
|
|
628
|
+
setBackgroundColor(hex: string): void;
|
|
629
|
+
/**
|
|
630
|
+
* Get or create a background slot override for a specific local slot index.
|
|
631
|
+
* Use this to set a custom color for a single slot within the container.
|
|
632
|
+
* @param localIndex The local slot index within this container
|
|
633
|
+
* @returns BackgroundSlot for chaining (e.g., putBackground(0).setColor("#FF0000"))
|
|
634
|
+
*/
|
|
635
|
+
putBackground(localIndex: number): BackgroundSlot;
|
|
636
|
+
/** Set the layout type */
|
|
637
|
+
setLayout(layout: "grid" | "flex"): Container;
|
|
638
|
+
/** Set the flow direction */
|
|
639
|
+
setDirection(direction: "row" | "column"): Container;
|
|
640
|
+
/** Set the gap between children (flex layout) */
|
|
641
|
+
setGap(gap: number): Container;
|
|
642
|
+
/** Set the start slot (top-left corner) */
|
|
643
|
+
setStartSlot(slot: number): Container;
|
|
644
|
+
/** Set the number of rows */
|
|
645
|
+
setRows(rows: number): Container;
|
|
646
|
+
/** Set the number of columns */
|
|
647
|
+
setCols(cols: number): Container;
|
|
648
|
+
getLayout(): "grid" | "flex";
|
|
649
|
+
getDirection(): "row" | "column";
|
|
650
|
+
getGap(): number;
|
|
651
|
+
getStartSlot(): number;
|
|
652
|
+
getRows(): number;
|
|
653
|
+
getCols(): number;
|
|
654
|
+
getSlotCount(): number;
|
|
655
|
+
/** Alias for getChildCount */
|
|
656
|
+
getElementCount(): number;
|
|
657
|
+
/** Alias for getChildAt */
|
|
658
|
+
getElementAt(index: number): Element | Container | null;
|
|
659
|
+
/**
|
|
660
|
+
* Get the virtual index (position in parent's children map).
|
|
661
|
+
* This is the key used to identify this container within its parent.
|
|
662
|
+
*/
|
|
663
|
+
getIndex(): number;
|
|
664
|
+
/** Set the unique identifier for persistence */
|
|
665
|
+
setId(id: string): Container;
|
|
666
|
+
/** Get the unique identifier */
|
|
667
|
+
getId(): string | null;
|
|
668
|
+
/** Set whether content slots should be persisted */
|
|
669
|
+
setPersist(persist: boolean): Container;
|
|
670
|
+
/** Get effective persist value (accounting for inheritance) */
|
|
671
|
+
isPersist(): boolean;
|
|
672
|
+
/** Set whether scroll position should be persisted */
|
|
673
|
+
setPersistScroll(persistScroll: boolean): Container;
|
|
674
|
+
/** Get effective persistScroll value (accounting for inheritance) */
|
|
675
|
+
isPersistScroll(): boolean;
|
|
676
|
+
/** Enable or disable scrolling */
|
|
677
|
+
setScrollable(scrollable: boolean): Container;
|
|
678
|
+
/** Check if scrollable */
|
|
679
|
+
isScrollable(): boolean;
|
|
680
|
+
/** Set the maximum number of children */
|
|
681
|
+
setMaxCapacity(max: number): Container;
|
|
682
|
+
/** Get the maximum capacity */
|
|
683
|
+
getMaxCapacity(): number;
|
|
684
|
+
/** Check if at max capacity */
|
|
685
|
+
isFull(): boolean;
|
|
686
|
+
/** Get remaining capacity */
|
|
687
|
+
getRemainingCapacity(): number;
|
|
688
|
+
/** Scroll by an offset (positive = forward, negative = backward) */
|
|
689
|
+
scroll(offset: number): void;
|
|
690
|
+
/** Scroll by one page (direction: 1 = next, -1 = previous) */
|
|
691
|
+
scrollPage(direction: 1 | -1): void;
|
|
692
|
+
/** Scroll to a specific virtual index */
|
|
693
|
+
scrollTo(virtualIndex: number): void;
|
|
694
|
+
/** Scroll to a specific page */
|
|
695
|
+
scrollToPage(page: number): void;
|
|
696
|
+
/** Get the number of items that fit on one page */
|
|
697
|
+
getPageSize(): number;
|
|
698
|
+
/** Get the total number of pages */
|
|
699
|
+
getPageCount(): number;
|
|
700
|
+
/** Get the current page (0-based) */
|
|
701
|
+
getCurrentPage(): number;
|
|
702
|
+
/** Get the current scroll offset */
|
|
703
|
+
getScrollOffset(): number;
|
|
704
|
+
/** Get the virtual size (highest index + 1) */
|
|
705
|
+
getVirtualSize(): number;
|
|
706
|
+
/** Check if there's a next page */
|
|
707
|
+
hasNextPage(): boolean;
|
|
708
|
+
/** Check if there's a previous page */
|
|
709
|
+
hasPreviousPage(): boolean;
|
|
710
|
+
/** Convert a relative slot to an absolute screen slot */
|
|
711
|
+
toAbsoluteSlot(relativeSlot: number): number;
|
|
712
|
+
/** Convert an absolute screen slot to a relative slot */
|
|
713
|
+
toRelativeSlot(absoluteSlot: number): number;
|
|
714
|
+
/** Convert virtual index to GUI slot (accounting for scroll) */
|
|
715
|
+
virtualIndexToSlot(virtualIndex: number): number;
|
|
716
|
+
/** Convert GUI slot to virtual index (accounting for scroll) */
|
|
717
|
+
slotToVirtualIndex(slot: number): number;
|
|
718
|
+
/** Get the cell state at a specific slot */
|
|
719
|
+
getCellState(slot: number): CellState;
|
|
720
|
+
/** Register an event callback */
|
|
721
|
+
on(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
722
|
+
on(event: "click", callback: (slot: number, virtualIndex: number) => void): void;
|
|
723
|
+
on(event: "scroll", callback: (offset: number, page: number) => void): void;
|
|
724
|
+
on(event: "childAdded", callback: (child: Element | Container, index: number) => void): void;
|
|
725
|
+
on(event: "childRemoved", callback: (child: Element | Container, index: number) => void): void;
|
|
726
|
+
on(event: "cleared", callback: () => void): void;
|
|
727
|
+
on(event: "capacityReached", callback: () => void): void;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Element is the unified item/button type.
|
|
731
|
+
* Can represent items, buttons, display-only elements, or content slots.
|
|
732
|
+
*/
|
|
733
|
+
export interface Element {
|
|
734
|
+
setTexture(texture: string): Element;
|
|
735
|
+
setTitle(title: string | null): Element;
|
|
736
|
+
setLore(lines: string[]): Element;
|
|
737
|
+
setHideTooltip(hide: boolean): Element;
|
|
738
|
+
setInteractive(interactive: boolean): Element;
|
|
739
|
+
setPickupable(pickupable: boolean): Element;
|
|
740
|
+
setData(data: unknown): Element;
|
|
741
|
+
getTexture(): string | null;
|
|
742
|
+
getTitle(): string | null;
|
|
743
|
+
getLore(): string[];
|
|
744
|
+
getData(): unknown;
|
|
745
|
+
isInteractive(): boolean;
|
|
746
|
+
isPickupable(): boolean;
|
|
747
|
+
getType(): "item" | "button" | "display" | "content_slot";
|
|
748
|
+
/** Get the cell state for this element's slot */
|
|
749
|
+
getCellState(slot: number): CellState;
|
|
750
|
+
/**
|
|
751
|
+
* Get the virtual index (position in parent's children map).
|
|
752
|
+
* This is the key used to identify this element within its parent container.
|
|
753
|
+
*/
|
|
754
|
+
getIndex(): number;
|
|
755
|
+
/**
|
|
756
|
+
* Get the computed real slot based on parent's scroll context.
|
|
757
|
+
* For non-scrollable containers, this equals the virtual index.
|
|
758
|
+
* For scrollable containers, this accounts for scroll offset.
|
|
759
|
+
*/
|
|
760
|
+
getRealSlot(): number;
|
|
761
|
+
/** Get the item stored in this content slot */
|
|
762
|
+
getStoredItem(): ScriptableItem | null;
|
|
763
|
+
/** Set the item stored in this content slot */
|
|
764
|
+
setStoredItem(item: ScriptableItem | null): void;
|
|
765
|
+
/** Check if this content slot has an item */
|
|
766
|
+
hasStoredItem(): boolean;
|
|
767
|
+
/** Clear the stored item */
|
|
768
|
+
clearStoredItem(): void;
|
|
769
|
+
/**
|
|
770
|
+
* Set whether this content slot should be persisted.
|
|
771
|
+
* Only applicable for CONTENT_SLOT type.
|
|
772
|
+
* If not set, inherits from parent container.
|
|
773
|
+
*/
|
|
774
|
+
setPersist(persist: boolean): Element;
|
|
775
|
+
/**
|
|
776
|
+
* Get effective persist value for this content slot.
|
|
777
|
+
* Only applicable for CONTENT_SLOT type.
|
|
778
|
+
*/
|
|
779
|
+
isPersist(): boolean;
|
|
780
|
+
onClick(callback: (event: ElementClickEvent) => void): Element;
|
|
781
|
+
onLeftClick(callback: (event: ElementClickEvent) => void): Element;
|
|
782
|
+
onRightClick(callback: (event: ElementClickEvent) => void): Element;
|
|
783
|
+
onShiftClick(callback: (event: ElementClickEvent) => void): Element;
|
|
784
|
+
onMiddleClick(callback: (event: ElementClickEvent) => void): Element;
|
|
785
|
+
/** Register a generic event callback */
|
|
786
|
+
on(eventName: string, callback: (...args: unknown[]) => void): void;
|
|
787
|
+
/** Called before item placement (CONTENT_SLOT only) - return false to cancel */
|
|
788
|
+
on(event: "beforeItemPlace", callback: (item: ScriptableItem, player: ScriptablePlayer) => boolean | void): void;
|
|
789
|
+
/** Called after item placement (CONTENT_SLOT only). Index is the virtual index of this element. */
|
|
790
|
+
on(event: "afterItemPlace", callback: (item: ScriptableItem, player: ScriptablePlayer, index: number) => void): void;
|
|
791
|
+
/** Called before item removal (CONTENT_SLOT only) - return false to cancel */
|
|
792
|
+
on(event: "beforeItemTake", callback: (player: ScriptablePlayer) => boolean | void): void;
|
|
793
|
+
/** Called after item removal (CONTENT_SLOT only). Index is the virtual index of this element. */
|
|
794
|
+
on(event: "afterItemTake", callback: (player: ScriptablePlayer, index: number) => void): void;
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Click event for Element interactions.
|
|
798
|
+
*/
|
|
799
|
+
export interface ElementClickEvent {
|
|
800
|
+
getElement(): Element;
|
|
801
|
+
getSlot(): number;
|
|
802
|
+
getClickType(): "left" | "right" | "middle" | "shift_left" | "shift_right" | "double_click" | "drop" | "control_drop" | "number_key" | "unknown";
|
|
803
|
+
isShiftClick(): boolean;
|
|
804
|
+
getData(): unknown;
|
|
805
|
+
cancel(): void;
|
|
806
|
+
isCancelled(): boolean;
|
|
807
|
+
}
|
|
808
|
+
export type GuiComponentType = Container | Element;
|
|
809
|
+
export interface ContainerClickEvent {
|
|
810
|
+
index: number;
|
|
811
|
+
}
|
|
812
|
+
export interface PropsAPI {
|
|
813
|
+
String: (defaultValue?: string) => StringPropAPI;
|
|
814
|
+
Number: (defaultValue?: number) => NumberPropAPI;
|
|
815
|
+
Boolean: (defaultValue?: boolean) => BooleanPropAPI;
|
|
816
|
+
Object: (defaultValue?: object) => ObjectPropAPI;
|
|
817
|
+
Array: (defaultValue?: unknown[]) => ArrayPropAPI;
|
|
818
|
+
Union: <T extends readonly (string | number | boolean)[]>(...values: T) => UnionPropAPI<T[number]>;
|
|
819
|
+
Generic: <T = unknown>(defaultValue?: T) => GenericPropAPI<T>;
|
|
820
|
+
}
|
|
821
|
+
export type ExtractPropType<T> = InferPropType<T>;
|
|
822
|
+
export type PropsObject<T> = {
|
|
823
|
+
[K in keyof T]: InferPropType<T[K]>;
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
826
|
+
* Base McModuleAPI interface with untyped emit.
|
|
827
|
+
* Use TypedMcModuleAPI for typed events.
|
|
828
|
+
*/
|
|
829
|
+
export interface McModuleAPI {
|
|
830
|
+
getProp: (key: string) => unknown;
|
|
831
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
832
|
+
exit: (value: unknown) => void;
|
|
833
|
+
getPlayer: (player: string) => ScriptablePlayer;
|
|
834
|
+
defineProps<T extends Record<string, unknown>>(props: T): PropsObject<T>;
|
|
835
|
+
open: (scriptName: string, props: Record<string, unknown>) => ScriptProcess;
|
|
836
|
+
camera: CameraAPI;
|
|
837
|
+
session: SessionAPI;
|
|
838
|
+
chatGUI: ChatGUIAPI;
|
|
839
|
+
command: CommandManager;
|
|
840
|
+
entity: BetterModelEntityAPI;
|
|
841
|
+
executor: ProcessExecutorAPI;
|
|
842
|
+
shaper: ShaperAPI;
|
|
843
|
+
items: ItemAPI;
|
|
844
|
+
definition: DefinitionBuilder;
|
|
845
|
+
storage: StorageAPI;
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Typed McModuleAPI with event type inference.
|
|
849
|
+
* When events are declared, emit() is typed to only accept declared event names.
|
|
850
|
+
* When no events are declared (EmptyEventSchema), emit() accepts any string (backward compatible).
|
|
851
|
+
*/
|
|
852
|
+
export type TypedMcModuleAPI<E extends EventSchema = EmptyEventSchema> = E extends EmptyEventSchema ? McModuleAPI : Omit<McModuleAPI, 'emit'> & {
|
|
853
|
+
/**
|
|
854
|
+
* Emit a typed event to parent process.
|
|
855
|
+
* Only declared event names are allowed.
|
|
856
|
+
*
|
|
857
|
+
* @param event Event name (must be declared in events schema)
|
|
858
|
+
* @param value Event payload (type checked against schema)
|
|
859
|
+
*/
|
|
860
|
+
emit<K extends keyof E>(event: K, value: InferPropType<E[K]>): void;
|
|
861
|
+
};
|
|
862
|
+
/**
|
|
863
|
+
* Base ScriptProcess interface with untyped events.
|
|
864
|
+
* Use TypedScriptProcess for type-safe event handling.
|
|
865
|
+
*/
|
|
866
|
+
export interface ScriptProcess {
|
|
867
|
+
/** Listen for events emitted by the script */
|
|
868
|
+
on(event: string, callback: (...args: unknown[]) => void): ScriptProcess;
|
|
869
|
+
/** Listen for an event only once (auto-removes after first call) */
|
|
870
|
+
once(event: string, callback: (...args: unknown[]) => void): ScriptProcess;
|
|
871
|
+
/** Remove event listener(s). If callback is omitted, removes all listeners for that event. */
|
|
872
|
+
off(event: string, callback?: (...args: unknown[]) => void): ScriptProcess;
|
|
873
|
+
/** Call a method on the script */
|
|
874
|
+
call(method: string, ...args: unknown[]): void;
|
|
875
|
+
/** Emit an event to the script */
|
|
876
|
+
emit(event: string, ...args: unknown[]): void;
|
|
877
|
+
/** Get the process ID */
|
|
878
|
+
getId(): number;
|
|
879
|
+
/** Check if the process has exited */
|
|
880
|
+
hasExited(): boolean;
|
|
881
|
+
/** Wait for the process to complete and get the return value */
|
|
882
|
+
then(callback: (value: unknown) => void): ScriptProcess;
|
|
883
|
+
/** Handle errors from the process */
|
|
884
|
+
catch(callback: (error: unknown) => void): ScriptProcess;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* Typed ScriptProcess with event type inference.
|
|
888
|
+
* When the script declares events, on/once callbacks are typed.
|
|
889
|
+
*
|
|
890
|
+
* @example
|
|
891
|
+
* ```typescript
|
|
892
|
+
* // If digicode declares: events: { onSuccess: Props.Boolean() }
|
|
893
|
+
* const child = digicode.run({ code: "1234" });
|
|
894
|
+
* child.on("onSuccess", (value) => {
|
|
895
|
+
* // value is typed as boolean
|
|
896
|
+
* });
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
export interface TypedScriptProcess<E extends EventSchema = EmptyEventSchema> extends Omit<ScriptProcess, 'on' | 'once' | 'off'> {
|
|
900
|
+
/**
|
|
901
|
+
* Listen for events emitted by the script.
|
|
902
|
+
* When events are declared, only declared event names are allowed.
|
|
903
|
+
*/
|
|
904
|
+
on<K extends keyof E>(event: K, callback: (value: InferPropType<E[K]>) => void): TypedScriptProcess<E>;
|
|
905
|
+
on(event: string, callback: (...args: unknown[]) => void): TypedScriptProcess<E>;
|
|
906
|
+
/**
|
|
907
|
+
* Listen for an event only once (auto-removes after first call).
|
|
908
|
+
* When events are declared, only declared event names are allowed.
|
|
909
|
+
*/
|
|
910
|
+
once<K extends keyof E>(event: K, callback: (value: InferPropType<E[K]>) => void): TypedScriptProcess<E>;
|
|
911
|
+
once(event: string, callback: (...args: unknown[]) => void): TypedScriptProcess<E>;
|
|
912
|
+
/**
|
|
913
|
+
* Remove event listener(s).
|
|
914
|
+
* If callback is omitted, removes all listeners for that event.
|
|
915
|
+
*/
|
|
916
|
+
off<K extends keyof E>(event: K, callback?: (value: InferPropType<E[K]>) => void): TypedScriptProcess<E>;
|
|
917
|
+
off(event: string, callback?: (...args: unknown[]) => void): TypedScriptProcess<E>;
|
|
918
|
+
}
|
|
919
|
+
/**
|
|
920
|
+
* Represents an imported script module.
|
|
921
|
+
* Scripts can import other scripts and invoke them with typed props and events.
|
|
922
|
+
*
|
|
923
|
+
* @example
|
|
924
|
+
* ```typescript
|
|
925
|
+
* import digicode from "./digicode";
|
|
926
|
+
*
|
|
927
|
+
* // Run the imported script with props
|
|
928
|
+
* const process = digicode.run({ code: "1234" });
|
|
929
|
+
*
|
|
930
|
+
* // Listen for typed events (if digicode declares events)
|
|
931
|
+
* process.on("onSuccess", (value) => {
|
|
932
|
+
* // value is typed based on event declaration
|
|
933
|
+
* });
|
|
934
|
+
*
|
|
935
|
+
* process.then(result => console.log("Result:", result));
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
export interface ScriptModule<P extends PropSchema = PropSchema, E extends EventSchema = EmptyEventSchema> {
|
|
939
|
+
/**
|
|
940
|
+
* Run the imported script with the given props.
|
|
941
|
+
* Creates a new process for the script execution.
|
|
942
|
+
*
|
|
943
|
+
* @param props Props to pass to the script
|
|
944
|
+
* @returns A TypedScriptProcess handle for the running script (with event types if declared)
|
|
945
|
+
*/
|
|
946
|
+
run(props: InferProps<P>): TypedScriptProcess<E>;
|
|
947
|
+
/**
|
|
948
|
+
* Get the script name/path.
|
|
949
|
+
*/
|
|
950
|
+
readonly name: string;
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Type helper to infer ScriptModule type from a ScriptDefinition.
|
|
954
|
+
* Extracts both props AND events for full type inference.
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* // digicode.ts
|
|
959
|
+
* export default defineScript({
|
|
960
|
+
* props: { code: Props.String() },
|
|
961
|
+
* events: { onSuccess: Props.Boolean() },
|
|
962
|
+
* run({ props }) { ... }
|
|
963
|
+
* });
|
|
964
|
+
*
|
|
965
|
+
* // main.ts - TypeScript infers both props and events
|
|
966
|
+
* import digicode from "./digicode";
|
|
967
|
+
* const child = digicode.run({ code: "1234" }); // Props type-safe!
|
|
968
|
+
* child.on("onSuccess", (val) => { ... }); // Events type-safe! val is boolean
|
|
969
|
+
* ```
|
|
970
|
+
*/
|
|
971
|
+
export type InferScriptModule<T> = T extends ScriptDefinition<infer P, infer E> ? ScriptModule<P, E> : T extends ScriptDefinition<infer P> ? ScriptModule<P, EmptyEventSchema> : ScriptModule<PropSchema, EmptyEventSchema>;
|
|
972
|
+
/**
|
|
973
|
+
* GuiText represents a text overlay in a GUI title.
|
|
974
|
+
* Returned by Screen.appendText().
|
|
975
|
+
* Supports dynamic updates and centering.
|
|
976
|
+
*/
|
|
977
|
+
export interface GuiText {
|
|
978
|
+
/**
|
|
979
|
+
* Update the text content and refresh the GUI title.
|
|
980
|
+
* Supports MiniMessage format for colors and formatting.
|
|
981
|
+
* @param text The new text content
|
|
982
|
+
* @returns this for method chaining
|
|
983
|
+
*/
|
|
984
|
+
update(text: string): GuiText;
|
|
985
|
+
/**
|
|
986
|
+
* Set text to be centered in the GUI title.
|
|
987
|
+
* @returns this for method chaining
|
|
988
|
+
*/
|
|
989
|
+
centered(): GuiText;
|
|
990
|
+
/**
|
|
991
|
+
* Check if text is centered.
|
|
992
|
+
* @returns true if centered
|
|
993
|
+
*/
|
|
994
|
+
isCentered(): boolean;
|
|
995
|
+
/**
|
|
996
|
+
* Set the line break width in pixels.
|
|
997
|
+
* Text will wrap to the next line when exceeding this width.
|
|
998
|
+
* Default is 160 pixels.
|
|
999
|
+
* @param pixels The width in pixels at which to break lines
|
|
1000
|
+
* @returns this for method chaining
|
|
1001
|
+
*/
|
|
1002
|
+
lineBreakAt(pixels: number): GuiText;
|
|
1003
|
+
/**
|
|
1004
|
+
* Get the line break width in pixels.
|
|
1005
|
+
* @returns The line break width
|
|
1006
|
+
*/
|
|
1007
|
+
getLineBreakAt(): number;
|
|
1008
|
+
}
|
|
1009
|
+
export interface ScriptablePlayer {
|
|
1010
|
+
giveItem(item: ScriptableItem): void;
|
|
1011
|
+
getName(): string;
|
|
1012
|
+
getUUID(): string;
|
|
1013
|
+
hasPermission(permission: string): boolean;
|
|
1014
|
+
sendMessage(message: string): void;
|
|
1015
|
+
clearChat(): void;
|
|
1016
|
+
/** Get current location as ScriptableLocation */
|
|
1017
|
+
getLocation(): ScriptableLocation;
|
|
1018
|
+
/** Get eye location as ScriptableLocation */
|
|
1019
|
+
getEyeLocation(): ScriptableLocation;
|
|
1020
|
+
/** Teleport to a location */
|
|
1021
|
+
teleport(location: ScriptableLocation): void;
|
|
1022
|
+
/** Teleport to coordinates in current world */
|
|
1023
|
+
teleportTo(x: number, y: number, z: number): void;
|
|
1024
|
+
isOnline(): boolean;
|
|
1025
|
+
exists(): boolean;
|
|
1026
|
+
getWorld(): string | null;
|
|
1027
|
+
getHealth(): number;
|
|
1028
|
+
getMaxHealth(): number;
|
|
1029
|
+
getFoodLevel(): number;
|
|
1030
|
+
getExperienceLevel(): number;
|
|
1031
|
+
getGamemode(): string;
|
|
1032
|
+
getChatSessionId(): string | null;
|
|
1033
|
+
getChatSession(): unknown | null;
|
|
1034
|
+
setChatSession(session: unknown): void;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* Wrapper for items - supports both vanilla Minecraft items and custom items.
|
|
1038
|
+
*
|
|
1039
|
+
* Properties:
|
|
1040
|
+
* - `type` - Item name for custom items (e.g., "magic_sword"), Material name for vanilla (e.g., "DIAMOND_SWORD")
|
|
1041
|
+
* - `isCustom` - true if this is a custom item registered with Kustom
|
|
1042
|
+
* - `amount` - Stack amount
|
|
1043
|
+
* - `material` - Material name (always available)
|
|
1044
|
+
* - `air` - true if this is an air item
|
|
1045
|
+
* - `customItem` - Access to underlying ScriptableCustomItem (null for vanilla)
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```typescript
|
|
1049
|
+
* slot.on("afterItemPlace", (item, player) => {
|
|
1050
|
+
* if (item.isCustom) {
|
|
1051
|
+
* console.log("Custom item: " + item.type); // "magic_sword"
|
|
1052
|
+
* } else {
|
|
1053
|
+
* console.log("Vanilla item: " + item.type); // "DIAMOND_SWORD"
|
|
1054
|
+
* }
|
|
1055
|
+
* });
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
export interface ScriptableItem {
|
|
1059
|
+
/**
|
|
1060
|
+
* Get the item type.
|
|
1061
|
+
* For custom items: returns the custom item name (e.g., "magic_sword")
|
|
1062
|
+
* For vanilla items: returns the Material name (e.g., "DIAMOND_SWORD")
|
|
1063
|
+
*/
|
|
1064
|
+
readonly type: string;
|
|
1065
|
+
/** Check if this is a custom item registered with Kustom */
|
|
1066
|
+
readonly isCustom: boolean;
|
|
1067
|
+
/** Get the item stack amount */
|
|
1068
|
+
readonly amount: number;
|
|
1069
|
+
/** Get the material name (e.g., "DIAMOND_SWORD") */
|
|
1070
|
+
readonly material: string;
|
|
1071
|
+
/** Check if this item is air/empty */
|
|
1072
|
+
readonly air: boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Get the underlying custom item wrapper (null for vanilla items).
|
|
1075
|
+
* Use this to access custom item-specific methods and properties.
|
|
1076
|
+
*/
|
|
1077
|
+
readonly customItem: ScriptableCustomItem | null;
|
|
1078
|
+
/** Get the underlying ItemStack (internal use) */
|
|
1079
|
+
getItemStack(): unknown;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Wrapper for CustomItem - provides access to custom item properties.
|
|
1083
|
+
*/
|
|
1084
|
+
export interface ScriptableCustomItem {
|
|
1085
|
+
/** Get the custom item name/ID */
|
|
1086
|
+
readonly name: string;
|
|
1087
|
+
/** Get the base material of this item */
|
|
1088
|
+
getMaterial(): string;
|
|
1089
|
+
/** Get an ItemStack for this item */
|
|
1090
|
+
getItemStack(): unknown;
|
|
1091
|
+
/** Get an ItemStack with a specific amount */
|
|
1092
|
+
getItemStack(amount: number): unknown;
|
|
1093
|
+
/** Check if this item is valid */
|
|
1094
|
+
isValid(): boolean;
|
|
1095
|
+
}
|
|
1096
|
+
export interface CameraAPI {
|
|
1097
|
+
create(x: number, y: number, z: number): Camera;
|
|
1098
|
+
create(x: number, y: number, z: number, yaw: number, pitch: number): Camera;
|
|
1099
|
+
createAtEyeLevel(x: number, y: number, z: number): Camera;
|
|
1100
|
+
get(id: string): Camera | null;
|
|
1101
|
+
get(id: string | object): Camera | null;
|
|
1102
|
+
isPlayerSpectating(playerName: string): boolean;
|
|
1103
|
+
getPlayerCamera(playerName: string): Camera | null;
|
|
1104
|
+
getCount(): number;
|
|
1105
|
+
getSpectatorCount(): number;
|
|
1106
|
+
remove(id: string): boolean;
|
|
1107
|
+
remove(id: string | object): boolean;
|
|
1108
|
+
startCameraMode(playerName: string, cameraId: string): boolean;
|
|
1109
|
+
stopSpectating(playerName: string): boolean;
|
|
1110
|
+
getAnimation(): CameraAnimationAPI;
|
|
1111
|
+
}
|
|
1112
|
+
export interface Camera {
|
|
1113
|
+
getId(): string;
|
|
1114
|
+
getLocation(): [number, number, number];
|
|
1115
|
+
setLocation(x: number, y: number, z: number): void;
|
|
1116
|
+
setLocation(x: number, y: number, z: number, yaw: number, pitch: number): void;
|
|
1117
|
+
getYaw(): number;
|
|
1118
|
+
setYaw(yaw: number): void;
|
|
1119
|
+
getPitch(): number;
|
|
1120
|
+
setPitch(pitch: number): void;
|
|
1121
|
+
setRotation(yaw: number, pitch: number): void;
|
|
1122
|
+
getDirection(): [number, number, number];
|
|
1123
|
+
setDirection(x: number, y: number, z: number): void;
|
|
1124
|
+
isActive(): boolean;
|
|
1125
|
+
getSpectator(): string | null;
|
|
1126
|
+
getSpectatorCount(): number;
|
|
1127
|
+
startCameraMode(playerName: string): boolean;
|
|
1128
|
+
move(dx: number, dy: number, dz: number): void;
|
|
1129
|
+
moveTo(x: number, y: number, z: number): void;
|
|
1130
|
+
rotate(yaw: number, pitch: number): void;
|
|
1131
|
+
lookAt(x: number, y: number, z: number): void;
|
|
1132
|
+
lookAtPlayer(playerName: string): void;
|
|
1133
|
+
isTransparentViewEnabled(): boolean;
|
|
1134
|
+
setTransparentView(enabled: boolean): void;
|
|
1135
|
+
toggleTransparentView(): void;
|
|
1136
|
+
clearTransparentView(): void;
|
|
1137
|
+
forceUpdateTransparentView(): void;
|
|
1138
|
+
setTarget(x: number, y: number, z: number): void;
|
|
1139
|
+
setTargetPlayer(playerName: string): void;
|
|
1140
|
+
clearTarget(): void;
|
|
1141
|
+
hasTarget(): boolean;
|
|
1142
|
+
stopSpectating(): boolean;
|
|
1143
|
+
remove(): boolean;
|
|
1144
|
+
forceUpdate(): void;
|
|
1145
|
+
createFakeEntity(): void;
|
|
1146
|
+
toString(): string;
|
|
1147
|
+
}
|
|
1148
|
+
export interface CameraAnimationAPI {
|
|
1149
|
+
createAnimation(): CameraAnimationBuilder;
|
|
1150
|
+
createTargetAnimation(x: number, y: number, z: number): TargetAnimationBuilder;
|
|
1151
|
+
createEntityTargetAnimation(entityName: string): EntityTargetAnimationBuilder;
|
|
1152
|
+
createAnimationSet(): AnimationSetBuilder;
|
|
1153
|
+
startFollowing(cameraId: string, playerName: string, offsetX: number, offsetY: number, offsetZ: number): void;
|
|
1154
|
+
isFollowing(cameraId: string): boolean;
|
|
1155
|
+
stopFollowing(cameraId: string): void;
|
|
1156
|
+
getPath(): PathAPI;
|
|
1157
|
+
getCurve(): CurveAPI;
|
|
1158
|
+
}
|
|
1159
|
+
export interface CameraAnimationBuilder {
|
|
1160
|
+
start(x: number, y: number, z: number): CameraAnimationBuilder;
|
|
1161
|
+
end(x: number, y: number, z: number): CameraAnimationBuilder;
|
|
1162
|
+
duration(seconds: number): CameraAnimationBuilder;
|
|
1163
|
+
framerate(fps: number): CameraAnimationBuilder;
|
|
1164
|
+
camera(cameraId: string): CameraAnimationBuilder;
|
|
1165
|
+
onStart(callback: () => void): CameraAnimationBuilder;
|
|
1166
|
+
onEnd(callback: () => void): CameraAnimationBuilder;
|
|
1167
|
+
build(): AnimationSet;
|
|
1168
|
+
}
|
|
1169
|
+
export interface TargetAnimationBuilder {
|
|
1170
|
+
duration(seconds: number): TargetAnimationBuilder;
|
|
1171
|
+
camera(cameraId: string): TargetAnimationBuilder;
|
|
1172
|
+
moveTo(offsetX: number, offsetY: number, offsetZ: number): AnimationSet;
|
|
1173
|
+
}
|
|
1174
|
+
export interface EntityTargetAnimationBuilder {
|
|
1175
|
+
duration(seconds: number): EntityTargetAnimationBuilder;
|
|
1176
|
+
camera(cameraId: string): EntityTargetAnimationBuilder;
|
|
1177
|
+
orbit(radius: number, height: number, startAngle: number, endAngle: number): AnimationSet;
|
|
1178
|
+
}
|
|
1179
|
+
export interface AnimationSetBuilder {
|
|
1180
|
+
append(animation: CameraAnimation): AnimationSetBuilder;
|
|
1181
|
+
delay(seconds: number): AnimationSetBuilder;
|
|
1182
|
+
onComplete(callback: () => void): AnimationSetBuilder;
|
|
1183
|
+
build(): AnimationSet;
|
|
1184
|
+
}
|
|
1185
|
+
export interface CameraAnimation {
|
|
1186
|
+
start(): void;
|
|
1187
|
+
stop(): void;
|
|
1188
|
+
isRunning(): boolean;
|
|
1189
|
+
}
|
|
1190
|
+
export interface TargetAnimation extends CameraAnimation {
|
|
1191
|
+
}
|
|
1192
|
+
export interface EntityTargetAnimation extends CameraAnimation {
|
|
1193
|
+
}
|
|
1194
|
+
export interface AnimationSet {
|
|
1195
|
+
start(): void;
|
|
1196
|
+
stop(): void;
|
|
1197
|
+
isRunning(): boolean;
|
|
1198
|
+
}
|
|
1199
|
+
export interface PathAPI {
|
|
1200
|
+
line(): Path;
|
|
1201
|
+
circle(): Path;
|
|
1202
|
+
spiral(radius: number, height: number, rotations: number): Path;
|
|
1203
|
+
figure8(width: number, height: number): Path;
|
|
1204
|
+
zigzag(width: number, height: number, segments: number): Path;
|
|
1205
|
+
bounce(height: number, bounces: number): Path;
|
|
1206
|
+
wave(amplitude: number, frequency: number, length: number): Path;
|
|
1207
|
+
}
|
|
1208
|
+
export interface Path {
|
|
1209
|
+
getPosition(startX: number, startY: number, startZ: number, endX: number, endY: number, endZ: number, progress: number): [number, number, number];
|
|
1210
|
+
}
|
|
1211
|
+
export interface CurveAPI {
|
|
1212
|
+
linear(): Curve;
|
|
1213
|
+
easeIn(): Curve;
|
|
1214
|
+
easeOut(): Curve;
|
|
1215
|
+
easeInOut(): Curve;
|
|
1216
|
+
bounce(): Curve;
|
|
1217
|
+
elastic(): Curve;
|
|
1218
|
+
sine(): Curve;
|
|
1219
|
+
exponential(): Curve;
|
|
1220
|
+
back(): Curve;
|
|
1221
|
+
circular(): Curve;
|
|
1222
|
+
step(steps: number): Curve;
|
|
1223
|
+
pulse(): Curve;
|
|
1224
|
+
}
|
|
1225
|
+
export interface Curve {
|
|
1226
|
+
getValue(progress: number): number;
|
|
1227
|
+
}
|
|
1228
|
+
export interface SessionAPI {
|
|
1229
|
+
create(sessionId: string, callback: (playerName: string, message: string, sessionId: string) => void): ChatSession;
|
|
1230
|
+
get(sessionId: string): ChatSession | null;
|
|
1231
|
+
close(sessionId: string): void;
|
|
1232
|
+
getCount(): number;
|
|
1233
|
+
getTotalPlayers(): number;
|
|
1234
|
+
isPlayerInSession(playerName: string): boolean;
|
|
1235
|
+
}
|
|
1236
|
+
export interface ChatSession {
|
|
1237
|
+
getSessionId(): string;
|
|
1238
|
+
getViewerCount(): number;
|
|
1239
|
+
hasPlayer(playerName: string): boolean;
|
|
1240
|
+
addPlayer(playerName: string): void;
|
|
1241
|
+
removePlayer(playerName: string): void;
|
|
1242
|
+
sendMessage(message: string): void;
|
|
1243
|
+
sendMessageToPlayer(playerName: string, message: string): void;
|
|
1244
|
+
close(): void;
|
|
1245
|
+
setClusterMode(clusterMode: boolean): void;
|
|
1246
|
+
isClusterMode(): boolean;
|
|
1247
|
+
clearPlayerChat(playerName: string): void;
|
|
1248
|
+
}
|
|
1249
|
+
export interface ChatGUIAPI {
|
|
1250
|
+
create(): ChatGUI;
|
|
1251
|
+
getCount(): number;
|
|
1252
|
+
}
|
|
1253
|
+
export interface ChatGUI {
|
|
1254
|
+
onInput(callback: (playerName: string, message: string, guiId: string) => void): void;
|
|
1255
|
+
setId(guiId: string): void;
|
|
1256
|
+
getId(): string;
|
|
1257
|
+
setBlocking(blocking: boolean): void;
|
|
1258
|
+
isBlocking(): boolean;
|
|
1259
|
+
addLine(content: string | ((line: ChatGUILine) => void)): void;
|
|
1260
|
+
addLine(lineWrapper: ChatGUILine): void;
|
|
1261
|
+
addEmptyLine(): void;
|
|
1262
|
+
createLine(): ChatGUILine;
|
|
1263
|
+
setLine(index: number, callback: (line: ChatGUILine) => void): void;
|
|
1264
|
+
updateLine(lineIndex: number, callback: (line: ChatGUILine) => void): void;
|
|
1265
|
+
removeLine(index: number): void;
|
|
1266
|
+
clear(): void;
|
|
1267
|
+
size(): number;
|
|
1268
|
+
ensureSize(minSize: number): void;
|
|
1269
|
+
addLineAt(index: number, callback: (line: ChatGUILine) => void): void;
|
|
1270
|
+
addLineAt(index: number, lineWrapper: ChatGUILine): void;
|
|
1271
|
+
setGlobalBackground(color: string): void;
|
|
1272
|
+
removeGlobalBackground(): void;
|
|
1273
|
+
open(playerName: string): void;
|
|
1274
|
+
close(playerName: string): void;
|
|
1275
|
+
close(): void;
|
|
1276
|
+
rerender(): void;
|
|
1277
|
+
rerenderForPlayer(playerName: string): void;
|
|
1278
|
+
}
|
|
1279
|
+
export interface ChatGUILine {
|
|
1280
|
+
padding(padding: number): ChatGUILine;
|
|
1281
|
+
spaceDistribution(distribution: "start" | "center" | "end" | "space_between" | "space_around" | "space_evenly"): ChatGUILine;
|
|
1282
|
+
spaceBetween(): ChatGUILine;
|
|
1283
|
+
spaceAround(): ChatGUILine;
|
|
1284
|
+
spaceEvenly(): ChatGUILine;
|
|
1285
|
+
center(): ChatGUILine;
|
|
1286
|
+
end(): ChatGUILine;
|
|
1287
|
+
background(color: string): ChatGUILine;
|
|
1288
|
+
noBackground(): ChatGUILine;
|
|
1289
|
+
addText(text: string): ChatGUILine;
|
|
1290
|
+
addText(text: string, color: string): ChatGUILine;
|
|
1291
|
+
addText(text: string, color: string, bold: boolean): ChatGUILine;
|
|
1292
|
+
addBoldText(text: string): ChatGUILine;
|
|
1293
|
+
addBoldText(text: string, color: string): ChatGUILine;
|
|
1294
|
+
addButton(text: string, command: string): ChatGUILine;
|
|
1295
|
+
addButton(text: string, command: string, hoverText: string): ChatGUILine;
|
|
1296
|
+
addButton(text: string, command: string, hoverText: string, color: string): ChatGUILine;
|
|
1297
|
+
addColumn(config: (config: ColumnConfig) => void): ChatGUILine;
|
|
1298
|
+
build(): unknown;
|
|
1299
|
+
hasBackground(): boolean;
|
|
1300
|
+
}
|
|
1301
|
+
export interface ColumnConfig {
|
|
1302
|
+
setType(type: "text" | "bold" | "button"): ColumnConfig;
|
|
1303
|
+
setText(text: string): ColumnConfig;
|
|
1304
|
+
setCommand(command: string): ColumnConfig;
|
|
1305
|
+
setHoverText(hoverText: string): ColumnConfig;
|
|
1306
|
+
setColor(color: string): ColumnConfig;
|
|
1307
|
+
setWidth(width: number): ColumnConfig;
|
|
1308
|
+
setAlign(align: "left" | "center" | "right"): ColumnConfig;
|
|
1309
|
+
setMargin(margin: number): ColumnConfig;
|
|
1310
|
+
}
|
|
1311
|
+
export interface CommandManager {
|
|
1312
|
+
register(name: string, callback: () => unknown): number;
|
|
1313
|
+
registerWithArgs(name: string, callback: (sender: string, args: string[]) => unknown): number;
|
|
1314
|
+
unregister(commandId: number): void;
|
|
1315
|
+
givePlayer(playerName: string, commandId: number): void;
|
|
1316
|
+
removePlayer(playerName: string, commandId: number): void;
|
|
1317
|
+
getPlayerCommands(playerName: string): string[];
|
|
1318
|
+
hasPlayerAccess(playerName: string, commandId: number): boolean;
|
|
1319
|
+
getCommand(commandId: number): [number, string] | null;
|
|
1320
|
+
getAllCommands(): [number, string][];
|
|
1321
|
+
getCommandCount(): number;
|
|
1322
|
+
getPlayerCount(): number;
|
|
1323
|
+
executeCommand(commandId: number, sender: string, ...args: unknown[]): unknown;
|
|
1324
|
+
}
|
|
1325
|
+
export interface BetterModelEntityAPI {
|
|
1326
|
+
hasModel(modelName: string): boolean;
|
|
1327
|
+
spawn(modelName: string, x: number, y: number, z: number, worldName?: string): EntityInstance | null;
|
|
1328
|
+
spawnBlock(modelName: string, x: number, y: number, z: number, onInteract: BlockInteractionCallback, worldName?: string): EntityInstance | null;
|
|
1329
|
+
disguisePlayer(playerName: string, modelName: string): EntityInstance | null;
|
|
1330
|
+
undisguisePlayer(playerName: string): boolean;
|
|
1331
|
+
playAnimationOnPlayer(playerName: string, animationName: string): boolean;
|
|
1332
|
+
mountPlayer(passengerName: string, vehicleName: string): boolean;
|
|
1333
|
+
unmountPlayer(playerName: string): boolean;
|
|
1334
|
+
hideModelFromPlayer(targetPlayerName: string, viewerPlayerName: string): boolean;
|
|
1335
|
+
showModelToPlayer(targetPlayerName: string, viewerPlayerName: string): boolean;
|
|
1336
|
+
getStats(): EntityStats;
|
|
1337
|
+
cleanup(): void;
|
|
1338
|
+
}
|
|
1339
|
+
export interface EntityInstance {
|
|
1340
|
+
/** Entity ID */
|
|
1341
|
+
readonly id: string;
|
|
1342
|
+
/** Model name */
|
|
1343
|
+
readonly modelName: string;
|
|
1344
|
+
/** Entity type ("dummy" or "entity") */
|
|
1345
|
+
readonly type: string;
|
|
1346
|
+
/** Check if destroyed (also available as method) */
|
|
1347
|
+
readonly isDestroyed: boolean;
|
|
1348
|
+
/** Check if this is a disguised player */
|
|
1349
|
+
readonly isDisguised: boolean;
|
|
1350
|
+
getId(): string;
|
|
1351
|
+
getModelName(): string;
|
|
1352
|
+
getType(): string;
|
|
1353
|
+
/**
|
|
1354
|
+
* Play an animation on this entity
|
|
1355
|
+
* @param animationName Name of the animation to play
|
|
1356
|
+
* @param animationType Optional animation type: "PLAY_ONCE", "LOOP", "HOLD_ON_LAST"
|
|
1357
|
+
* @returns true if successful
|
|
1358
|
+
*/
|
|
1359
|
+
playAnimation(animationName: string, animationType?: "PLAY_ONCE" | "LOOP" | "HOLD_ON_LAST"): boolean;
|
|
1360
|
+
/** Get list of available animations */
|
|
1361
|
+
getAvailableAnimations(): string[];
|
|
1362
|
+
/** Get information about a specific animation */
|
|
1363
|
+
getAnimationInfo(animationName: string): unknown | null;
|
|
1364
|
+
/** Stop all animations */
|
|
1365
|
+
stopAnimation(): boolean;
|
|
1366
|
+
hideFromPlayer(playerName: string): boolean;
|
|
1367
|
+
showToPlayer(playerName: string): boolean;
|
|
1368
|
+
mountOn(vehicleEntityId: string): boolean;
|
|
1369
|
+
unmount(): boolean;
|
|
1370
|
+
/** Change the mount controller */
|
|
1371
|
+
changeMountController(controllerName: string): boolean;
|
|
1372
|
+
destroy(): boolean;
|
|
1373
|
+
/** Remove disguise from player (if this is a disguised player) */
|
|
1374
|
+
removeDisguise(): boolean;
|
|
1375
|
+
getInfo(): EntityInfo;
|
|
1376
|
+
}
|
|
1377
|
+
export interface EntityStats {
|
|
1378
|
+
dummyEntities: number;
|
|
1379
|
+
entityTrackers: number;
|
|
1380
|
+
trackedByScript: number;
|
|
1381
|
+
}
|
|
1382
|
+
export interface EntityInfo {
|
|
1383
|
+
id: string;
|
|
1384
|
+
modelName: string;
|
|
1385
|
+
type: string;
|
|
1386
|
+
destroyed: boolean;
|
|
1387
|
+
entityType?: string;
|
|
1388
|
+
entityUUID?: string;
|
|
1389
|
+
world?: string;
|
|
1390
|
+
x?: number;
|
|
1391
|
+
y?: number;
|
|
1392
|
+
z?: number;
|
|
1393
|
+
}
|
|
1394
|
+
export type BlockInteractionCallback = (playerName: string | null, trackerId: string, interactionType: BlockInteractionType, ...extraArgs: unknown[]) => unknown;
|
|
1395
|
+
export type BlockInteractionType = 'LEFT_CLICK' | 'RIGHT_CLICK' | 'DAMAGE' | 'START_BREAKING' | 'BREAKING_PROGRESS' | 'BREAK_COMPLETE' | 'BREAKING_CANCELLED' | 'REMOVE';
|
|
1396
|
+
export interface ProcessExecutorAPI {
|
|
1397
|
+
getType(): string;
|
|
1398
|
+
getName(): string;
|
|
1399
|
+
getDisplayName(): string;
|
|
1400
|
+
isPlayer(): boolean;
|
|
1401
|
+
isConsole(): boolean;
|
|
1402
|
+
hasLocation(): boolean;
|
|
1403
|
+
getLocation(): ExecutorLocation | null;
|
|
1404
|
+
getWorldName(): string | null;
|
|
1405
|
+
asPlayer(): ScriptablePlayer | null;
|
|
1406
|
+
getInfo(): ExecutorInfo;
|
|
1407
|
+
}
|
|
1408
|
+
export interface ExecutorLocation {
|
|
1409
|
+
x: number;
|
|
1410
|
+
y: number;
|
|
1411
|
+
z: number;
|
|
1412
|
+
world: string;
|
|
1413
|
+
yaw: number;
|
|
1414
|
+
pitch: number;
|
|
1415
|
+
}
|
|
1416
|
+
export interface ExecutorInfo {
|
|
1417
|
+
type: string;
|
|
1418
|
+
name: string;
|
|
1419
|
+
displayName: string;
|
|
1420
|
+
isPlayer: boolean;
|
|
1421
|
+
isConsole: boolean;
|
|
1422
|
+
hasLocation: boolean;
|
|
1423
|
+
location?: ExecutorLocation;
|
|
1424
|
+
worldName?: string;
|
|
1425
|
+
}
|
|
1426
|
+
export interface ShaperAPI {
|
|
1427
|
+
create(templateId: string): ShaperTemplateBuilder;
|
|
1428
|
+
getTemplate(templateId: string): ShaperTemplateWrapper | null;
|
|
1429
|
+
hasTemplate(templateId: string): boolean;
|
|
1430
|
+
getTemplateIds(): string[];
|
|
1431
|
+
getInstance(instanceId: string): ShaperBlockInstance | null;
|
|
1432
|
+
getInstanceIds(): string[];
|
|
1433
|
+
spawn(templateId: string, location: ScriptableLocation, yawDegrees: number): ShaperBlockInstance | null;
|
|
1434
|
+
spawnAt(templateId: string, x: number, y: number, z: number, worldName: string, yawDegrees: number): ShaperBlockInstance | null;
|
|
1435
|
+
removeInstance(instanceId: string): boolean;
|
|
1436
|
+
getInstanceCount(): number;
|
|
1437
|
+
getTemplateCount(): number;
|
|
1438
|
+
}
|
|
1439
|
+
export interface ShaperTemplateBuilder {
|
|
1440
|
+
/**
|
|
1441
|
+
* Set the model for this shaper.
|
|
1442
|
+
* Accepts either a string path or a ModelNode from DefinitionBuilder.
|
|
1443
|
+
*/
|
|
1444
|
+
withModel(modelOrPath: string | ModelNode): ShaperTemplateBuilder;
|
|
1445
|
+
withBetterModel(modelId: string): ShaperTemplateBuilder;
|
|
1446
|
+
modelOffset(x: number, y: number, z: number): ShaperTemplateBuilder;
|
|
1447
|
+
modelScale(x: number, y: number, z: number): ShaperTemplateBuilder;
|
|
1448
|
+
addCollisionRect(width: number, height: number, depth: number, cornerX: number, cornerY: number, cornerZ: number): ShaperTemplateBuilder;
|
|
1449
|
+
fullBlockCollision(): ShaperTemplateBuilder;
|
|
1450
|
+
slabCollision(height: number): ShaperTemplateBuilder;
|
|
1451
|
+
/**
|
|
1452
|
+
* Enable or disable automatic block placement when right-clicking with the item.
|
|
1453
|
+
* By default, shaper blocks are automatically placeable.
|
|
1454
|
+
* When disabled, the auto-generated item is also marked as hidden.
|
|
1455
|
+
* @param enabled true to enable auto-placement (default), false to disable
|
|
1456
|
+
*/
|
|
1457
|
+
autoPlace(enabled: boolean): ShaperTemplateBuilder;
|
|
1458
|
+
onClick(callback: (event: ShaperClickEvent) => void): ShaperTemplateBuilder;
|
|
1459
|
+
onBreak(callback: (event: ShaperBreakEvent) => void): ShaperTemplateBuilder;
|
|
1460
|
+
onPlace(callback: (event: ShaperPlaceEvent) => void): ShaperTemplateBuilder;
|
|
1461
|
+
register(): ShaperTemplateWrapper;
|
|
1462
|
+
}
|
|
1463
|
+
export interface ShaperTemplateWrapper {
|
|
1464
|
+
readonly id: string;
|
|
1465
|
+
hasBetterModel(): boolean;
|
|
1466
|
+
getBetterModelId(): string | null;
|
|
1467
|
+
spawn(location: ScriptableLocation, yawDegrees: number): ShaperBlockInstance | null;
|
|
1468
|
+
spawnAt(location: ScriptableLocation): ShaperBlockInstance | null;
|
|
1469
|
+
spawnAtCoords(x: number, y: number, z: number, worldName: string, yawDegrees: number): ShaperBlockInstance | null;
|
|
1470
|
+
}
|
|
1471
|
+
export interface ShaperBlockInstance {
|
|
1472
|
+
readonly id: string;
|
|
1473
|
+
readonly templateId: string;
|
|
1474
|
+
readonly rotation: number;
|
|
1475
|
+
readonly isSpawned: boolean;
|
|
1476
|
+
readonly isDestroyed: boolean;
|
|
1477
|
+
getLocation(): ScriptableLocation | null;
|
|
1478
|
+
setRotation(degrees: number): void;
|
|
1479
|
+
addRotation(degrees: number): void;
|
|
1480
|
+
teleport(location: ScriptableLocation): void;
|
|
1481
|
+
teleportWithRotation(location: ScriptableLocation, yawDegrees: number): void;
|
|
1482
|
+
getState(key: string): unknown;
|
|
1483
|
+
getStateWithDefault(key: string, defaultValue: unknown): unknown;
|
|
1484
|
+
setState(key: string, value: unknown): void;
|
|
1485
|
+
getBetterModelEntityId(): string | null;
|
|
1486
|
+
hasBetterModel(): boolean;
|
|
1487
|
+
playAnimation(animationName: string): boolean;
|
|
1488
|
+
playAnimation(animationName: string, animationType: "PLAY_ONCE" | "LOOP" | "HOLD_ON_LAST"): boolean;
|
|
1489
|
+
saveBetterModelState(): void;
|
|
1490
|
+
remove(): void;
|
|
1491
|
+
despawn(): void;
|
|
1492
|
+
}
|
|
1493
|
+
export interface ShaperClickEvent {
|
|
1494
|
+
readonly instance: ShaperBlockInstance;
|
|
1495
|
+
readonly player: ScriptablePlayer;
|
|
1496
|
+
readonly collisionInfo: ScriptableCollisionInfo | null;
|
|
1497
|
+
readonly clickedFace: string;
|
|
1498
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1499
|
+
cancel(): void;
|
|
1500
|
+
isCancelled(): boolean;
|
|
1501
|
+
setCancelled(cancelled: boolean): void;
|
|
1502
|
+
isSneaking(): boolean;
|
|
1503
|
+
getPlacementLocation(): ScriptableLocation;
|
|
1504
|
+
}
|
|
1505
|
+
export interface ShaperBreakEvent {
|
|
1506
|
+
readonly instance: ShaperBlockInstance;
|
|
1507
|
+
readonly player: ScriptablePlayer | null;
|
|
1508
|
+
readonly collisionInfo: ScriptableCollisionInfo | null;
|
|
1509
|
+
cancel(): void;
|
|
1510
|
+
isCancelled(): boolean;
|
|
1511
|
+
}
|
|
1512
|
+
export interface ShaperPlaceEvent {
|
|
1513
|
+
readonly instance: ShaperBlockInstance;
|
|
1514
|
+
readonly location: ScriptableLocation;
|
|
1515
|
+
readonly player: ScriptablePlayer | null;
|
|
1516
|
+
cancel(): void;
|
|
1517
|
+
isCancelled(): boolean;
|
|
1518
|
+
}
|
|
1519
|
+
export interface ScriptableCollisionInfo {
|
|
1520
|
+
readonly shaperId: string;
|
|
1521
|
+
readonly scale: number;
|
|
1522
|
+
readonly clickedFace: string;
|
|
1523
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1524
|
+
readonly sneaking: boolean;
|
|
1525
|
+
readonly mainHandItem: unknown;
|
|
1526
|
+
readonly offHandItem: unknown;
|
|
1527
|
+
getLocation(): ScriptableLocation | null;
|
|
1528
|
+
isValid(): boolean;
|
|
1529
|
+
getPlacementLocation(): ScriptableLocation;
|
|
1530
|
+
isCancelled(): boolean;
|
|
1531
|
+
cancel(): void;
|
|
1532
|
+
setCancelled(cancelled: boolean): void;
|
|
1533
|
+
}
|
|
1534
|
+
export interface ScriptableLocation {
|
|
1535
|
+
readonly x: number;
|
|
1536
|
+
readonly y: number;
|
|
1537
|
+
readonly z: number;
|
|
1538
|
+
readonly yaw: number;
|
|
1539
|
+
readonly pitch: number;
|
|
1540
|
+
readonly worldName: string;
|
|
1541
|
+
getX(): number;
|
|
1542
|
+
getY(): number;
|
|
1543
|
+
getZ(): number;
|
|
1544
|
+
getYaw(): number;
|
|
1545
|
+
getPitch(): number;
|
|
1546
|
+
getWorldName(): string;
|
|
1547
|
+
getWorld(): ScriptableWorld;
|
|
1548
|
+
getBlockX(): number;
|
|
1549
|
+
getBlockY(): number;
|
|
1550
|
+
getBlockZ(): number;
|
|
1551
|
+
toBukkit(): unknown;
|
|
1552
|
+
toObject(): {
|
|
1553
|
+
x: number;
|
|
1554
|
+
y: number;
|
|
1555
|
+
z: number;
|
|
1556
|
+
yaw: number;
|
|
1557
|
+
pitch: number;
|
|
1558
|
+
world: string;
|
|
1559
|
+
};
|
|
1560
|
+
add(x: number, y: number, z: number): ScriptableLocation;
|
|
1561
|
+
subtract(x: number, y: number, z: number): ScriptableLocation;
|
|
1562
|
+
multiply(factor: number): ScriptableLocation;
|
|
1563
|
+
copy(): ScriptableLocation;
|
|
1564
|
+
distance(other: ScriptableLocation): number;
|
|
1565
|
+
distanceSquared(other: ScriptableLocation): number;
|
|
1566
|
+
getBlockLocation(): ScriptableLocation;
|
|
1567
|
+
getCenter(): ScriptableLocation;
|
|
1568
|
+
getBlockCenter(): ScriptableLocation;
|
|
1569
|
+
setDirection(x: number, y: number, z: number): ScriptableLocation;
|
|
1570
|
+
getDirection(): {
|
|
1571
|
+
x: number;
|
|
1572
|
+
y: number;
|
|
1573
|
+
z: number;
|
|
1574
|
+
};
|
|
1575
|
+
isSameBlock(other: ScriptableLocation): boolean;
|
|
1576
|
+
isSameWorld(other: ScriptableLocation): boolean;
|
|
1577
|
+
}
|
|
1578
|
+
export interface ScriptableWorld {
|
|
1579
|
+
readonly name: string;
|
|
1580
|
+
readonly environment: string;
|
|
1581
|
+
readonly seed: number;
|
|
1582
|
+
readonly time: number;
|
|
1583
|
+
getName(): string;
|
|
1584
|
+
getTimeValue(): number;
|
|
1585
|
+
setTime(time: number): void;
|
|
1586
|
+
getFullTime(): number;
|
|
1587
|
+
setFullTime(time: number): void;
|
|
1588
|
+
isRaining(): boolean;
|
|
1589
|
+
setStorm(storm: boolean): void;
|
|
1590
|
+
isThundering(): boolean;
|
|
1591
|
+
setThundering(thundering: boolean): void;
|
|
1592
|
+
setWeatherDuration(duration: number): void;
|
|
1593
|
+
clearWeather(): void;
|
|
1594
|
+
getPlayers(): ScriptablePlayer[];
|
|
1595
|
+
getPlayerCount(): number;
|
|
1596
|
+
getSpawnLocation(): ScriptableLocation;
|
|
1597
|
+
setSpawnLocation(location: ScriptableLocation): void;
|
|
1598
|
+
setSpawnLocationAt(x: number, y: number, z: number): void;
|
|
1599
|
+
getHighestBlockYAt(x: number, z: number): number;
|
|
1600
|
+
getHighestBlockAt(x: number, z: number): ScriptableLocation;
|
|
1601
|
+
spawnParticle(particleType: string, location: ScriptableLocation, count: number, offsetX: number, offsetY: number, offsetZ: number, speed: number): void;
|
|
1602
|
+
spawnParticleAt(particleType: string, x: number, y: number, z: number, count: number, offsetX: number, offsetY: number, offsetZ: number, speed: number): void;
|
|
1603
|
+
playSound(location: ScriptableLocation, soundName: string, volume: number, pitch: number): void;
|
|
1604
|
+
playSoundAt(x: number, y: number, z: number, soundName: string, volume: number, pitch: number): void;
|
|
1605
|
+
createExplosion(location: ScriptableLocation, power: number, setFire: boolean, breakBlocks: boolean): void;
|
|
1606
|
+
createExplosionAt(x: number, y: number, z: number, power: number, setFire: boolean, breakBlocks: boolean): void;
|
|
1607
|
+
strikeLightning(location: ScriptableLocation): void;
|
|
1608
|
+
strikeLightningEffect(location: ScriptableLocation): void;
|
|
1609
|
+
strikeLightningAt(x: number, y: number, z: number): void;
|
|
1610
|
+
strikeLightningEffectAt(x: number, y: number, z: number): void;
|
|
1611
|
+
isValid(): boolean;
|
|
1612
|
+
getDifficulty(): string;
|
|
1613
|
+
isPvP(): boolean;
|
|
1614
|
+
getWorldBorderSize(): number;
|
|
1615
|
+
}
|
|
1616
|
+
export interface DefinitionBuilder {
|
|
1617
|
+
model(modelPath: string): ModelRef;
|
|
1618
|
+
condition(property: string): ConditionNode;
|
|
1619
|
+
select(property: string): SelectNode;
|
|
1620
|
+
rangeDispatch(property: string): RangeDispatchNode;
|
|
1621
|
+
composite(): CompositeNode;
|
|
1622
|
+
bow(defaultModel: string, pulling0: string, pulling1: string, pulling2: string): ModelNode;
|
|
1623
|
+
bowCustom(defaultModel: string, pullingModels: string[], thresholds: number[]): ModelNode;
|
|
1624
|
+
elytra(normalModel: string, brokenModel: string): ModelNode;
|
|
1625
|
+
crossbow(defaultModel: string, pulling0: string, pulling1: string, pulling2: string, arrowLoaded: string, rocketLoaded: string): ModelNode;
|
|
1626
|
+
displayContext(guiModel: string, defaultModel: string): ModelNode;
|
|
1627
|
+
displayContextFull(guiModel: string, groundModel: string, defaultModel: string): ModelNode;
|
|
1628
|
+
}
|
|
1629
|
+
export interface ModelNode {
|
|
1630
|
+
}
|
|
1631
|
+
export interface ModelRef extends ModelNode {
|
|
1632
|
+
withConstantTint(argbColor: number): ModelRef;
|
|
1633
|
+
withDyeTint(defaultColor: number): ModelRef;
|
|
1634
|
+
}
|
|
1635
|
+
export interface ConditionNode extends ModelNode {
|
|
1636
|
+
onTrue(node: ModelNode): ConditionNode;
|
|
1637
|
+
onFalse(node: ModelNode): ConditionNode;
|
|
1638
|
+
component(componentId: string): ConditionNode;
|
|
1639
|
+
}
|
|
1640
|
+
export interface SelectNode extends ModelNode {
|
|
1641
|
+
addCase(when: string, model: ModelNode): SelectNode;
|
|
1642
|
+
addCase(when: string[], model: ModelNode): SelectNode;
|
|
1643
|
+
fallback(node: ModelNode): SelectNode;
|
|
1644
|
+
blockStateProperty(propertyName: string): SelectNode;
|
|
1645
|
+
pattern(datePattern: string): SelectNode;
|
|
1646
|
+
}
|
|
1647
|
+
export interface RangeDispatchNode extends ModelNode {
|
|
1648
|
+
entry(threshold: number, model: ModelNode): RangeDispatchNode;
|
|
1649
|
+
fallback(node: ModelNode): RangeDispatchNode;
|
|
1650
|
+
scale(scale: number): RangeDispatchNode;
|
|
1651
|
+
period(period: number): RangeDispatchNode;
|
|
1652
|
+
target(target: "spawn" | "lodestone" | "recovery" | "none"): RangeDispatchNode;
|
|
1653
|
+
source(source: "daytime" | "random"): RangeDispatchNode;
|
|
1654
|
+
}
|
|
1655
|
+
export interface CompositeNode extends ModelNode {
|
|
1656
|
+
add(model: ModelNode): CompositeNode;
|
|
1657
|
+
}
|
|
1658
|
+
export interface ItemAPI {
|
|
1659
|
+
create(itemName: string): ItemTemplateBuilder;
|
|
1660
|
+
get(itemName: string): ScriptableCustomItem | null;
|
|
1661
|
+
hasItem(itemName: string): boolean;
|
|
1662
|
+
getItemNames(): string[];
|
|
1663
|
+
getItemCount(): number;
|
|
1664
|
+
unregister(itemName: string): boolean;
|
|
1665
|
+
}
|
|
1666
|
+
export interface ItemTemplateBuilder {
|
|
1667
|
+
withMaterial(materialName: string): ItemTemplateBuilder;
|
|
1668
|
+
/**
|
|
1669
|
+
* Set the model for this item.
|
|
1670
|
+
* Accepts either a string path or a ModelNode from DefinitionBuilder.
|
|
1671
|
+
*/
|
|
1672
|
+
withModel(modelOrPath: string | ModelNode): ItemTemplateBuilder;
|
|
1673
|
+
withDisplayName(displayName: string): ItemTemplateBuilder;
|
|
1674
|
+
withDescription(description: string): ItemTemplateBuilder;
|
|
1675
|
+
/**
|
|
1676
|
+
* Make this item place a block when right-clicked.
|
|
1677
|
+
* @param blockPath The block to place (namespace:path format)
|
|
1678
|
+
*/
|
|
1679
|
+
placesBlock(blockPath: string): ItemTemplateBuilder;
|
|
1680
|
+
on(event: "rightClick", callback: (event: ItemInteractEvent) => void): ItemTemplateBuilder;
|
|
1681
|
+
on(event: "leftClick", callback: (event: ItemInteractEvent) => void): ItemTemplateBuilder;
|
|
1682
|
+
on(event: "drop", callback: (event: ItemDropEvent) => void): ItemTemplateBuilder;
|
|
1683
|
+
on(event: "pickup", callback: (event: ItemPickupEvent) => void): ItemTemplateBuilder;
|
|
1684
|
+
on(event: "consume", callback: (event: ItemConsumeEvent) => void): ItemTemplateBuilder;
|
|
1685
|
+
on(event: "damageEntity", callback: (event: ItemDamageEntityEvent) => void): ItemTemplateBuilder;
|
|
1686
|
+
on(event: "shootBow", callback: (event: ItemShootBowEvent) => void): ItemTemplateBuilder;
|
|
1687
|
+
on(event: "holdStart", callback: (event: ItemHoldEvent) => void): ItemTemplateBuilder;
|
|
1688
|
+
on(event: "holdEnd", callback: (event: ItemHoldEvent) => void): ItemTemplateBuilder;
|
|
1689
|
+
on(event: "swapHand", callback: (event: ItemSwapHandEvent) => void): ItemTemplateBuilder;
|
|
1690
|
+
on(event: "durabilityChange", callback: (event: ItemDurabilityEvent) => void): ItemTemplateBuilder;
|
|
1691
|
+
on(event: "break", callback: (event: ItemBreakEvent) => void): ItemTemplateBuilder;
|
|
1692
|
+
on(event: "interactEntity", callback: (event: ItemEntityInteractEvent) => void): ItemTemplateBuilder;
|
|
1693
|
+
on(event: "blockBreak", callback: (event: ItemBlockBreakEvent) => void): ItemTemplateBuilder;
|
|
1694
|
+
on(event: "blockPlace", callback: (event: ItemBlockPlaceEvent) => void): ItemTemplateBuilder;
|
|
1695
|
+
once(event: "rightClick", callback: (event: ItemInteractEvent) => void): ItemTemplateBuilder;
|
|
1696
|
+
once(event: "leftClick", callback: (event: ItemInteractEvent) => void): ItemTemplateBuilder;
|
|
1697
|
+
once(event: "drop", callback: (event: ItemDropEvent) => void): ItemTemplateBuilder;
|
|
1698
|
+
once(event: "pickup", callback: (event: ItemPickupEvent) => void): ItemTemplateBuilder;
|
|
1699
|
+
once(event: "consume", callback: (event: ItemConsumeEvent) => void): ItemTemplateBuilder;
|
|
1700
|
+
once(event: "damageEntity", callback: (event: ItemDamageEntityEvent) => void): ItemTemplateBuilder;
|
|
1701
|
+
once(event: "shootBow", callback: (event: ItemShootBowEvent) => void): ItemTemplateBuilder;
|
|
1702
|
+
once(event: "holdStart", callback: (event: ItemHoldEvent) => void): ItemTemplateBuilder;
|
|
1703
|
+
once(event: "holdEnd", callback: (event: ItemHoldEvent) => void): ItemTemplateBuilder;
|
|
1704
|
+
once(event: "swapHand", callback: (event: ItemSwapHandEvent) => void): ItemTemplateBuilder;
|
|
1705
|
+
once(event: "durabilityChange", callback: (event: ItemDurabilityEvent) => void): ItemTemplateBuilder;
|
|
1706
|
+
once(event: "break", callback: (event: ItemBreakEvent) => void): ItemTemplateBuilder;
|
|
1707
|
+
once(event: "interactEntity", callback: (event: ItemEntityInteractEvent) => void): ItemTemplateBuilder;
|
|
1708
|
+
once(event: "blockBreak", callback: (event: ItemBlockBreakEvent) => void): ItemTemplateBuilder;
|
|
1709
|
+
once(event: "blockPlace", callback: (event: ItemBlockPlaceEvent) => void): ItemTemplateBuilder;
|
|
1710
|
+
register(): ScriptableCustomItem;
|
|
1711
|
+
}
|
|
1712
|
+
export interface ScriptableCustomItem {
|
|
1713
|
+
readonly name: string;
|
|
1714
|
+
getMaterial(): string;
|
|
1715
|
+
getItemStack(): unknown;
|
|
1716
|
+
getItemStack(amount: number): unknown;
|
|
1717
|
+
isValid(): boolean;
|
|
1718
|
+
}
|
|
1719
|
+
/**
|
|
1720
|
+
* Persistent key-value storage API for scripts.
|
|
1721
|
+
* Data is stored per-script in plugins/kustom-plugin/data/scripts/{scriptName}/
|
|
1722
|
+
*
|
|
1723
|
+
* @example
|
|
1724
|
+
* ```typescript
|
|
1725
|
+
* // Store data
|
|
1726
|
+
* process.storage.set("config", { maxLevel: 100, debug: true });
|
|
1727
|
+
* process.storage.set("player_Steve_coins", 500);
|
|
1728
|
+
*
|
|
1729
|
+
* // Retrieve data
|
|
1730
|
+
* const config = process.storage.get("config");
|
|
1731
|
+
* const coins = process.storage.get("player_Steve_coins");
|
|
1732
|
+
*
|
|
1733
|
+
* // Check existence
|
|
1734
|
+
* if (process.storage.has("config")) { ... }
|
|
1735
|
+
*
|
|
1736
|
+
* // List all keys
|
|
1737
|
+
* const keys = process.storage.keys();
|
|
1738
|
+
*
|
|
1739
|
+
* // Delete data
|
|
1740
|
+
* process.storage.delete("oldKey");
|
|
1741
|
+
* ```
|
|
1742
|
+
*/
|
|
1743
|
+
export interface StorageAPI {
|
|
1744
|
+
/**
|
|
1745
|
+
* Store a value for the given key.
|
|
1746
|
+
* The value can be any JSON-serializable value (object, array, string, number, boolean).
|
|
1747
|
+
*
|
|
1748
|
+
* @param key The key to store under
|
|
1749
|
+
* @param value The value to store
|
|
1750
|
+
*/
|
|
1751
|
+
set(key: string, value: unknown): void;
|
|
1752
|
+
/**
|
|
1753
|
+
* Retrieve a value for the given key.
|
|
1754
|
+
*
|
|
1755
|
+
* @param key The key to retrieve
|
|
1756
|
+
* @returns The stored value, or undefined if not found
|
|
1757
|
+
*/
|
|
1758
|
+
get<T = unknown>(key: string): T | undefined;
|
|
1759
|
+
/**
|
|
1760
|
+
* Delete a stored value.
|
|
1761
|
+
*
|
|
1762
|
+
* @param key The key to delete
|
|
1763
|
+
* @returns true if deleted, false if not found
|
|
1764
|
+
*/
|
|
1765
|
+
delete(key: string): boolean;
|
|
1766
|
+
/**
|
|
1767
|
+
* Check if a key exists.
|
|
1768
|
+
*
|
|
1769
|
+
* @param key The key to check
|
|
1770
|
+
* @returns true if the key exists
|
|
1771
|
+
*/
|
|
1772
|
+
has(key: string): boolean;
|
|
1773
|
+
/**
|
|
1774
|
+
* Get all keys stored by this script.
|
|
1775
|
+
*
|
|
1776
|
+
* @returns Array of key names
|
|
1777
|
+
*/
|
|
1778
|
+
keys(): string[];
|
|
1779
|
+
/**
|
|
1780
|
+
* Delete all data stored by this script.
|
|
1781
|
+
*
|
|
1782
|
+
* @returns Number of keys deleted
|
|
1783
|
+
*/
|
|
1784
|
+
clear(): number;
|
|
1785
|
+
/**
|
|
1786
|
+
* Get the number of stored keys.
|
|
1787
|
+
*
|
|
1788
|
+
* @returns Number of keys
|
|
1789
|
+
*/
|
|
1790
|
+
size(): number;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Interact event (rightClick, leftClick).
|
|
1794
|
+
* The block property is a unified ScriptableBlock that works for both vanilla and custom blocks.
|
|
1795
|
+
*/
|
|
1796
|
+
export interface ItemInteractEvent {
|
|
1797
|
+
readonly item: ScriptableCustomItem;
|
|
1798
|
+
readonly player: ScriptablePlayer;
|
|
1799
|
+
/** The block that was clicked (null if air was clicked). Use block.type to get the block type. */
|
|
1800
|
+
readonly block: ScriptableBlock | null;
|
|
1801
|
+
readonly blockFace: "UP" | "DOWN" | "NORTH" | "SOUTH" | "EAST" | "WEST" | null;
|
|
1802
|
+
readonly clickType: "LEFT_CLICK" | "RIGHT_CLICK";
|
|
1803
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1804
|
+
readonly isBlockClick: boolean;
|
|
1805
|
+
readonly isAirClick: boolean;
|
|
1806
|
+
readonly isBreaking: boolean;
|
|
1807
|
+
readonly sneaking: boolean;
|
|
1808
|
+
cancel(): void;
|
|
1809
|
+
isCancelled(): boolean;
|
|
1810
|
+
setUseItemInHand(result: "ALLOW" | "DENY" | "DEFAULT"): void;
|
|
1811
|
+
setUseInteractedBlock(result: "ALLOW" | "DENY" | "DEFAULT"): void;
|
|
1812
|
+
}
|
|
1813
|
+
export interface ItemDropEvent {
|
|
1814
|
+
readonly item: ScriptableCustomItem;
|
|
1815
|
+
readonly player: ScriptablePlayer;
|
|
1816
|
+
readonly droppedItem: DroppedItemInfo;
|
|
1817
|
+
cancel(): void;
|
|
1818
|
+
isCancelled(): boolean;
|
|
1819
|
+
}
|
|
1820
|
+
export interface ItemPickupEvent {
|
|
1821
|
+
readonly item: ScriptableCustomItem;
|
|
1822
|
+
readonly player: ScriptablePlayer;
|
|
1823
|
+
readonly pickedUpItem: DroppedItemInfo;
|
|
1824
|
+
readonly remaining: number;
|
|
1825
|
+
cancel(): void;
|
|
1826
|
+
isCancelled(): boolean;
|
|
1827
|
+
}
|
|
1828
|
+
export interface ItemConsumeEvent {
|
|
1829
|
+
readonly item: ScriptableCustomItem;
|
|
1830
|
+
readonly player: ScriptablePlayer;
|
|
1831
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1832
|
+
cancel(): void;
|
|
1833
|
+
isCancelled(): boolean;
|
|
1834
|
+
setItem(itemName: string | null): void;
|
|
1835
|
+
getReplacement(): string | null;
|
|
1836
|
+
}
|
|
1837
|
+
export interface ItemDamageEntityEvent {
|
|
1838
|
+
readonly item: ScriptableCustomItem;
|
|
1839
|
+
readonly player: ScriptablePlayer;
|
|
1840
|
+
readonly target: ScriptableEntity;
|
|
1841
|
+
readonly damage: number;
|
|
1842
|
+
readonly finalDamage: number;
|
|
1843
|
+
readonly cause: string;
|
|
1844
|
+
cancel(): void;
|
|
1845
|
+
isCancelled(): boolean;
|
|
1846
|
+
setDamage(damage: number): void;
|
|
1847
|
+
isCritical(): boolean;
|
|
1848
|
+
}
|
|
1849
|
+
export type ProjectileType = "ARROW" | "SPECTRAL_ARROW" | "FIREBALL" | "SMALL_FIREBALL" | "DRAGON_FIREBALL" | "WITHER_SKULL" | "SNOWBALL" | "EGG" | "TRIDENT" | "WIND_CHARGE" | "LLAMA_SPIT" | "SHULKER_BULLET";
|
|
1850
|
+
export interface ItemShootBowEvent {
|
|
1851
|
+
readonly item: ScriptableCustomItem;
|
|
1852
|
+
readonly player: ScriptablePlayer;
|
|
1853
|
+
readonly force: number;
|
|
1854
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1855
|
+
readonly projectile: ScriptableEntity;
|
|
1856
|
+
readonly consumable: ScriptableCustomItem | null;
|
|
1857
|
+
cancel(): void;
|
|
1858
|
+
isCancelled(): boolean;
|
|
1859
|
+
setConsumeItem(consume: boolean): void;
|
|
1860
|
+
shouldConsumeItem(): boolean;
|
|
1861
|
+
setProjectileType(type: ProjectileType): void;
|
|
1862
|
+
setProjectileSpeed(multiplier: number): void;
|
|
1863
|
+
setProjectileFire(onFire: boolean): void;
|
|
1864
|
+
setProjectileGravity(hasGravity: boolean): void;
|
|
1865
|
+
}
|
|
1866
|
+
export interface ItemHoldEvent {
|
|
1867
|
+
readonly item: ScriptableCustomItem;
|
|
1868
|
+
readonly player: ScriptablePlayer;
|
|
1869
|
+
readonly previousSlot: number;
|
|
1870
|
+
readonly newSlot: number;
|
|
1871
|
+
readonly isStarting: boolean;
|
|
1872
|
+
cancel(): void;
|
|
1873
|
+
isCancelled(): boolean;
|
|
1874
|
+
}
|
|
1875
|
+
export interface ItemSwapHandEvent {
|
|
1876
|
+
readonly item: ScriptableCustomItem;
|
|
1877
|
+
readonly player: ScriptablePlayer;
|
|
1878
|
+
readonly mainHandItem: ScriptableCustomItem | null;
|
|
1879
|
+
readonly offHandItem: ScriptableCustomItem | null;
|
|
1880
|
+
cancel(): void;
|
|
1881
|
+
isCancelled(): boolean;
|
|
1882
|
+
setMainHandItem(itemName: string | null): void;
|
|
1883
|
+
setOffHandItem(itemName: string | null): void;
|
|
1884
|
+
}
|
|
1885
|
+
export interface ItemDurabilityEvent {
|
|
1886
|
+
readonly item: ScriptableCustomItem;
|
|
1887
|
+
readonly player: ScriptablePlayer;
|
|
1888
|
+
readonly damage: number;
|
|
1889
|
+
readonly originalDamage: number;
|
|
1890
|
+
cancel(): void;
|
|
1891
|
+
isCancelled(): boolean;
|
|
1892
|
+
setDamage(damage: number): void;
|
|
1893
|
+
getCurrentDurability(): number;
|
|
1894
|
+
getMaxDurability(): number;
|
|
1895
|
+
getRemainingDurability(): number;
|
|
1896
|
+
}
|
|
1897
|
+
export interface ItemBreakEvent {
|
|
1898
|
+
readonly item: ScriptableCustomItem;
|
|
1899
|
+
readonly player: ScriptablePlayer;
|
|
1900
|
+
}
|
|
1901
|
+
export interface ItemEntityInteractEvent {
|
|
1902
|
+
readonly item: ScriptableCustomItem;
|
|
1903
|
+
readonly player: ScriptablePlayer;
|
|
1904
|
+
readonly target: ScriptableEntity;
|
|
1905
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1906
|
+
readonly clickPosition: [number, number, number] | null;
|
|
1907
|
+
cancel(): void;
|
|
1908
|
+
isCancelled(): boolean;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Block break event - fired when player breaks a block while holding the item.
|
|
1912
|
+
* Works for both vanilla blocks and custom shaper blocks.
|
|
1913
|
+
* Use `block.isCustom` to check if it's a custom block.
|
|
1914
|
+
*/
|
|
1915
|
+
export interface ItemBlockBreakEvent {
|
|
1916
|
+
readonly item: ScriptableCustomItem;
|
|
1917
|
+
readonly player: ScriptablePlayer;
|
|
1918
|
+
/**
|
|
1919
|
+
* The block being broken. Supports both vanilla and custom blocks.
|
|
1920
|
+
* Use `block.isCustom` to distinguish between them.
|
|
1921
|
+
* Use `block.shaper` to access shaper-specific methods for custom blocks.
|
|
1922
|
+
*/
|
|
1923
|
+
readonly block: ScriptableBlock;
|
|
1924
|
+
/** Experience to drop (vanilla blocks only) */
|
|
1925
|
+
readonly expToDrop: number;
|
|
1926
|
+
cancel(): void;
|
|
1927
|
+
isCancelled(): boolean;
|
|
1928
|
+
/** Set experience to drop (vanilla blocks only) */
|
|
1929
|
+
setExpToDrop(exp: number): void;
|
|
1930
|
+
/** Check if items will drop (vanilla blocks only) */
|
|
1931
|
+
isDropItems(): boolean;
|
|
1932
|
+
/** Set whether items should drop (vanilla blocks only) */
|
|
1933
|
+
setDropItems(drop: boolean): void;
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Block place event - fired when player places a block (if item is placeable).
|
|
1937
|
+
* Both block and blockAgainst are unified ScriptableBlock objects.
|
|
1938
|
+
*/
|
|
1939
|
+
export interface ItemBlockPlaceEvent {
|
|
1940
|
+
readonly item: ScriptableCustomItem;
|
|
1941
|
+
readonly player: ScriptablePlayer;
|
|
1942
|
+
/** The block being placed. Use block.type to get the block type. */
|
|
1943
|
+
readonly block: ScriptableBlock;
|
|
1944
|
+
/** The block this was placed against. Use blockAgainst.type to get the block type. */
|
|
1945
|
+
readonly blockAgainst: ScriptableBlock;
|
|
1946
|
+
readonly hand: "MAIN_HAND" | "OFF_HAND";
|
|
1947
|
+
cancel(): void;
|
|
1948
|
+
isCancelled(): boolean;
|
|
1949
|
+
}
|
|
1950
|
+
export interface DroppedItemInfo {
|
|
1951
|
+
readonly itemStack: ScriptableCustomItem | null;
|
|
1952
|
+
readonly location: ScriptableLocation;
|
|
1953
|
+
getVelocity(): [number, number, number];
|
|
1954
|
+
setVelocity(x: number, y: number, z: number): void;
|
|
1955
|
+
getAmount(): number;
|
|
1956
|
+
getPickupDelay(): number;
|
|
1957
|
+
setPickupDelay(delay: number): void;
|
|
1958
|
+
canPickup(): boolean;
|
|
1959
|
+
getUuid(): string;
|
|
1960
|
+
isValid(): boolean;
|
|
1961
|
+
}
|
|
1962
|
+
export interface ScriptableEntity {
|
|
1963
|
+
readonly type: string;
|
|
1964
|
+
readonly uuid: string;
|
|
1965
|
+
readonly name: string;
|
|
1966
|
+
getLocation(): ScriptableLocation;
|
|
1967
|
+
isPlayer(): boolean;
|
|
1968
|
+
asPlayer(): ScriptablePlayer | null;
|
|
1969
|
+
getHealth(): number;
|
|
1970
|
+
getMaxHealth(): number;
|
|
1971
|
+
isDead(): boolean;
|
|
1972
|
+
getWorld(): string;
|
|
1973
|
+
isValid(): boolean;
|
|
1974
|
+
getVelocity(): [number, number, number];
|
|
1975
|
+
isOnGround(): boolean;
|
|
1976
|
+
}
|
|
1977
|
+
/**
|
|
1978
|
+
* Block wrapper that supports both vanilla Bukkit blocks and custom shaper blocks.
|
|
1979
|
+
* Provides a unified API for block interactions in JavaScript.
|
|
1980
|
+
*/
|
|
1981
|
+
export interface ScriptableBlock {
|
|
1982
|
+
/** X coordinate */
|
|
1983
|
+
readonly x: number;
|
|
1984
|
+
/** Y coordinate */
|
|
1985
|
+
readonly y: number;
|
|
1986
|
+
/** Z coordinate */
|
|
1987
|
+
readonly z: number;
|
|
1988
|
+
/** World name */
|
|
1989
|
+
readonly worldName: string;
|
|
1990
|
+
/**
|
|
1991
|
+
* Whether this is a custom shaper block.
|
|
1992
|
+
* @returns true if this wraps a shaper, false for vanilla blocks
|
|
1993
|
+
*/
|
|
1994
|
+
readonly isCustom: boolean;
|
|
1995
|
+
/**
|
|
1996
|
+
* Get the block type.
|
|
1997
|
+
* - For custom blocks: "custom:template_id" (e.g., "custom:tower")
|
|
1998
|
+
* - For vanilla blocks: Material name (e.g., "STONE", "DIRT")
|
|
1999
|
+
*/
|
|
2000
|
+
readonly type: string;
|
|
2001
|
+
/**
|
|
2002
|
+
* Access the underlying shaper instance (null for vanilla blocks).
|
|
2003
|
+
* Use this to access shaper-specific methods and properties.
|
|
2004
|
+
*/
|
|
2005
|
+
readonly shaper: ShaperBlockInstance | null;
|
|
2006
|
+
getLocation(): ScriptableLocation;
|
|
2007
|
+
getWorld(): ScriptableWorld;
|
|
2008
|
+
hasLocation(): boolean;
|
|
2009
|
+
}
|
|
2010
|
+
/**
|
|
2011
|
+
* Sound categories matching Bukkit's SoundCategory enum.
|
|
2012
|
+
* Categories affect which volume slider in player settings controls the sound.
|
|
2013
|
+
*/
|
|
2014
|
+
export type SoundCategory = "MASTER" | "MUSIC" | "RECORDS" | "WEATHER" | "BLOCKS" | "HOSTILE" | "NEUTRAL" | "PLAYERS" | "AMBIENT" | "VOICE";
|
|
2015
|
+
/**
|
|
2016
|
+
* Options for playSound function.
|
|
2017
|
+
*/
|
|
2018
|
+
export interface PlaySoundOptions {
|
|
2019
|
+
/** Volume level (default 1.0, affects range: ~16 blocks per 1.0) */
|
|
2020
|
+
volume?: number;
|
|
2021
|
+
/** Pitch (default 1.0, range 0.5-2.0) */
|
|
2022
|
+
pitch?: number;
|
|
2023
|
+
/** Sound category for player volume settings (optional, let Bukkit handle default) */
|
|
2024
|
+
category?: SoundCategory;
|
|
2025
|
+
/** Seed for randomized sounds (optional) */
|
|
2026
|
+
seed?: number;
|
|
2027
|
+
}
|
|
2028
|
+
/**
|
|
2029
|
+
* Target for sound playback.
|
|
2030
|
+
* - ScriptablePlayer: Only that player hears
|
|
2031
|
+
* - ScriptablePlayer[]: Only those players hear
|
|
2032
|
+
* - "*": All online players hear
|
|
2033
|
+
* - ScriptableLocation: World-based, nearby players hear
|
|
2034
|
+
* - ScriptableEntity: Uses entity location, nearby players hear
|
|
2035
|
+
*/
|
|
2036
|
+
export type SoundTarget = ScriptablePlayer | ScriptablePlayer[] | "*" | ScriptableLocation | ScriptableEntity;
|
|
2037
|
+
/**
|
|
2038
|
+
* Returned by playSound() for tracking and stopping sounds.
|
|
2039
|
+
*/
|
|
2040
|
+
export interface Sound {
|
|
2041
|
+
/** Stop this sound for all original targets */
|
|
2042
|
+
stop(): void;
|
|
2043
|
+
/** Check if the sound has not been stopped */
|
|
2044
|
+
isPlaying(): boolean;
|
|
2045
|
+
/** The sound name that was played */
|
|
2046
|
+
readonly name: string;
|
|
2047
|
+
/** The category used (if specified) */
|
|
2048
|
+
readonly category?: SoundCategory;
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Play a sound to one or more targets.
|
|
2052
|
+
*
|
|
2053
|
+
* @param sound Sound name (vanilla like "ENTITY_EXPERIENCE_ORB_PICKUP" or custom like "custom:my_sound")
|
|
2054
|
+
* @param target Where/who to play the sound to
|
|
2055
|
+
* @param options Optional sound parameters
|
|
2056
|
+
* @returns Sound object for stopping the sound later
|
|
2057
|
+
*
|
|
2058
|
+
* @example
|
|
2059
|
+
* // Simple usage
|
|
2060
|
+
* const sound = playSound("ENTITY_EXPERIENCE_ORB_PICKUP", player);
|
|
2061
|
+
*
|
|
2062
|
+
* // With options
|
|
2063
|
+
* const music = playSound("MUSIC_DISC_13", player, {
|
|
2064
|
+
* volume: 0.5,
|
|
2065
|
+
* category: "RECORDS"
|
|
2066
|
+
* });
|
|
2067
|
+
*
|
|
2068
|
+
* // Stop later
|
|
2069
|
+
* music.stop();
|
|
2070
|
+
*
|
|
2071
|
+
* // Location-based (nearby players hear)
|
|
2072
|
+
* playSound("BLOCK_ANVIL_LAND", location, { volume: 2.0 });
|
|
2073
|
+
*
|
|
2074
|
+
* // Multiple players
|
|
2075
|
+
* playSound("ENTITY_FIREWORK_ROCKET_LAUNCH", [player1, player2]);
|
|
2076
|
+
*
|
|
2077
|
+
* // All online players
|
|
2078
|
+
* playSound("ENTITY_ENDER_DRAGON_DEATH", "*");
|
|
2079
|
+
*/
|
|
2080
|
+
export declare function playSound(sound: string, target: SoundTarget, options?: PlaySoundOptions): Sound;
|
|
2081
|
+
/**
|
|
2082
|
+
* Stop all sounds.
|
|
2083
|
+
*
|
|
2084
|
+
* @param target Optional - if provided, stops all sounds for that player.
|
|
2085
|
+
* If omitted, stops all sounds started by this script.
|
|
2086
|
+
*
|
|
2087
|
+
* @example
|
|
2088
|
+
* // Stop all sounds from this script
|
|
2089
|
+
* stopAllSounds();
|
|
2090
|
+
*
|
|
2091
|
+
* // Stop all sounds for a specific player
|
|
2092
|
+
* stopAllSounds(player);
|
|
2093
|
+
*/
|
|
2094
|
+
export declare function stopAllSounds(target?: ScriptablePlayer): void;
|