redscript-mc 1.2.15 → 1.2.17

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.
@@ -0,0 +1,494 @@
1
+ // builtins.d.mcrs
2
+ // RedScript builtin function declarations
3
+ // Auto-generated by: redscript generate-dts
4
+ // DO NOT EDIT — regenerate with: redscript generate-dts
5
+
6
+ // ──────────────────────────────────────────────────────────────────────
7
+ // Chat & Display
8
+ // ──────────────────────────────────────────────────────────────────────
9
+
10
+ /// Displays a message to all players in chat as the server.
11
+ /// @param message Message to broadcast to all players
12
+ /// @example say("Hello, world!");
13
+ /// @example say("Game has started!");
14
+ declare fn say(message: string): void;
15
+
16
+ /// Sends a private message to a player or selector using tellraw.
17
+ /// @param target Target player or entity selector
18
+ /// @param message Message to send privately
19
+ /// @example tell(@s, "You won!");
20
+ /// @example tell(@a[tag=vip], "Welcome, VIP!");
21
+ declare fn tell(target: selector, message: string): void;
22
+
23
+ /// Alias for tell(). Sends a raw text message using tellraw.
24
+ /// @param target Target player or entity selector
25
+ /// @param message Message text (supports f-string interpolation)
26
+ /// @example tellraw(@s, "Hello!");
27
+ declare fn tellraw(target: selector, message: string): void;
28
+
29
+ /// Sends a message to all players in chat (@a).
30
+ /// @param message Message to broadcast
31
+ /// @example announce("Round 1 starts in 3 seconds!");
32
+ declare fn announce(message: string): void;
33
+
34
+ /// Shows a large title on screen for target players.
35
+ /// @param target Target player(s)
36
+ /// @param message Title text to display
37
+ /// @example title(@a, "Round 1");
38
+ /// @example title(@s, "You Win!");
39
+ declare fn title(target: selector, message: string): void;
40
+
41
+ /// Shows subtitle text below the main title on screen.
42
+ /// @param target Target player(s)
43
+ /// @param message Subtitle text (appears below title)
44
+ /// @example subtitle(@a, "Fight!");
45
+ declare fn subtitle(target: selector, message: string): void;
46
+
47
+ /// Displays text in the action bar (above the hotbar).
48
+ /// @param target Target player(s)
49
+ /// @param message Action bar text (above hotbar)
50
+ /// @example actionbar(@a, "⏱ ${time}s remaining");
51
+ declare fn actionbar(target: selector, message: string): void;
52
+
53
+ /// Sets title display timing in ticks. 20 ticks = 1 second.
54
+ /// @param target Target player(s)
55
+ /// @param fadeIn Fade-in duration in ticks
56
+ /// @param stay Stay duration in ticks
57
+ /// @param fadeOut Fade-out duration in ticks
58
+ /// @example title_times(@a, 10, 40, 10);
59
+ /// @example // Show for 2 seconds
60
+ declare fn title_times(target: selector, fadeIn: int, stay: int, fadeOut: int): void;
61
+
62
+ // ──────────────────────────────────────────────────────────────────────
63
+ // Player
64
+ // ──────────────────────────────────────────────────────────────────────
65
+
66
+ /// Gives item(s) to a player.
67
+ /// @param target Target player(s)
68
+ /// @param item Item ID (e.g. "minecraft:diamond")
69
+ /// @param count Number of items to give (optional)
70
+ /// @param nbt Optional NBT data for the item (optional)
71
+ /// @example give(@s, "minecraft:diamond", 5);
72
+ /// @example give(@a, "minecraft:apple");
73
+ /// @example give(@s, "minecraft:diamond_sword", 1, "{Enchantments:[{id:\"minecraft:sharpness\",lvl:5s}]}");
74
+ declare fn give(target: selector, item: string, count: int = 1, nbt: string): void;
75
+
76
+ /// Kills the target entity. Defaults to the executing entity (@s).
77
+ /// @param target Target to kill (default: @s) (optional)
78
+ /// @example kill(@e[type=minecraft:zombie]);
79
+ /// @example kill(@s);
80
+ /// @example kill(@e[tag=enemy]);
81
+ declare fn kill(target: selector = @s): void;
82
+
83
+ /// Applies a status effect to an entity.
84
+ /// @param target Target entity or player
85
+ /// @param effect Effect ID (e.g. "minecraft:speed")
86
+ /// @param duration Duration in seconds (optional)
87
+ /// @param amplifier Effect level (0-255, where 0 = level 1) (optional)
88
+ /// @example effect(@s, "minecraft:speed", 60, 1);
89
+ /// @example effect(@a, "minecraft:regeneration", 10);
90
+ /// @example effect(@e[type=minecraft:zombie], "minecraft:slowness", 20, 2);
91
+ declare fn effect(target: selector, effect: string, duration: int = 30, amplifier: int = 0): void;
92
+
93
+ /// Removes a status effect from an entity, or clears all effects.
94
+ /// @param target Target entity or player
95
+ /// @param effect Effect to remove (omit to clear all) (optional)
96
+ /// @example effect_clear(@s, "minecraft:poison");
97
+ /// @example effect_clear(@a);
98
+ declare fn effect_clear(target: selector, effect: string): void;
99
+
100
+ /// Removes items from a player's inventory.
101
+ /// @param target Target player
102
+ /// @param item Specific item to remove (omit to clear all) (optional)
103
+ /// @example clear(@s, "minecraft:dirt");
104
+ /// @example clear(@a);
105
+ declare fn clear(target: selector, item: string): void;
106
+
107
+ /// Kicks a player from the server with an optional reason.
108
+ /// @param player Target player to kick
109
+ /// @param reason Kick message shown to the player (optional)
110
+ /// @example kick(@s, "You lost!");
111
+ /// @example kick(@p, "AFK too long");
112
+ declare fn kick(player: selector, reason: string): void;
113
+
114
+ /// Adds experience points or levels to a player.
115
+ /// @param target Target player
116
+ /// @param amount Amount of XP to add
117
+ /// @param type "points" or "levels" (optional)
118
+ /// @example xp_add(@s, 100);
119
+ /// @example xp_add(@s, 5, "levels");
120
+ declare fn xp_add(target: selector, amount: int, type: string = points): void;
121
+
122
+ /// Sets a player's experience points or levels.
123
+ /// @param target Target player
124
+ /// @param amount New XP value
125
+ /// @param type "points" or "levels" (optional)
126
+ /// @example xp_set(@s, 0, "levels");
127
+ /// @example xp_set(@s, 500);
128
+ declare fn xp_set(target: selector, amount: int, type: string = points): void;
129
+
130
+ // ──────────────────────────────────────────────────────────────────────
131
+ // World & Block
132
+ // ──────────────────────────────────────────────────────────────────────
133
+
134
+ /// Teleports an entity to a player or position.
135
+ /// @param target Entity to teleport
136
+ /// @param destination Target player or BlockPos coordinates
137
+ /// @example tp(@s, (0, 64, 0));
138
+ /// @example tp(@a, @s);
139
+ /// @example tp(@s, (~0, ~10, ~0));
140
+ declare fn tp(target: selector, destination: selector): void;
141
+
142
+ /// @deprecated Use tp() instead. Teleports an entity to a position.
143
+ /// @param target Entity to teleport
144
+ /// @param destination Target player or position
145
+ /// @example tp(@s, (0, 64, 0)); // use tp instead
146
+ declare fn tp_to(target: selector, destination: selector): void;
147
+
148
+ /// Places a block at the specified coordinates.
149
+ /// @param pos Block position, e.g. (0, 64, 0) or (~1, ~0, ~0)
150
+ /// @param block Block ID (e.g. "minecraft:stone")
151
+ /// @example setblock((0, 64, 0), "minecraft:stone");
152
+ /// @example setblock((~1, ~0, ~0), "minecraft:air");
153
+ declare fn setblock(pos: BlockPos, block: string): void;
154
+
155
+ /// Fills a cuboid region with a specified block.
156
+ /// @param from Start corner of the region
157
+ /// @param to End corner of the region
158
+ /// @param block Block to fill with
159
+ /// @example fill((0, 64, 0), (10, 64, 10), "minecraft:grass_block");
160
+ /// @example fill((~-5, ~-1, ~-5), (~5, ~-1, ~5), "minecraft:bedrock");
161
+ declare fn fill(from: BlockPos, to: BlockPos, block: string): void;
162
+
163
+ /// Clones a region of blocks to a new location.
164
+ /// @param from Source region start corner
165
+ /// @param to Source region end corner
166
+ /// @param dest Destination corner
167
+ /// @example clone((0,64,0), (10,64,10), (20,64,0));
168
+ declare fn clone(from: BlockPos, to: BlockPos, dest: BlockPos): void;
169
+
170
+ /// Summons an entity at the specified position.
171
+ /// @param type Entity type ID (e.g. "minecraft:zombie")
172
+ /// @param x X coordinate (default: ~) (optional)
173
+ /// @param y Y coordinate (default: ~) (optional)
174
+ /// @param z Z coordinate (default: ~) (optional)
175
+ /// @param nbt Optional NBT data for the entity (optional)
176
+ /// @example summon("minecraft:zombie", ~0, ~0, ~0);
177
+ /// @example summon("minecraft:armor_stand", (0, 64, 0));
178
+ /// @example summon("minecraft:zombie", ~0, ~0, ~0, "{CustomName:\"Boss\"}");
179
+ declare fn summon(type: string, x: coord = ~, y: coord = ~, z: coord = ~, nbt: string): void;
180
+
181
+ /// Spawns a particle effect at the specified position.
182
+ /// @param name Particle type ID (e.g. "minecraft:flame")
183
+ /// @param x X coordinate (optional)
184
+ /// @param y Y coordinate (optional)
185
+ /// @param z Z coordinate (optional)
186
+ /// @example particle("minecraft:flame", (~0, ~1, ~0));
187
+ /// @example particle("minecraft:explosion", (0, 100, 0));
188
+ declare fn particle(name: string, x: coord = ~, y: coord = ~, z: coord = ~): void;
189
+
190
+ /// Plays a sound effect for target players.
191
+ /// @param sound Sound event ID (e.g. "entity.experience_orb.pickup")
192
+ /// @param source Sound category: "master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"
193
+ /// @param target Target player to hear the sound
194
+ /// @param x X origin position (optional)
195
+ /// @param y Y origin position (optional)
196
+ /// @param z Z origin position (optional)
197
+ /// @param volume Volume (default: 1.0) (optional)
198
+ /// @param pitch Pitch (default: 1.0) (optional)
199
+ /// @param minVolume Minimum volume for distant players (optional)
200
+ /// @example playsound("entity.experience_orb.pickup", "player", @s);
201
+ /// @example playsound("ui.toast.challenge_complete", "master", @a);
202
+ declare fn playsound(sound: string, source: string, target: selector, x: coord, y: coord, z: coord, volume: float = 1.0, pitch: float = 1.0, minVolume: float): void;
203
+
204
+ /// Sets the weather condition.
205
+ /// @param type "clear", "rain", or "thunder"
206
+ /// @example weather("clear");
207
+ /// @example weather("thunder");
208
+ declare fn weather(type: string): void;
209
+
210
+ /// Sets the world time.
211
+ /// @param value Time in ticks, or "day"/"night"/"noon"/"midnight"
212
+ /// @example time_set(0); // dawn
213
+ /// @example time_set("midnight");
214
+ declare fn time_set(value: string): void;
215
+
216
+ /// Advances the world time by a number of ticks.
217
+ /// @param ticks Number of ticks to advance
218
+ /// @example time_add(6000); // advance by half a day
219
+ declare fn time_add(ticks: int): void;
220
+
221
+ /// Sets a gamerule value.
222
+ /// @param rule Gamerule name (e.g. "keepInventory")
223
+ /// @param value New value (true/false for boolean rules, integer for numeric)
224
+ /// @example gamerule("keepInventory", true);
225
+ /// @example gamerule("randomTickSpeed", 3);
226
+ declare fn gamerule(rule: string, value: string): void;
227
+
228
+ /// Sets the game difficulty.
229
+ /// @param level "peaceful", "easy", "normal", or "hard"
230
+ /// @example difficulty("hard");
231
+ /// @example difficulty("peaceful");
232
+ declare fn difficulty(level: string): void;
233
+
234
+ // ──────────────────────────────────────────────────────────────────────
235
+ // Entities & Tags
236
+ // ──────────────────────────────────────────────────────────────────────
237
+
238
+ /// Adds a scoreboard tag to an entity.
239
+ /// @param target Target entity
240
+ /// @param tag Tag name to add
241
+ /// @example tag_add(@s, "hasKey");
242
+ /// @example tag_add(@e[type=minecraft:zombie], "boss");
243
+ declare fn tag_add(target: selector, tag: string): void;
244
+
245
+ /// Removes a scoreboard tag from an entity.
246
+ /// @param target Target entity
247
+ /// @param tag Tag name to remove
248
+ /// @example tag_remove(@s, "hasKey");
249
+ declare fn tag_remove(target: selector, tag: string): void;
250
+
251
+ // ──────────────────────────────────────────────────────────────────────
252
+ // Scoreboard
253
+ // ──────────────────────────────────────────────────────────────────────
254
+
255
+ /// Reads a value from a vanilla MC scoreboard objective.
256
+ /// @param target Player, entity, or fake player name (e.g. "#counter")
257
+ /// @param objective Scoreboard objective name
258
+ /// @returns int
259
+ /// @example let hp: int = scoreboard_get(@s, "health");
260
+ /// @example let kills: int = scoreboard_get(@s, "kills");
261
+ declare fn scoreboard_get(target: selector, objective: string): int;
262
+
263
+ /// Alias for scoreboard_get(). Reads a value from a scoreboard.
264
+ /// @param target Player, entity, or fake player name
265
+ /// @param objective Scoreboard objective name
266
+ /// @returns int
267
+ /// @example let kills: int = score(@s, "kills");
268
+ declare fn score(target: selector, objective: string): int;
269
+
270
+ /// Sets a value in a vanilla MC scoreboard objective.
271
+ /// @param target Player, entity, or fake player
272
+ /// @param objective Objective name
273
+ /// @param value New score value
274
+ /// @example scoreboard_set("#game", "timer", 300);
275
+ /// @example scoreboard_set(@s, "lives", 3);
276
+ declare fn scoreboard_set(target: selector, objective: string, value: int): void;
277
+
278
+ /// Displays a scoreboard objective in a display slot.
279
+ /// @param slot "list", "sidebar", or "belowName"
280
+ /// @param objective Objective name to display
281
+ /// @example scoreboard_display("sidebar", "kills");
282
+ declare fn scoreboard_display(slot: string, objective: string): void;
283
+
284
+ /// Clears the display in a scoreboard slot.
285
+ /// @param slot "list", "sidebar", or "belowName"
286
+ /// @example scoreboard_hide("sidebar");
287
+ declare fn scoreboard_hide(slot: string): void;
288
+
289
+ /// Creates a new scoreboard objective.
290
+ /// @param name Objective name
291
+ /// @param criteria Criteria (e.g. "dummy", "playerKillCount")
292
+ /// @param displayName Optional display name (optional)
293
+ /// @example scoreboard_add_objective("kills", "playerKillCount");
294
+ /// @example scoreboard_add_objective("timer", "dummy", "Game Timer");
295
+ declare fn scoreboard_add_objective(name: string, criteria: string, displayName: string): void;
296
+
297
+ /// Removes a scoreboard objective.
298
+ /// @param name Objective name to remove
299
+ /// @example scoreboard_remove_objective("kills");
300
+ declare fn scoreboard_remove_objective(name: string): void;
301
+
302
+ // ──────────────────────────────────────────────────────────────────────
303
+ // Random
304
+ // ──────────────────────────────────────────────────────────────────────
305
+
306
+ /// Generates a random integer in range [min, max] using scoreboard arithmetic. Compatible with all MC versions.
307
+ /// @param min Minimum value (inclusive)
308
+ /// @param max Maximum value (inclusive)
309
+ /// @returns int
310
+ /// @example let roll: int = random(1, 6);
311
+ /// @example let chance: int = random(0, 99);
312
+ declare fn random(min: int, max: int): int;
313
+
314
+ /// Generates a random integer using /random command (MC 1.20.3+). Faster and more reliable than random().
315
+ /// @param min Minimum value (inclusive)
316
+ /// @param max Maximum value (inclusive)
317
+ /// @returns int
318
+ /// @example let n: int = random_native(1, 100);
319
+ declare fn random_native(min: int, max: int): int;
320
+
321
+ /// Resets a random sequence with an optional seed (MC 1.20.3+).
322
+ /// @param sequence Sequence name (namespaced, e.g. "mypack:loot")
323
+ /// @param seed Seed value (optional)
324
+ /// @example random_sequence("mypack:loot", 42);
325
+ declare fn random_sequence(sequence: string, seed: int = 0): void;
326
+
327
+ // ──────────────────────────────────────────────────────────────────────
328
+ // Data (NBT)
329
+ // ──────────────────────────────────────────────────────────────────────
330
+
331
+ /// Reads NBT data from an entity, block, or storage into an integer variable.
332
+ /// @param targetType "entity", "block", or "storage"
333
+ /// @param target Target selector or storage path
334
+ /// @param path NBT path (e.g. "Health")
335
+ /// @param scale Scale factor (optional)
336
+ /// @returns int
337
+ /// @example let hp: int = data_get("entity", "@s", "Health");
338
+ /// @example let val: int = data_get("storage", "mypack:data", "myKey");
339
+ declare fn data_get(targetType: string, target: string, path: string, scale: float = 1): int;
340
+
341
+ /// Merges NBT data into an entity, block, or storage.
342
+ /// @param target Target entity selector or block position
343
+ /// @param nbt NBT data to merge (struct literal or string)
344
+ /// @example data_merge(@s, { Invisible: 1b, Silent: 1b });
345
+ declare fn data_merge(target: selector, nbt: string): void;
346
+
347
+ // ──────────────────────────────────────────────────────────────────────
348
+ // Boss Bar
349
+ // ──────────────────────────────────────────────────────────────────────
350
+
351
+ /// Creates a new boss bar.
352
+ /// @param id Boss bar ID (namespaced, e.g. "minecraft:health")
353
+ /// @param name Display name
354
+ /// @example bossbar_add("mymod:timer", "Time Left");
355
+ declare fn bossbar_add(id: string, name: string): void;
356
+
357
+ /// Sets the current value of a boss bar.
358
+ /// @param id Boss bar ID
359
+ /// @param value Current value
360
+ /// @example bossbar_set_value("mymod:timer", 60);
361
+ declare fn bossbar_set_value(id: string, value: int): void;
362
+
363
+ /// Sets the maximum value of a boss bar.
364
+ /// @param id Boss bar ID
365
+ /// @param max Maximum value
366
+ /// @example bossbar_set_max("mymod:timer", 300);
367
+ declare fn bossbar_set_max(id: string, max: int): void;
368
+
369
+ /// Sets the color of a boss bar.
370
+ /// @param id Boss bar ID
371
+ /// @param color "blue", "green", "pink", "purple", "red", "white", or "yellow"
372
+ /// @example bossbar_set_color("mymod:timer", "red");
373
+ declare fn bossbar_set_color(id: string, color: string): void;
374
+
375
+ /// Sets the style (segmentation) of a boss bar.
376
+ /// @param id Boss bar segmentation style
377
+ /// @param style "notched_6", "notched_10", "notched_12", "notched_20", or "progress"
378
+ /// @example bossbar_set_style("mymod:timer", "notched_10");
379
+ declare fn bossbar_set_style(id: string, style: string): void;
380
+
381
+ /// Shows or hides a boss bar.
382
+ /// @param id Boss bar ID
383
+ /// @param visible Visibility state (true = show, false = hide)
384
+ /// @example bossbar_set_visible("mymod:timer", true);
385
+ declare fn bossbar_set_visible(id: string, visible: bool): void;
386
+
387
+ /// Sets which players can see the boss bar.
388
+ /// @param id Boss bar ID
389
+ /// @param target Players who should see the boss bar
390
+ /// @example bossbar_set_players("mymod:timer", @a);
391
+ declare fn bossbar_set_players(id: string, target: selector): void;
392
+
393
+ /// Removes a boss bar.
394
+ /// @param id Boss bar ID to remove
395
+ /// @example bossbar_remove("mymod:timer");
396
+ declare fn bossbar_remove(id: string): void;
397
+
398
+ /// Gets the current value of a boss bar.
399
+ /// @param id Boss bar ID
400
+ /// @returns int
401
+ /// @example let v: int = bossbar_get_value("mymod:timer");
402
+ declare fn bossbar_get_value(id: string): int;
403
+
404
+ // ──────────────────────────────────────────────────────────────────────
405
+ // Teams
406
+ // ──────────────────────────────────────────────────────────────────────
407
+
408
+ /// Creates a new team.
409
+ /// @param name Team name
410
+ /// @param displayName Optional display name (optional)
411
+ /// @example team_add("red");
412
+ /// @example team_add("blue", "Blue Team");
413
+ declare fn team_add(name: string, displayName: string): void;
414
+
415
+ /// Removes a team.
416
+ /// @param name Team name to remove
417
+ /// @example team_remove("red");
418
+ declare fn team_remove(name: string): void;
419
+
420
+ /// Adds entities to a team.
421
+ /// @param name Team name to join
422
+ /// @param target Entities to add to the team
423
+ /// @example team_join("red", @s);
424
+ /// @example team_join("blue", @a[tag=blue_team]);
425
+ declare fn team_join(name: string, target: selector): void;
426
+
427
+ /// Removes entities from their current team.
428
+ /// @param target Entities to remove from their team
429
+ /// @example team_leave(@s);
430
+ declare fn team_leave(target: selector): void;
431
+
432
+ /// Sets a team option/property.
433
+ /// @param name Team name
434
+ /// @param option Option name (e.g. "color", "friendlyFire", "prefix")
435
+ /// @param value Option value
436
+ /// @example team_option("red", "color", "red");
437
+ /// @example team_option("blue", "friendlyFire", "false");
438
+ declare fn team_option(name: string, option: string, value: string): void;
439
+
440
+ // ──────────────────────────────────────────────────────────────────────
441
+ // Collections (Set)
442
+ // ──────────────────────────────────────────────────────────────────────
443
+
444
+ /// Creates a new unique set backed by NBT storage. Returns the set ID.
445
+ /// @returns string
446
+ /// @example let enemies: string = set_new();
447
+ /// @example set_add(enemies, "@s");
448
+ declare fn set_new(): string;
449
+
450
+ /// Adds a value to a set (no-op if already present).
451
+ /// @param setId Set ID returned by set_new()
452
+ /// @param value Value to add
453
+ /// @example set_add(enemies, "@s");
454
+ declare fn set_add(setId: string, value: string): void;
455
+
456
+ /// Returns 1 if the set contains the value, 0 otherwise.
457
+ /// @param setId Set ID
458
+ /// @param value Value to check
459
+ /// @returns int
460
+ /// @example if set_contains(enemies, "@s") { kill(@s); }
461
+ declare fn set_contains(setId: string, value: string): int;
462
+
463
+ /// Removes a value from a set.
464
+ /// @param setId Set ID
465
+ /// @param value Value to remove
466
+ /// @example set_remove(enemies, "@s");
467
+ declare fn set_remove(setId: string, value: string): void;
468
+
469
+ /// Removes all values from a set.
470
+ /// @param setId Set ID to clear
471
+ /// @example set_clear(enemies);
472
+ declare fn set_clear(setId: string): void;
473
+
474
+ // ──────────────────────────────────────────────────────────────────────
475
+ // Timers
476
+ // ──────────────────────────────────────────────────────────────────────
477
+
478
+ /// Executes a callback function after a delay (in ticks).
479
+ /// @param delay Delay in ticks before executing the callback
480
+ /// @param callback Lambda function to execute after delay
481
+ /// @example setTimeout(100, () => { say("5 seconds passed!"); });
482
+ declare fn setTimeout(delay: int, callback: string): void;
483
+
484
+ /// Executes a callback function repeatedly at a fixed interval. Returns an interval ID.
485
+ /// @param interval Interval in ticks between executions
486
+ /// @param callback Lambda function to execute repeatedly
487
+ /// @returns int
488
+ /// @example let timer: int = setInterval(20, () => { say("Every second!"); });
489
+ declare fn setInterval(interval: int, callback: string): int;
490
+
491
+ /// Cancels a repeating interval created by setInterval().
492
+ /// @param id Interval ID returned by setInterval()
493
+ /// @example clearInterval(timer);
494
+ declare fn clearInterval(id: int): void;