@kradle/challenges-sdk 0.5.3 → 0.6.1
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/LLM_README.md +680 -37
- package/README.md +86 -4
- package/dist/actions.d.ts +639 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +798 -2
- package/dist/actions.js.map +1 -1
- package/dist/api_utils.d.ts +20 -0
- package/dist/api_utils.d.ts.map +1 -1
- package/dist/api_utils.js +36 -1
- package/dist/api_utils.js.map +1 -1
- package/dist/challenge.d.ts +1 -0
- package/dist/challenge.d.ts.map +1 -1
- package/dist/challenge.js +68 -25
- package/dist/challenge.js.map +1 -1
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +29 -1
- package/dist/types.js.map +1 -1
- package/package.json +4 -3
package/dist/actions.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type GAMERULES, type JSONTextComponent, type Score, SelectorClass, type SingleEntityArgument } from "sandstone";
|
|
2
2
|
import type { ATTRIBUTES, BLOCKS, ENTITY_TYPES, ITEMS } from "sandstone/arguments/generated";
|
|
3
|
+
import type { ConditionType } from "sandstone/flow";
|
|
3
4
|
import type { LiteralStringUnion } from "./utils";
|
|
4
5
|
export type TargetNames = LiteralStringUnion<"all" | "self"> | SelectorClass<any, any>;
|
|
5
6
|
export declare function mapTarget(target: string | SelectorClass): SelectorClass<any, any> | string;
|
|
@@ -11,6 +12,59 @@ export declare const Actions: {
|
|
|
11
12
|
announce: ({ message }: {
|
|
12
13
|
message: JSONTextComponent;
|
|
13
14
|
}) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Pick `count` random participants and tag them. Used to assign hidden
|
|
17
|
+
* roles in social-deduction challenges — combine with `Actions.tellraw` to
|
|
18
|
+
* privately notify each tagged participant of their assignment.
|
|
19
|
+
*
|
|
20
|
+
* Uses Minecraft's `sort=random,limit=N` selector behavior. The selection
|
|
21
|
+
* happens at command time (typically `start_challenge`), so it's stable
|
|
22
|
+
* for the rest of the run.
|
|
23
|
+
*
|
|
24
|
+
* @example Saboteur assignment in a 4-player game:
|
|
25
|
+
* ```ts
|
|
26
|
+
* start_challenge: () => {
|
|
27
|
+
* Actions.assignRandomTag({ tag: "saboteur", count: 1 });
|
|
28
|
+
* // Then DM each tagged participant their secret role:
|
|
29
|
+
* Actions.tellraw({
|
|
30
|
+
* target: Selector("@a", { tag: "saboteur" }),
|
|
31
|
+
* message: [{ text: "🔪 You're the saboteur. Stop the miners.", color: "red" }],
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* `count` is capped to the number of participants — over-asking just tags
|
|
37
|
+
* everyone available.
|
|
38
|
+
*/
|
|
39
|
+
assignRandomTag: ({ tag: tagName, count }: {
|
|
40
|
+
tag: string;
|
|
41
|
+
count: number;
|
|
42
|
+
}) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Pick a uniform random integer in `[min, max]` (both inclusive) and
|
|
45
|
+
* return it as an anonymous `Score`. Wraps Minecraft's `random value`
|
|
46
|
+
* command, which Sandstone does not expose as a typed primitive — this
|
|
47
|
+
* helper is the abstraction so that user code never has to write `raw`
|
|
48
|
+
* for randomness.
|
|
49
|
+
*
|
|
50
|
+
* Use to randomize challenge state at `start_challenge` (which goal block
|
|
51
|
+
* is "the" goal, which player a saboteur is paired with for a side-quest,
|
|
52
|
+
* etc.) so behavior isn't gameable across runs.
|
|
53
|
+
*
|
|
54
|
+
* @example Pick one of 4 goal directions per run:
|
|
55
|
+
* ```ts
|
|
56
|
+
* goal_index: { type: "global", default: 0 },
|
|
57
|
+
*
|
|
58
|
+
* start_challenge: () => {
|
|
59
|
+
* variables.goal_index.score.set(Actions.randomInt({ min: 0, max: 3 }));
|
|
60
|
+
* // Then branch: _.if(goal_index.equalTo(0), () => place at N), etc.
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
randomInt: ({ min, max }: {
|
|
65
|
+
min: number;
|
|
66
|
+
max: number;
|
|
67
|
+
}) => Score;
|
|
14
68
|
/**
|
|
15
69
|
* Clear the inventory of a target.
|
|
16
70
|
* @param {TargetNames} target - The target to clear the inventory of.
|
|
@@ -34,6 +88,7 @@ export declare const Actions: {
|
|
|
34
88
|
* @param {number} y2 - The y coordinate of the region.
|
|
35
89
|
* @param {number} z2 - The z coordinate of the region.
|
|
36
90
|
* @param {boolean} absolute - Whether the coordinates are absolute or relative.
|
|
91
|
+
* @param {"fill" | "line" | "pyramid"} mode - Required. How to fill the region: `"fill"` (solid box between the two points), `"line"` (1-wide line from point 1 to point 2), or `"pyramid"` (pyramid `|y2|` blocks tall, stepping in by 2 per layer). Omitting it throws `Invalid fill mode` at build time.
|
|
37
92
|
*/
|
|
38
93
|
fill: ({ block, x1, y1, z1, x2, y2, z2, absolute, mode, }: {
|
|
39
94
|
block: BLOCKS;
|
|
@@ -86,6 +141,35 @@ export declare const Actions: {
|
|
|
86
141
|
kill: ({ selector }: {
|
|
87
142
|
selector: TargetNames;
|
|
88
143
|
}) => void;
|
|
144
|
+
/**
|
|
145
|
+
* Set the gamemode of a target. Useful for moving an eliminated player
|
|
146
|
+
* to spectator without killing them (preserves the entity, lets them
|
|
147
|
+
* watch the rest of the run).
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* Actions.setGamemode({ target: "self", mode: "spectator" });
|
|
151
|
+
* Actions.setGamemode({ target: "all", mode: "adventure" });
|
|
152
|
+
*/
|
|
153
|
+
setGamemode: ({ target, mode, }: {
|
|
154
|
+
target: TargetNames;
|
|
155
|
+
mode: "survival" | "creative" | "adventure" | "spectator";
|
|
156
|
+
}) => void;
|
|
157
|
+
/**
|
|
158
|
+
* Eliminate a participant from the active round: switch them to
|
|
159
|
+
* spectator mode (so they can still observe but can't act). Sister
|
|
160
|
+
* helper to `kill`, intended for vote-out / king-of-the-hill / battle
|
|
161
|
+
* royale style games where elimination shouldn't end the agent's
|
|
162
|
+
* connection.
|
|
163
|
+
*
|
|
164
|
+
* Note: this only flips gamemode. The challenge author is responsible
|
|
165
|
+
* for any per-player tracking variable (e.g. `is_alive`).
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* Actions.eliminate({ target: "self" });
|
|
169
|
+
*/
|
|
170
|
+
eliminate: ({ target }: {
|
|
171
|
+
target: TargetNames;
|
|
172
|
+
}) => void;
|
|
89
173
|
/**
|
|
90
174
|
* Set an attribute for a target.
|
|
91
175
|
* @param {ATTRIBUTES} attribute_ - The attribute to set.
|
|
@@ -123,6 +207,38 @@ export declare const Actions: {
|
|
|
123
207
|
setEndState: ({ endState }: {
|
|
124
208
|
endState: string;
|
|
125
209
|
}) => void;
|
|
210
|
+
/**
|
|
211
|
+
* For each `(name, condition)` pair, emit `_.if(condition, () =>
|
|
212
|
+
* setEndState(name))` at the current codegen location. Where (and how
|
|
213
|
+
* often) those checks run is up to the caller — `events.on_tick` for a
|
|
214
|
+
* per-tick check, `custom_events.actions` for a single fire, etc.
|
|
215
|
+
*
|
|
216
|
+
* Returns a `ConditionType` that is true when at least one of the input
|
|
217
|
+
* conditions is true (i.e. an end-state was applied). Hand it to
|
|
218
|
+
* `.end_condition()` if you want the game to end as soon as any end-state
|
|
219
|
+
* has been set; ignore it if the game's end is gated on something else
|
|
220
|
+
* (timer, separate condition).
|
|
221
|
+
*
|
|
222
|
+
* Note: conditions are evaluated in whatever execution context the caller
|
|
223
|
+
* is in. From `on_tick` that's the server entity, where per-player score
|
|
224
|
+
* reads silently fail — see `Actions.maxPlayerScore` for the per-player →
|
|
225
|
+
* global bridge.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* let endReached: ConditionType | undefined;
|
|
229
|
+
* const challenge = createChallenge({...});
|
|
230
|
+
* challenge
|
|
231
|
+
* .events((vars) => ({
|
|
232
|
+
* on_tick: () => {
|
|
233
|
+
* endReached = Actions.setEndStates({
|
|
234
|
+
* winner_found: vars.top_kills.greaterOrEqualThan(20),
|
|
235
|
+
* all_dead: vars.alive_players.equalTo(0),
|
|
236
|
+
* });
|
|
237
|
+
* },
|
|
238
|
+
* }))
|
|
239
|
+
* .end_condition(() => endReached!); // game ends as soon as any branch fires
|
|
240
|
+
*/
|
|
241
|
+
setEndStates: (endStates: Record<string, ConditionType>) => ConditionType;
|
|
126
242
|
/**
|
|
127
243
|
* Set a block at a specific location.
|
|
128
244
|
*/
|
|
@@ -184,6 +300,120 @@ export declare const Actions: {
|
|
|
184
300
|
variable: Score;
|
|
185
301
|
value: number | Score;
|
|
186
302
|
}) => void;
|
|
303
|
+
/**
|
|
304
|
+
* Selector that matches `@s` only when standing on the block at the
|
|
305
|
+
* given absolute coordinate. Use this anywhere you'd otherwise have
|
|
306
|
+
* written `Selector("@s", { x, y, z })` — that bare form does NOT
|
|
307
|
+
* constrain position (Minecraft treats x/y/z as the selector origin
|
|
308
|
+
* for distance math, not as a position filter), so the condition
|
|
309
|
+
* silently passes for everyone. This helper bakes in the right
|
|
310
|
+
* `dx: 0, dy: 1, dz: 0` volume covering the block above and the
|
|
311
|
+
* head space, so the selector matches only when the player's feet
|
|
312
|
+
* are inside the 1×1×1 column at (x, y+1, z).
|
|
313
|
+
*
|
|
314
|
+
* @param {number} x - X of the block being stood on.
|
|
315
|
+
* @param {number} y - Y of the block being stood on (the player's feet are at y+1).
|
|
316
|
+
* @param {number} z - Z of the block being stood on.
|
|
317
|
+
* @param {string} [role] - Optional role tag the player must also have.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* // Trigger alice_shared when Alice steps on her pad block.
|
|
321
|
+
* alice_shared: {
|
|
322
|
+
* type: "global",
|
|
323
|
+
* default: 0,
|
|
324
|
+
* updater: (value) => {
|
|
325
|
+
* _.if(value.equalTo(0), () => {
|
|
326
|
+
* forEveryPlayer(() => {
|
|
327
|
+
* _.if(Actions.standingOnBlock({ x: ALICE_PAD.x, y: ALICE_PAD.y, z: ALICE_PAD.z, role: "alice" }), () => {
|
|
328
|
+
* value.set(1);
|
|
329
|
+
* });
|
|
330
|
+
* });
|
|
331
|
+
* });
|
|
332
|
+
* },
|
|
333
|
+
* },
|
|
334
|
+
*/
|
|
335
|
+
standingOnBlock: ({ x, y, z, role }: {
|
|
336
|
+
x: number;
|
|
337
|
+
y: number;
|
|
338
|
+
z: number;
|
|
339
|
+
role?: string;
|
|
340
|
+
}) => SelectorClass<true, true>;
|
|
341
|
+
/**
|
|
342
|
+
* Condition that matches `@s` when the player has voted in `voteId` (any
|
|
343
|
+
* option), or — when `option` is given — only when they voted for that
|
|
344
|
+
* specific option. Agents cast votes with skills.voteForOption; the arena
|
|
345
|
+
* records each pick as the player tags kradle.voteOptions.<voteId> and
|
|
346
|
+
* kradle.voteOptions.<voteId>.<option>.
|
|
347
|
+
*
|
|
348
|
+
* It matches `@s`, so use it as a CONDITION in a player context — inside
|
|
349
|
+
* `forEveryPlayer(...)`, or in `setEndStates` / win conditions. Don't hand it
|
|
350
|
+
* to `execute.as(...)` from a tick/load context: `@s` resolves to no one
|
|
351
|
+
* there, so the command runs for nobody (the context-safety check flags this).
|
|
352
|
+
*
|
|
353
|
+
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
354
|
+
* @param {string} [option] - Optional specific option, e.g. "red".
|
|
355
|
+
* @returns {ConditionType} a per-player condition for `_.if` / win conditions.
|
|
356
|
+
* @throws {Error} If the vote or option isn't declared in config.ts's votingOptions.
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* // Teleport everyone who picked the red room.
|
|
360
|
+
* forEveryPlayer(() => {
|
|
361
|
+
* _.if(Actions.votedFor("selectroom", "red"), () => {
|
|
362
|
+
* Actions.teleport({ target: "self", x: 10, y: -60, z: 10, absolute: true });
|
|
363
|
+
* });
|
|
364
|
+
* });
|
|
365
|
+
*/
|
|
366
|
+
votedFor: (voteId: string, option?: string) => SelectorClass<true, true>;
|
|
367
|
+
/**
|
|
368
|
+
* Announces a vote to all participants over the `***KRADLE***` channel agents
|
|
369
|
+
* read, naming the vote and its options. Agents respond with
|
|
370
|
+
* skills.voteForOption(voteId, option). Compose with `allVotesIn`,
|
|
371
|
+
* `assignDefaultVotes`, and `votedFor` to build a full vote phase.
|
|
372
|
+
*
|
|
373
|
+
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
374
|
+
* @param {string} prompt - Human-readable instruction, e.g. "Pick a room!".
|
|
375
|
+
* @param {string[]} options - Valid options, e.g. ["red", "green", "blue"].
|
|
376
|
+
* @throws {Error} If the vote or any option isn't declared in config.ts's votingOptions.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* Actions.promptVote({ voteId: "selectroom", prompt: "Pick a room!", options: ["red", "green"] });
|
|
380
|
+
*/
|
|
381
|
+
promptVote: ({ voteId, prompt, options }: {
|
|
382
|
+
voteId: string;
|
|
383
|
+
prompt: string;
|
|
384
|
+
options: string[];
|
|
385
|
+
}) => void;
|
|
386
|
+
/**
|
|
387
|
+
* Condition that is true once every participant has voted in `voteId` — i.e.
|
|
388
|
+
* no participant is still missing the `kradle.voteOptions.<voteId>` tag the
|
|
389
|
+
* arena writes on each vote. Combine with a timer to end a vote phase as soon
|
|
390
|
+
* as everyone is in.
|
|
391
|
+
*
|
|
392
|
+
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
393
|
+
* @returns {ConditionType} true when all participants have voted.
|
|
394
|
+
* @throws {Error} If the vote isn't declared in config.ts's votingOptions.
|
|
395
|
+
*
|
|
396
|
+
* @example
|
|
397
|
+
* _.if(_.or(Actions.allVotesIn("selectroom"), vars.voteTimer.greaterOrEqualThan(600)), () => { ... });
|
|
398
|
+
*/
|
|
399
|
+
allVotesIn: (voteId: string) => import("sandstone/flow").CombinedConditions;
|
|
400
|
+
/**
|
|
401
|
+
* Records `default` for every participant who has not voted in `voteId` yet —
|
|
402
|
+
* call this when a vote phase times out so non-voters are still moved by
|
|
403
|
+
* `votedFor`. Writes the same tags the arena would (kradle.voteOptions.<voteId>
|
|
404
|
+
* and kradle.voteOptions.<voteId>.<option>).
|
|
405
|
+
*
|
|
406
|
+
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
407
|
+
* @param {string} default - Option assigned to non-voters, e.g. "red".
|
|
408
|
+
* @throws {Error} If the vote or default option isn't declared in config.ts's votingOptions.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* Actions.assignDefaultVotes({ voteId: "selectroom", default: "red" });
|
|
412
|
+
*/
|
|
413
|
+
assignDefaultVotes: ({ voteId, default: defaultOption }: {
|
|
414
|
+
voteId: string;
|
|
415
|
+
default: string;
|
|
416
|
+
}) => void;
|
|
187
417
|
/**
|
|
188
418
|
* log a message with the watcher
|
|
189
419
|
* @param {string} message - The message to send.
|
|
@@ -221,6 +451,166 @@ export declare const Actions: {
|
|
|
221
451
|
target: TargetNames;
|
|
222
452
|
item: ITEMS;
|
|
223
453
|
}) => Score<string | undefined>;
|
|
454
|
+
/**
|
|
455
|
+
* Compute the maximum value of an individual score across all
|
|
456
|
+
* participants and store it in a global Variable. Returns the variable.
|
|
457
|
+
*
|
|
458
|
+
* Why this helper exists: end-state and end-condition checks evaluated
|
|
459
|
+
* from `events.on_tick` run in server context (the caller is a non-player
|
|
460
|
+
* entity), so an `if score @s X matches Y` check on a per-player score
|
|
461
|
+
* silently fails because @s has no entry on the per-player objective.
|
|
462
|
+
* Wrapping the comparison in this helper materializes a global "max
|
|
463
|
+
* across players" value that IS safe to reference from those checks.
|
|
464
|
+
*
|
|
465
|
+
* @param {Score} score - The per-player score to aggregate.
|
|
466
|
+
* @param {number} [min=0] - Lower bound to seed the result with. Pass a
|
|
467
|
+
* negative value if your per-player score can go below 0 (e.g. climb's
|
|
468
|
+
* `current_height` defaulting to -1000); otherwise the default `0`
|
|
469
|
+
* would mask negative actual maxes.
|
|
470
|
+
* @returns {Score} An anonymous Score containing the max.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* // In a custom_variables global updater:
|
|
474
|
+
* max_diamonds: {
|
|
475
|
+
* type: "global",
|
|
476
|
+
* default: 0,
|
|
477
|
+
* updater: (value, { diamonds }) => {
|
|
478
|
+
* value.set(Actions.maxPlayerScore({ score: diamonds }));
|
|
479
|
+
* },
|
|
480
|
+
* },
|
|
481
|
+
*
|
|
482
|
+
* // Then end-states can reference the global:
|
|
483
|
+
* .events(({ max_diamonds }) => ({
|
|
484
|
+
* on_tick: () => Actions.setEndStates({
|
|
485
|
+
* winner_found: max_diamonds.greaterOrEqualThan(5),
|
|
486
|
+
* }),
|
|
487
|
+
* }))
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* // Climb's max_height — y can go below 0:
|
|
491
|
+
* max_height_global: {
|
|
492
|
+
* type: "global",
|
|
493
|
+
* default: -1000,
|
|
494
|
+
* updater: (value, { max_height }) => {
|
|
495
|
+
* value.set(Actions.maxPlayerScore({ score: max_height, min: -1000 }));
|
|
496
|
+
* },
|
|
497
|
+
* },
|
|
498
|
+
*/
|
|
499
|
+
maxPlayerScore: ({ score, min }: {
|
|
500
|
+
score: Score;
|
|
501
|
+
min?: number;
|
|
502
|
+
}) => Score;
|
|
503
|
+
/**
|
|
504
|
+
* Returns a Sandstone condition that's true when the executing player
|
|
505
|
+
* (in `as @s` context) is standing on `block`. The default is a
|
|
506
|
+
* single-cell check (block at `~ ~-1 ~`), but `slop` widens the check
|
|
507
|
+
* to a `(2*slop+1)×(2*slop+1)` patch around the player's foot position
|
|
508
|
+
* — useful when the agent's pathfinder leaves them slightly off-center
|
|
509
|
+
* from a target block (e.g. mineflayer's `goToNearestBlock` reports
|
|
510
|
+
* success once within ~1.5 blocks of the target, so the agent is
|
|
511
|
+
* commonly off by a fractional block in x/z).
|
|
512
|
+
*
|
|
513
|
+
* Compiles to: `block ~ ~-1 ~ <block>` for slop=0, or an `_.or(...)` of
|
|
514
|
+
* 9 / 25 / etc. cell checks for slop=1 / 2 / etc.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* // PD-style "did the agent step on the cooperate pad?" check
|
|
518
|
+
* choice: {
|
|
519
|
+
* type: "individual",
|
|
520
|
+
* default: 0,
|
|
521
|
+
* updater: (value) => {
|
|
522
|
+
* _.if(Actions.isStandingOn({ block: "minecraft:lime_wool", slop: 1 }), () => {
|
|
523
|
+
* value.set(COOPERATE);
|
|
524
|
+
* });
|
|
525
|
+
* },
|
|
526
|
+
* },
|
|
527
|
+
*/
|
|
528
|
+
isStandingOn: ({ block, slop }: {
|
|
529
|
+
block: BLOCKS;
|
|
530
|
+
slop?: number;
|
|
531
|
+
}) => ConditionType;
|
|
532
|
+
/**
|
|
533
|
+
* Count instances of a block within an axis-aligned region. Useful for
|
|
534
|
+
* detecting agent-built structures without pinning detection to a single
|
|
535
|
+
* coordinate (which breaks the moment the agent moves before building).
|
|
536
|
+
*
|
|
537
|
+
* Implementation note: emits one `execute if block` check per cell in the
|
|
538
|
+
* region at codegen time, so the region is hard-capped at 4096 cells
|
|
539
|
+
* (~64×8×8) to keep the generated datapack reasonable.
|
|
540
|
+
*
|
|
541
|
+
* @param block The block ID to count (e.g. "minecraft:cobblestone").
|
|
542
|
+
* @param from First corner of the region (inclusive).
|
|
543
|
+
* @param to Opposite corner (inclusive).
|
|
544
|
+
* @param absolute Whether `from` / `to` are absolute world coordinates.
|
|
545
|
+
* @returns A Sandstone `Score` containing the count.
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* // Detect any 5+ cobblestone block tower built within a 12×6×12 zone:
|
|
549
|
+
* const count = Actions.countBlocksInRegion({
|
|
550
|
+
* block: "minecraft:cobblestone",
|
|
551
|
+
* from: { x: -6, y: -60, z: -6 },
|
|
552
|
+
* to: { x: 6, y: -55, z: 6 },
|
|
553
|
+
* absolute: true,
|
|
554
|
+
* });
|
|
555
|
+
* _.if(count.greaterOrEqualThan(5), () => Actions.announce({ message: "Tower built!" }));
|
|
556
|
+
*/
|
|
557
|
+
countBlocksInRegion: ({ block, from, to, absolute, }: {
|
|
558
|
+
block: BLOCKS;
|
|
559
|
+
from: {
|
|
560
|
+
x: number;
|
|
561
|
+
y: number;
|
|
562
|
+
z: number;
|
|
563
|
+
};
|
|
564
|
+
to: {
|
|
565
|
+
x: number;
|
|
566
|
+
y: number;
|
|
567
|
+
z: number;
|
|
568
|
+
};
|
|
569
|
+
absolute: boolean;
|
|
570
|
+
}) => Score;
|
|
571
|
+
/**
|
|
572
|
+
* Count instances of a block in a region centered on a target. Same idea
|
|
573
|
+
* as `countBlocksInRegion` but the bounds are *relative to the target's
|
|
574
|
+
* current position* — useful when the region of interest moves with a
|
|
575
|
+
* player (e.g. "how many X blocks are around the agent right now").
|
|
576
|
+
*
|
|
577
|
+
* What this is NOT: it does not verify a structure (the matches don't
|
|
578
|
+
* have to be contiguous), and it does not prove the target placed them.
|
|
579
|
+
* Treat the result as "presence count in a volume." Turn it into "the
|
|
580
|
+
* agent placed N of these" only when the block type doesn't spawn
|
|
581
|
+
* naturally in your world (and your arena init didn't pre-place any), or
|
|
582
|
+
* by clearing the volume first and counting the delta.
|
|
583
|
+
*
|
|
584
|
+
* Implementation note: emits one `execute as <target> at @s if block`
|
|
585
|
+
* check per cell at codegen time, so the region is hard-capped at 4096
|
|
586
|
+
* cells just like `countBlocksInRegion`.
|
|
587
|
+
*
|
|
588
|
+
* @example
|
|
589
|
+
* // Count diamond_block instances within 6 blocks of the agent. Diamond
|
|
590
|
+
* // blocks don't generate naturally, so in a flat-world challenge whose
|
|
591
|
+
* // arena init doesn't pre-place any, this is equivalently the count of
|
|
592
|
+
* // diamond blocks the agent has placed within reach.
|
|
593
|
+
* diamond_blocks_nearby: {
|
|
594
|
+
* type: "individual",
|
|
595
|
+
* default: 0,
|
|
596
|
+
* updater: (value) => {
|
|
597
|
+
* value.set(Actions.countBlocksRelativeTo({
|
|
598
|
+
* target: "self",
|
|
599
|
+
* block: "minecraft:diamond_block",
|
|
600
|
+
* dxRange: [-6, 6],
|
|
601
|
+
* dyRange: [-2, 4],
|
|
602
|
+
* dzRange: [-6, 6],
|
|
603
|
+
* }));
|
|
604
|
+
* },
|
|
605
|
+
* }
|
|
606
|
+
*/
|
|
607
|
+
countBlocksRelativeTo: ({ target, block, dxRange, dyRange, dzRange, }: {
|
|
608
|
+
target: TargetNames;
|
|
609
|
+
block: BLOCKS;
|
|
610
|
+
dxRange: [number, number];
|
|
611
|
+
dyRange: [number, number];
|
|
612
|
+
dzRange: [number, number];
|
|
613
|
+
}) => Score;
|
|
224
614
|
/**
|
|
225
615
|
* Get the current player's position as x, y, z Score variables.
|
|
226
616
|
* Must be called in a player context (e.g., inside forEveryPlayer or when @s is a player).
|
|
@@ -242,5 +632,254 @@ export declare const Actions: {
|
|
|
242
632
|
getLocation: ({ name }: {
|
|
243
633
|
name: string;
|
|
244
634
|
}) => SelectorClass<true, false>;
|
|
635
|
+
/**
|
|
636
|
+
* Build a box (4 walls + optional floor/roof) in a single call. Replaces
|
|
637
|
+
* the typical 5+ `Actions.fill` calls per arena.
|
|
638
|
+
*
|
|
639
|
+
* @param block The wall block (e.g. "minecraft:stone").
|
|
640
|
+
* @param from First corner (inclusive).
|
|
641
|
+
* @param to Opposite corner (inclusive).
|
|
642
|
+
* @param absolute Whether coordinates are absolute or player-relative.
|
|
643
|
+
* @param hollow When true (default), only walls are placed; the interior is left untouched.
|
|
644
|
+
* When false, the entire volume is filled with `block`.
|
|
645
|
+
* @param floor Optional block to fill the floor with (overrides `block` for floor only).
|
|
646
|
+
* @param roof Optional block to fill the roof with.
|
|
647
|
+
* @param clearInside When true and `hollow=true`, the interior volume is set to air
|
|
648
|
+
* (useful for clearing existing terrain inside the new box).
|
|
649
|
+
*
|
|
650
|
+
* @example
|
|
651
|
+
* // 13x13x5 stone arena with a stone-bricks floor, no roof, interior cleared
|
|
652
|
+
* Actions.box({
|
|
653
|
+
* block: "minecraft:stone",
|
|
654
|
+
* from: { x: -6, y: -60, z: -6 },
|
|
655
|
+
* to: { x: 6, y: -55, z: 6 },
|
|
656
|
+
* absolute: true,
|
|
657
|
+
* hollow: true,
|
|
658
|
+
* floor: "minecraft:stone_bricks",
|
|
659
|
+
* clearInside: true,
|
|
660
|
+
* });
|
|
661
|
+
*/
|
|
662
|
+
box: ({ block, from, to, absolute, hollow, floor, roof, clearInside, }: {
|
|
663
|
+
block: BLOCKS;
|
|
664
|
+
from: {
|
|
665
|
+
x: number;
|
|
666
|
+
y: number;
|
|
667
|
+
z: number;
|
|
668
|
+
};
|
|
669
|
+
to: {
|
|
670
|
+
x: number;
|
|
671
|
+
y: number;
|
|
672
|
+
z: number;
|
|
673
|
+
};
|
|
674
|
+
absolute: boolean;
|
|
675
|
+
hollow?: boolean;
|
|
676
|
+
floor?: BLOCKS;
|
|
677
|
+
roof?: BLOCKS;
|
|
678
|
+
clearInside?: BLOCKS | boolean;
|
|
679
|
+
}) => void;
|
|
680
|
+
/**
|
|
681
|
+
* Give every participant a list of items in one call. Replaces the
|
|
682
|
+
* sequence of `Actions.give({ target: "all", item: …, count: … })` calls
|
|
683
|
+
* that opens nearly every multi-player init_participants (castle-ctf has
|
|
684
|
+
* six of them for the iron-sword + 4 armor pieces + food loadout).
|
|
685
|
+
*
|
|
686
|
+
* @example PvP standard kit:
|
|
687
|
+
* ```ts
|
|
688
|
+
* Actions.giveAll([
|
|
689
|
+
* { item: "minecraft:iron_sword" },
|
|
690
|
+
* { item: "minecraft:iron_helmet" },
|
|
691
|
+
* { item: "minecraft:iron_chestplate" },
|
|
692
|
+
* { item: "minecraft:iron_leggings" },
|
|
693
|
+
* { item: "minecraft:iron_boots" },
|
|
694
|
+
* { item: "minecraft:cooked_beef", count: 5 },
|
|
695
|
+
* ]);
|
|
696
|
+
* ```
|
|
697
|
+
*
|
|
698
|
+
* `count` defaults to 1. For role-specific equipment, use plain
|
|
699
|
+
* `Actions.give({ target: roleName, … })`.
|
|
700
|
+
*/
|
|
701
|
+
giveAll: (items: Array<{
|
|
702
|
+
item: ITEMS;
|
|
703
|
+
count?: number;
|
|
704
|
+
}>) => void;
|
|
705
|
+
/**
|
|
706
|
+
* "When the block at this absolute coordinate stops being `expected`, set
|
|
707
|
+
* `into` to 1." The standard goal_broken / flag_broken global-variable
|
|
708
|
+
* updater idiom. Latches at 1 — once tripped, stays tripped (so the
|
|
709
|
+
* end_state fires consistently even if the block is later replaced).
|
|
710
|
+
*
|
|
711
|
+
* Replaces the 4-line `_.if(_.not(_.block(abs(...), ...)), () => value.set(1))`
|
|
712
|
+
* pattern that appears in ~10 challenges' custom_variable updaters
|
|
713
|
+
* (castle-ctf×2, castle-siege×4, defender-striker, beanstalk, tower-trio,
|
|
714
|
+
* tunnel-rush, sky-walker, …). Removes the need to import `abs` from
|
|
715
|
+
* sandstone for this purpose.
|
|
716
|
+
*
|
|
717
|
+
* For multi-block checks ("all N landmarks broken" — diamond-hunt,
|
|
718
|
+
* return-home), keep using the manual `_.if(_.and(...conditions), …)`
|
|
719
|
+
* pattern — this helper is single-block only.
|
|
720
|
+
*
|
|
721
|
+
* @example castle-ctf red flag (latching — once broken, stays broken):
|
|
722
|
+
* ```ts
|
|
723
|
+
* red_flag_broken: {
|
|
724
|
+
* type: "global",
|
|
725
|
+
* default: 0,
|
|
726
|
+
* updater: (value) => {
|
|
727
|
+
* // Latch: only flip 0→1, never reset to 0. The returned Score is
|
|
728
|
+
* // itself a Condition (truthy = non-zero), so no `.equalTo(1)` needed.
|
|
729
|
+
* _.if(Actions.detectBlockMissing({
|
|
730
|
+
* at: { x: RED_BASE.x, y: RED_BASE.y + 1, z: RED_BASE.z },
|
|
731
|
+
* expected: "minecraft:red_wool",
|
|
732
|
+
* }), () => value.set(1));
|
|
733
|
+
* },
|
|
734
|
+
* }
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* @returns {Score} An anonymous Score: 1 if the block at `at` is NOT
|
|
738
|
+
* `expected`, 0 if it is. Non-latching — recomputed every call. Wrap in
|
|
739
|
+
* `_.if(missing, () => value.set(1))` (the Score is itself a Condition,
|
|
740
|
+
* truthy = non-zero) for the latching "once broken, stays broken" pattern.
|
|
741
|
+
*/
|
|
742
|
+
detectBlockMissing: ({ at, expected }: {
|
|
743
|
+
at: {
|
|
744
|
+
x: number;
|
|
745
|
+
y: number;
|
|
746
|
+
z: number;
|
|
747
|
+
};
|
|
748
|
+
expected: BLOCKS;
|
|
749
|
+
}) => Score;
|
|
750
|
+
/**
|
|
751
|
+
* Summon a single configurable entity with optional health, attack damage,
|
|
752
|
+
* movement speed, and tags. Uses Sandstone's typed `summon` + NBT helpers
|
|
753
|
+
* (`NBT.byte`, `NBT.float`) so that booleans and NBT primitives serialize
|
|
754
|
+
* correctly — sandstone otherwise emits JS `true` as `{}` (an invalid NBT
|
|
755
|
+
* token), which broke boss-brawl's `CustomNameVisible: true` summon early on.
|
|
756
|
+
*
|
|
757
|
+
* For boss-style configured mobs (boss-solo, boss-brawl). Use
|
|
758
|
+
* `Actions.summonMultiple` for plain entities without stat overrides.
|
|
759
|
+
*
|
|
760
|
+
* @example A 60-HP fast-moving boss zombie:
|
|
761
|
+
* ```ts
|
|
762
|
+
* Actions.summonEntityWithStats({
|
|
763
|
+
* entity: "minecraft:zombie",
|
|
764
|
+
* x: 0, y: -60, z: 0, absolute: true,
|
|
765
|
+
* health: 60,
|
|
766
|
+
* attackDamage: 6,
|
|
767
|
+
* movementSpeed: 0.18,
|
|
768
|
+
* tags: ["boss"], // for `Actions.countEntities({ tag: "boss", … })`
|
|
769
|
+
* });
|
|
770
|
+
* ```
|
|
771
|
+
*/
|
|
772
|
+
summonEntityWithStats: ({ entity, x, y, z, absolute, health, attackDamage, movementSpeed, tags, }: {
|
|
773
|
+
entity: ENTITY_TYPES;
|
|
774
|
+
x: number;
|
|
775
|
+
y: number;
|
|
776
|
+
z: number;
|
|
777
|
+
absolute: boolean;
|
|
778
|
+
health?: number;
|
|
779
|
+
attackDamage?: number;
|
|
780
|
+
movementSpeed?: number;
|
|
781
|
+
tags?: string[];
|
|
782
|
+
}) => void;
|
|
783
|
+
/**
|
|
784
|
+
* Count entities matching any combination of `entity` type, `tag`, and/or
|
|
785
|
+
* `volume`, returning the count as an anonymous `Score`. At least one
|
|
786
|
+
* filter must be provided (counting "every entity in the world" is almost
|
|
787
|
+
* always a bug — guarded at runtime).
|
|
788
|
+
*
|
|
789
|
+
* Use this in a global custom_variable updater whose value tracks "how
|
|
790
|
+
* many Xs are currently in the world", e.g. boss alive (zombie count),
|
|
791
|
+
* chickens left, sheep in a pen.
|
|
792
|
+
*
|
|
793
|
+
* @param entity Optional entity type (e.g. `"minecraft:zombie"`).
|
|
794
|
+
* @param tag Optional tag filter (Minecraft `@e[tag=…]`). Used by e.g.
|
|
795
|
+
* boss-brawl, which counts zombies tagged `"boss"` to ignore wave-spawned mooks.
|
|
796
|
+
* @param volume Optional bounding box (Minecraft-style: corner + dx/dy/dz
|
|
797
|
+
* extents, absolute coords). Omit to count anywhere in the world.
|
|
798
|
+
* @returns {Score} An anonymous Score holding the count.
|
|
799
|
+
*
|
|
800
|
+
* @example boss_alive — counts zombies anywhere
|
|
801
|
+
* ```ts
|
|
802
|
+
* boss_alive: {
|
|
803
|
+
* type: "global",
|
|
804
|
+
* default: 1,
|
|
805
|
+
* updater: (value) => {
|
|
806
|
+
* value.set(Actions.countEntities({ entity: "minecraft:zombie" }));
|
|
807
|
+
* },
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*
|
|
811
|
+
* @example boss-brawl — count only the tagged boss zombies
|
|
812
|
+
* ```ts
|
|
813
|
+
* value.set(Actions.countEntities({ entity: "minecraft:zombie", tag: "boss" }));
|
|
814
|
+
* ```
|
|
815
|
+
*
|
|
816
|
+
* @example sheep_in_pen — counts sheep inside a 3×1×3 box
|
|
817
|
+
* ```ts
|
|
818
|
+
* value.set(Actions.countEntities({
|
|
819
|
+
* entity: "minecraft:sheep",
|
|
820
|
+
* volume: { x: 14, y: -59, z: -1, dx: 2, dy: 1, dz: 2 },
|
|
821
|
+
* }));
|
|
822
|
+
* ```
|
|
823
|
+
*/
|
|
824
|
+
countEntities: ({ entity, tag, volume, }: {
|
|
825
|
+
entity?: ENTITY_TYPES;
|
|
826
|
+
tag?: string;
|
|
827
|
+
volume?: {
|
|
828
|
+
x: number;
|
|
829
|
+
y: number;
|
|
830
|
+
z: number;
|
|
831
|
+
dx: number;
|
|
832
|
+
dy: number;
|
|
833
|
+
dz: number;
|
|
834
|
+
};
|
|
835
|
+
}) => Score;
|
|
836
|
+
/**
|
|
837
|
+
* Build a flat open arena: a single-block-thick floor at `center.y` with
|
|
838
|
+
* cleared airspace above up to `headroom` blocks tall. The "no walls,
|
|
839
|
+
* just open ground for things to move on" pattern shared by sumo-arena,
|
|
840
|
+
* boss-brawl, wave-survival, stalker, and one half of defender-striker.
|
|
841
|
+
*
|
|
842
|
+
* For arenas with walls, use `Actions.box({ hollow: true, floor: … })`.
|
|
843
|
+
*
|
|
844
|
+
* @example
|
|
845
|
+
* Actions.flatArena({
|
|
846
|
+
* block: "minecraft:stone",
|
|
847
|
+
* center: { x: 0, y: -60, z: 0 },
|
|
848
|
+
* radius: 10, // 21×21 footprint
|
|
849
|
+
* headroom: 4, // 4 blocks of air above the floor (default 4)
|
|
850
|
+
* });
|
|
851
|
+
*/
|
|
852
|
+
flatArena: ({ block, center, radius, headroom, }: {
|
|
853
|
+
block: BLOCKS;
|
|
854
|
+
center: {
|
|
855
|
+
x: number;
|
|
856
|
+
y: number;
|
|
857
|
+
z: number;
|
|
858
|
+
};
|
|
859
|
+
radius: number;
|
|
860
|
+
/** How many blocks of air to clear above the floor. Default 4. */
|
|
861
|
+
headroom?: number;
|
|
862
|
+
}) => void;
|
|
863
|
+
/**
|
|
864
|
+
* Apply a non-lethal knockback / displacement to a target via Minecraft's
|
|
865
|
+
* `effect` command. The default effect is a brief levitation (lifts the
|
|
866
|
+
* target straight up without dealing damage).
|
|
867
|
+
*
|
|
868
|
+
* Use `mode: "slowfall"` to combine levitation with slow falling so the
|
|
869
|
+
* target doesn't take fall damage on landing.
|
|
870
|
+
*
|
|
871
|
+
* @example
|
|
872
|
+
* // Periodic knockback in King-of-the-Hill style:
|
|
873
|
+
* Actions.knockbackWithLevitation({ target: "all", durationSeconds: 2, amplifier: 6 });
|
|
874
|
+
*
|
|
875
|
+
* // Knock with slow-fall for safe landing:
|
|
876
|
+
* Actions.knockbackWithLevitation({ target: "self", mode: "slowfall", durationSeconds: 3 });
|
|
877
|
+
*/
|
|
878
|
+
knockbackWithLevitation: ({ target, durationSeconds, amplifier, mode, }: {
|
|
879
|
+
target: TargetNames;
|
|
880
|
+
durationSeconds?: number;
|
|
881
|
+
amplifier?: number;
|
|
882
|
+
mode?: "levitation" | "slowfall";
|
|
883
|
+
}) => void;
|
|
245
884
|
};
|
|
246
885
|
//# sourceMappingURL=actions.d.ts.map
|