@kradle/challenges-sdk 0.10.0 → 0.11.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/CHANGELOG.md +32 -1
- package/LLM_README.md +235 -2333
- package/README.md +151 -570
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/runtime/examples/capture-the-flag.d.ts +33 -0
- package/dist/runtime/examples/capture-the-flag.d.ts.map +1 -0
- package/dist/runtime/examples/capture-the-flag.js +79 -0
- package/dist/runtime/examples/capture-the-flag.js.map +1 -0
- package/dist/runtime/examples/climb.d.ts +34 -0
- package/dist/runtime/examples/climb.d.ts.map +1 -0
- package/dist/runtime/examples/climb.js +54 -0
- package/dist/runtime/examples/climb.js.map +1 -0
- package/dist/runtime/examples/four-bridges.d.ts +107 -0
- package/dist/runtime/examples/four-bridges.d.ts.map +1 -0
- package/dist/runtime/examples/four-bridges.js +294 -0
- package/dist/runtime/examples/four-bridges.js.map +1 -0
- package/dist/runtime/examples/herding.d.ts +59 -0
- package/dist/runtime/examples/herding.d.ts.map +1 -0
- package/dist/runtime/examples/herding.js +181 -0
- package/dist/runtime/examples/herding.js.map +1 -0
- package/dist/runtime/examples/skywars.d.ts +116 -0
- package/dist/runtime/examples/skywars.d.ts.map +1 -0
- package/dist/runtime/examples/skywars.js +253 -0
- package/dist/runtime/examples/skywars.js.map +1 -0
- package/dist/runtime/harness.d.ts +176 -0
- package/dist/runtime/harness.d.ts.map +1 -0
- package/dist/runtime/harness.js +441 -0
- package/dist/runtime/harness.js.map +1 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +18 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/sandbox-registry.d.ts +7 -0
- package/dist/runtime/sandbox-registry.d.ts.map +1 -0
- package/dist/runtime/sandbox-registry.js +16 -0
- package/dist/runtime/sandbox-registry.js.map +1 -0
- package/dist/runtime/sandbox.d.ts +29 -0
- package/dist/runtime/sandbox.d.ts.map +1 -0
- package/dist/runtime/sandbox.js +70 -0
- package/dist/runtime/sandbox.js.map +1 -0
- package/dist/runtime/sdk.d.ts +1038 -0
- package/dist/runtime/sdk.d.ts.map +1 -0
- package/dist/runtime/sdk.js +1271 -0
- package/dist/runtime/sdk.js.map +1 -0
- package/dist/runtime/world.d.ts +141 -0
- package/dist/runtime/world.d.ts.map +1 -0
- package/dist/runtime/world.js +344 -0
- package/dist/runtime/world.js.map +1 -0
- package/package.json +76 -40
- package/dist/actions.d.ts +0 -901
- package/dist/actions.d.ts.map +0 -1
- package/dist/actions.js +0 -1155
- package/dist/actions.js.map +0 -1
- package/dist/api_utils.d.ts +0 -25
- package/dist/api_utils.d.ts.map +0 -1
- package/dist/api_utils.js +0 -48
- package/dist/api_utils.js.map +0 -1
- package/dist/challenge.d.ts +0 -58
- package/dist/challenge.d.ts.map +0 -1
- package/dist/challenge.js +0 -582
- package/dist/challenge.js.map +0 -1
- package/dist/commands.d.ts +0 -57
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -200
- package/dist/commands.js.map +0 -1
- package/dist/constants.d.ts +0 -78
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -109
- package/dist/constants.js.map +0 -1
- package/dist/testmode.d.ts +0 -3
- package/dist/testmode.d.ts.map +0 -1
- package/dist/testmode.js +0 -19
- package/dist/testmode.js.map +0 -1
- package/dist/types.d.ts +0 -195
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -38
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -17
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -22
- package/dist/utils.js.map +0 -1
package/dist/actions.d.ts
DELETED
|
@@ -1,901 +0,0 @@
|
|
|
1
|
-
import { type GAMERULES, type JSONTextComponent, type Score, SelectorClass, type SingleEntityArgument } from "sandstone";
|
|
2
|
-
import type { ATTRIBUTES, BLOCKS, ENTITY_TYPES, ITEMS } from "sandstone/arguments/generated";
|
|
3
|
-
import type { ConditionType } from "sandstone/flow";
|
|
4
|
-
import type { LiteralStringUnion } from "./utils";
|
|
5
|
-
export type TargetNames = LiteralStringUnion<"all" | "self"> | SelectorClass<any, any>;
|
|
6
|
-
export declare function mapTarget(target: string | SelectorClass): SelectorClass<any, any> | string;
|
|
7
|
-
export declare const Actions: {
|
|
8
|
-
/**
|
|
9
|
-
* Send a chat message to everyone.
|
|
10
|
-
* @param {JSONTextComponent} message - The message to send.
|
|
11
|
-
*/
|
|
12
|
-
announce: ({ message }: {
|
|
13
|
-
message: JSONTextComponent;
|
|
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;
|
|
68
|
-
/**
|
|
69
|
-
* Clear the inventory of a target.
|
|
70
|
-
* @param {TargetNames} target - The target to clear the inventory of.
|
|
71
|
-
*/
|
|
72
|
-
clear: ({ target }: {
|
|
73
|
-
target: TargetNames;
|
|
74
|
-
}) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Fill a region with a block.
|
|
77
|
-
* @param {BLOCKS} block - The block to fill the region with.
|
|
78
|
-
* @param {number} x1 - The x coordinate of the region.
|
|
79
|
-
* @param {number} y1 - The y coordinate of the region.
|
|
80
|
-
* @param {number} z1 - The z coordinate of the region.
|
|
81
|
-
* @param {number} x2 - The x coordinate of the region.
|
|
82
|
-
* @param {number} y2 - The y coordinate of the region.
|
|
83
|
-
* @param {number} z2 - The z coordinate of the region.
|
|
84
|
-
* @param {boolean} absolute - Whether the coordinates are absolute or relative.
|
|
85
|
-
* @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.
|
|
86
|
-
*/
|
|
87
|
-
fill: ({ block, x1, y1, z1, x2, y2, z2, absolute, mode, }: {
|
|
88
|
-
block: BLOCKS;
|
|
89
|
-
x1: number;
|
|
90
|
-
y1: number;
|
|
91
|
-
z1: number;
|
|
92
|
-
x2: number;
|
|
93
|
-
y2: number;
|
|
94
|
-
z2: number;
|
|
95
|
-
absolute: boolean;
|
|
96
|
-
mode: "fill" | "line" | "pyramid";
|
|
97
|
-
}) => void;
|
|
98
|
-
/**
|
|
99
|
-
* Give an item to a target.
|
|
100
|
-
* @param {ITEMS} item - The item to give.
|
|
101
|
-
* @param {TargetNames} target - The target to give the item to.
|
|
102
|
-
* @param {number} count - The number of items to give.
|
|
103
|
-
*/
|
|
104
|
-
give: ({ item, target, count }: {
|
|
105
|
-
item: ITEMS;
|
|
106
|
-
target: TargetNames;
|
|
107
|
-
count?: number;
|
|
108
|
-
}) => void;
|
|
109
|
-
/**
|
|
110
|
-
* Give loot to a target with a weighted chance for selecting one of the items.
|
|
111
|
-
* @param {{ name: ITEMS, count: number, weight: number }[]} items - The items to give.
|
|
112
|
-
* @param {TargetNames} target - The target to give the item to.
|
|
113
|
-
*/
|
|
114
|
-
giveLoot: ({ items, target }: {
|
|
115
|
-
items: [{
|
|
116
|
-
name: ITEMS;
|
|
117
|
-
count: number;
|
|
118
|
-
weight: number;
|
|
119
|
-
}];
|
|
120
|
-
target: TargetNames;
|
|
121
|
-
}) => void;
|
|
122
|
-
/**
|
|
123
|
-
* Set a gamerule.
|
|
124
|
-
* @param {GAMERULES} rule - The name of the gamerule.
|
|
125
|
-
* @param {boolean | number} value - The value to set the gamerule to.
|
|
126
|
-
*/
|
|
127
|
-
gamerule: ({ rule, value }: {
|
|
128
|
-
rule: GAMERULES;
|
|
129
|
-
value: boolean | number;
|
|
130
|
-
}) => void;
|
|
131
|
-
/**
|
|
132
|
-
* Kill entities matching a selector.
|
|
133
|
-
* @param {SelectorArgument} selector - The entities to kill.
|
|
134
|
-
*/
|
|
135
|
-
kill: ({ selector }: {
|
|
136
|
-
selector: TargetNames;
|
|
137
|
-
}) => void;
|
|
138
|
-
/**
|
|
139
|
-
* Set the gamemode of a target. Useful for moving an eliminated player
|
|
140
|
-
* to spectator without killing them (preserves the entity, lets them
|
|
141
|
-
* watch the rest of the run).
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* Actions.setGamemode({ target: "self", mode: "spectator" });
|
|
145
|
-
* Actions.setGamemode({ target: "all", mode: "adventure" });
|
|
146
|
-
*/
|
|
147
|
-
setGamemode: ({ target, mode, }: {
|
|
148
|
-
target: TargetNames;
|
|
149
|
-
mode: "survival" | "creative" | "adventure" | "spectator";
|
|
150
|
-
}) => void;
|
|
151
|
-
/**
|
|
152
|
-
* Eliminate a participant from the active round: switch them to
|
|
153
|
-
* spectator mode (so they can still observe but can't act). Sister
|
|
154
|
-
* helper to `kill`, intended for vote-out / king-of-the-hill / battle
|
|
155
|
-
* royale style games where elimination shouldn't end the agent's
|
|
156
|
-
* connection.
|
|
157
|
-
*
|
|
158
|
-
* Note: this only flips gamemode. The challenge author is responsible
|
|
159
|
-
* for any per-player tracking variable (e.g. `is_alive`).
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* Actions.eliminate({ target: "self" });
|
|
163
|
-
*/
|
|
164
|
-
eliminate: ({ target }: {
|
|
165
|
-
target: TargetNames;
|
|
166
|
-
}) => void;
|
|
167
|
-
/**
|
|
168
|
-
* Set an attribute for a target.
|
|
169
|
-
* @param {ATTRIBUTES} attribute_ - The attribute to set.
|
|
170
|
-
* @param {number} value - The value to set the attribute to.
|
|
171
|
-
* @param {TargetNames} target - The target to set the attribute for.
|
|
172
|
-
*/
|
|
173
|
-
setAttribute: ({ attribute_, value, target }: {
|
|
174
|
-
attribute_: ATTRIBUTES;
|
|
175
|
-
value: number;
|
|
176
|
-
target: TargetNames;
|
|
177
|
-
}) => void;
|
|
178
|
-
/**
|
|
179
|
-
* Set the time of day.
|
|
180
|
-
* @param {'day' | 'night'} time_ - The time to set.
|
|
181
|
-
*/
|
|
182
|
-
setTime: ({ time }: {
|
|
183
|
-
time: "day" | "night";
|
|
184
|
-
}) => void;
|
|
185
|
-
/**
|
|
186
|
-
* Summon multiple entities at a specific location.
|
|
187
|
-
*/
|
|
188
|
-
summonMultiple: (params: {
|
|
189
|
-
entity: ENTITY_TYPES;
|
|
190
|
-
count: number;
|
|
191
|
-
x: number;
|
|
192
|
-
y: number;
|
|
193
|
-
z: number;
|
|
194
|
-
absolute: boolean;
|
|
195
|
-
}) => void;
|
|
196
|
-
/**
|
|
197
|
-
* Set the end state of the challenge.
|
|
198
|
-
* @param {string} end_state - The end state to set.
|
|
199
|
-
* @throws {Error} If KRADLE_CHALLENGE_END_STATES is set and endState is not in the list.
|
|
200
|
-
*/
|
|
201
|
-
setEndState: ({ endState }: {
|
|
202
|
-
endState: string;
|
|
203
|
-
}) => void;
|
|
204
|
-
/**
|
|
205
|
-
* For each `(name, condition)` pair, emit `_.if(condition, () =>
|
|
206
|
-
* setEndState(name))` at the current codegen location. Where (and how
|
|
207
|
-
* often) those checks run is up to the caller — `events.on_tick` for a
|
|
208
|
-
* per-tick check, `custom_events.actions` for a single fire, etc.
|
|
209
|
-
*
|
|
210
|
-
* Returns a `ConditionType` that is true when at least one of the input
|
|
211
|
-
* conditions is true (i.e. an end-state was applied). Hand it to
|
|
212
|
-
* `.end_condition()` if you want the game to end as soon as any end-state
|
|
213
|
-
* has been set; ignore it if the game's end is gated on something else
|
|
214
|
-
* (timer, separate condition).
|
|
215
|
-
*
|
|
216
|
-
* Note: conditions are evaluated in whatever execution context the caller
|
|
217
|
-
* is in. From `on_tick` that's the server entity, where per-player score
|
|
218
|
-
* reads silently fail — see `Actions.maxPlayerScore` for the per-player →
|
|
219
|
-
* global bridge.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* let endReached: ConditionType | undefined;
|
|
223
|
-
* const challenge = createChallenge({...});
|
|
224
|
-
* challenge
|
|
225
|
-
* .events((vars) => ({
|
|
226
|
-
* on_tick: () => {
|
|
227
|
-
* endReached = Actions.setEndStates({
|
|
228
|
-
* winner_found: vars.top_kills.greaterOrEqualThan(20),
|
|
229
|
-
* all_dead: vars.alive_players.equalTo(0),
|
|
230
|
-
* });
|
|
231
|
-
* },
|
|
232
|
-
* }))
|
|
233
|
-
* .end_condition(() => endReached!); // game ends as soon as any branch fires
|
|
234
|
-
*/
|
|
235
|
-
setEndStates: (endStates: Record<string, ConditionType>) => ConditionType;
|
|
236
|
-
/**
|
|
237
|
-
* Set a block at a specific location.
|
|
238
|
-
*/
|
|
239
|
-
setBlock: (params: {
|
|
240
|
-
block: BLOCKS;
|
|
241
|
-
x: number;
|
|
242
|
-
y: number;
|
|
243
|
-
z: number;
|
|
244
|
-
absolute: boolean;
|
|
245
|
-
}) => void;
|
|
246
|
-
/**
|
|
247
|
-
* Teleport entities to a specific location, or to another entity.
|
|
248
|
-
* @param {TargetNames} target - The entities to teleport.
|
|
249
|
-
* @param {SingleEntityArgument} toEntity - The entity to teleport to.
|
|
250
|
-
* @param {number} x - The x coordinate of the destination.
|
|
251
|
-
* @param {number} y - The y coordinate of the destination.
|
|
252
|
-
* @param {number} z - The z coordinate of the destination.
|
|
253
|
-
* @param {boolean} absolute - Whether the coordinates are absolute or relative.
|
|
254
|
-
*/
|
|
255
|
-
teleport: (args: {
|
|
256
|
-
target: TargetNames;
|
|
257
|
-
x: number;
|
|
258
|
-
y: number;
|
|
259
|
-
z: number;
|
|
260
|
-
absolute: boolean;
|
|
261
|
-
} | {
|
|
262
|
-
target: TargetNames;
|
|
263
|
-
toEntity: SingleEntityArgument;
|
|
264
|
-
}) => void;
|
|
265
|
-
/**
|
|
266
|
-
* Force the target player(s) to immediately interrupt whatever code they are
|
|
267
|
-
* running and walk to the given absolute coordinates. Server-initiated: the
|
|
268
|
-
* challenge forces the move, unlike normal agent movement skills. The agents
|
|
269
|
-
* always walk to the destination — they are never teleported, even in cheat
|
|
270
|
-
* mode. Only the interrupt plus a single pathfind are guaranteed; an agent
|
|
271
|
-
* may decide to walk away again on its next action.
|
|
272
|
-
* @param {TargetNames} target - "self", "all", a role name, or a Selector.
|
|
273
|
-
* "self" is the acting agent and only resolves inside a per-player
|
|
274
|
-
* context; a forceMoveTo("self") reachable from a contextless server
|
|
275
|
-
* function is caught by the build context-safety check. Raw "@..."
|
|
276
|
-
* selector strings are rejected by mapTarget — use "self" or a Selector.
|
|
277
|
-
* @param {number} x - Absolute x coordinate to move to.
|
|
278
|
-
* @param {number} y - Absolute y coordinate to move to.
|
|
279
|
-
* @param {number} z - Absolute z coordinate to move to.
|
|
280
|
-
*/
|
|
281
|
-
forceMoveTo: ({ target, x, y, z }: {
|
|
282
|
-
target: TargetNames;
|
|
283
|
-
x: number;
|
|
284
|
-
y: number;
|
|
285
|
-
z: number;
|
|
286
|
-
}) => void;
|
|
287
|
-
/**
|
|
288
|
-
* Send a chat message to a target.
|
|
289
|
-
* @param {JSONTextComponent} message - The message to send.
|
|
290
|
-
* @param {TargetNames} target - The target to send the message to.
|
|
291
|
-
*/
|
|
292
|
-
tellraw: ({ message, target }: {
|
|
293
|
-
message: JSONTextComponent;
|
|
294
|
-
target: TargetNames;
|
|
295
|
-
}) => void;
|
|
296
|
-
/**
|
|
297
|
-
* Increment a score variable by 1.
|
|
298
|
-
* @param variable - The score variable to increment.
|
|
299
|
-
*/
|
|
300
|
-
increment: ({ variable }: {
|
|
301
|
-
variable: Score;
|
|
302
|
-
}) => void;
|
|
303
|
-
/**
|
|
304
|
-
* Decrement a score variable by 1.
|
|
305
|
-
* @param variable - The score variable to decrement.
|
|
306
|
-
*/
|
|
307
|
-
decrement: ({ variable }: {
|
|
308
|
-
variable: Score;
|
|
309
|
-
}) => void;
|
|
310
|
-
/**
|
|
311
|
-
* Set a score variable to a specific value.
|
|
312
|
-
* @param variable - The score variable to set.
|
|
313
|
-
* @param value - The value to set the score variable to, which can be a number or another score variable.
|
|
314
|
-
*/
|
|
315
|
-
set: ({ variable, value }: {
|
|
316
|
-
variable: Score;
|
|
317
|
-
value: number | Score;
|
|
318
|
-
}) => void;
|
|
319
|
-
/**
|
|
320
|
-
* Selector that matches `@s` only when standing on the block at the
|
|
321
|
-
* given absolute coordinate. Use this anywhere you'd otherwise have
|
|
322
|
-
* written `Selector("@s", { x, y, z })` — that bare form does NOT
|
|
323
|
-
* constrain position (Minecraft treats x/y/z as the selector origin
|
|
324
|
-
* for distance math, not as a position filter), so the condition
|
|
325
|
-
* silently passes for everyone. This helper bakes in the right
|
|
326
|
-
* `dx: 0, dy: 1, dz: 0` volume covering the block above and the
|
|
327
|
-
* head space, so the selector matches only when the player's feet
|
|
328
|
-
* are inside the 1×1×1 column at (x, y+1, z).
|
|
329
|
-
*
|
|
330
|
-
* @param {number} x - X of the block being stood on.
|
|
331
|
-
* @param {number} y - Y of the block being stood on (the player's feet are at y+1).
|
|
332
|
-
* @param {number} z - Z of the block being stood on.
|
|
333
|
-
* @param {string} [role] - Optional role tag the player must also have.
|
|
334
|
-
*
|
|
335
|
-
* @example
|
|
336
|
-
* // Trigger alice_shared when Alice steps on her pad block.
|
|
337
|
-
* alice_shared: {
|
|
338
|
-
* type: "global",
|
|
339
|
-
* default: 0,
|
|
340
|
-
* updater: (value) => {
|
|
341
|
-
* _.if(value.equalTo(0), () => {
|
|
342
|
-
* forEveryPlayer(() => {
|
|
343
|
-
* _.if(Actions.standingOnBlock({ x: ALICE_PAD.x, y: ALICE_PAD.y, z: ALICE_PAD.z, role: "alice" }), () => {
|
|
344
|
-
* value.set(1);
|
|
345
|
-
* });
|
|
346
|
-
* });
|
|
347
|
-
* });
|
|
348
|
-
* },
|
|
349
|
-
* },
|
|
350
|
-
*/
|
|
351
|
-
standingOnBlock: ({ x, y, z, role }: {
|
|
352
|
-
x: number;
|
|
353
|
-
y: number;
|
|
354
|
-
z: number;
|
|
355
|
-
role?: string;
|
|
356
|
-
}) => SelectorClass<true, true>;
|
|
357
|
-
/**
|
|
358
|
-
* Condition that matches `@s` when the player has voted in `voteId` (any
|
|
359
|
-
* option), or — when `option` is given — only when they voted for that
|
|
360
|
-
* specific option. Agents cast votes with skills.voteForOption; the arena
|
|
361
|
-
* records each pick as the player tags kradle.voteOptions.<voteId> and
|
|
362
|
-
* kradle.voteOptions.<voteId>.<option>.
|
|
363
|
-
*
|
|
364
|
-
* It matches `@s`, so use it as a CONDITION in a player context — inside
|
|
365
|
-
* `forEveryPlayer(...)`, or in `setEndStates` / win conditions. Don't hand it
|
|
366
|
-
* to `execute.as(...)` from a tick/load context: `@s` resolves to no one
|
|
367
|
-
* there, so the command runs for nobody (the context-safety check flags this).
|
|
368
|
-
*
|
|
369
|
-
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
370
|
-
* @param {string} [option] - Optional specific option, e.g. "red".
|
|
371
|
-
* @returns {ConditionType} a per-player condition for `_.if` / win conditions.
|
|
372
|
-
* @throws {Error} If the vote or option isn't declared in config.ts's votingOptions.
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* // Teleport everyone who picked the red room.
|
|
376
|
-
* forEveryPlayer(() => {
|
|
377
|
-
* _.if(Actions.votedFor("selectroom", "red"), () => {
|
|
378
|
-
* Actions.teleport({ target: "self", x: 10, y: -60, z: 10, absolute: true });
|
|
379
|
-
* });
|
|
380
|
-
* });
|
|
381
|
-
*/
|
|
382
|
-
votedFor: (voteId: string, option?: string) => SelectorClass<true, true>;
|
|
383
|
-
/**
|
|
384
|
-
* Announces a vote to all participants over the `***KRADLE***` channel agents
|
|
385
|
-
* read, naming the vote and its options. Agents respond with
|
|
386
|
-
* skills.voteForOption(voteId, option). Compose with `allVotesIn`,
|
|
387
|
-
* `assignDefaultVotes`, and `votedFor` to build a full vote phase.
|
|
388
|
-
*
|
|
389
|
-
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
390
|
-
* @param {string} prompt - Human-readable instruction, e.g. "Pick a room!".
|
|
391
|
-
* @param {string[]} options - Valid options, e.g. ["red", "green", "blue"].
|
|
392
|
-
* @throws {Error} If the vote or any option isn't declared in config.ts's votingOptions.
|
|
393
|
-
*
|
|
394
|
-
* @example
|
|
395
|
-
* Actions.promptVote({ voteId: "selectroom", prompt: "Pick a room!", options: ["red", "green"] });
|
|
396
|
-
*/
|
|
397
|
-
promptVote: ({ voteId, prompt, options }: {
|
|
398
|
-
voteId: string;
|
|
399
|
-
prompt: string;
|
|
400
|
-
options: string[];
|
|
401
|
-
}) => void;
|
|
402
|
-
/**
|
|
403
|
-
* Condition that is true once every participant has voted in `voteId` — i.e.
|
|
404
|
-
* no participant is still missing the `kradle.voteOptions.<voteId>` tag the
|
|
405
|
-
* arena writes on each vote. Combine with a timer to end a vote phase as soon
|
|
406
|
-
* as everyone is in.
|
|
407
|
-
*
|
|
408
|
-
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
409
|
-
* @returns {ConditionType} true when all participants have voted.
|
|
410
|
-
* @throws {Error} If the vote isn't declared in config.ts's votingOptions.
|
|
411
|
-
*
|
|
412
|
-
* @example
|
|
413
|
-
* _.if(_.or(Actions.allVotesIn("selectroom"), vars.voteTimer.greaterOrEqualThan(600)), () => { ... });
|
|
414
|
-
*/
|
|
415
|
-
allVotesIn: (voteId: string) => import("sandstone/flow").CombinedConditions;
|
|
416
|
-
/**
|
|
417
|
-
* Records `default` for every participant who has not voted in `voteId` yet —
|
|
418
|
-
* call this when a vote phase times out so non-voters are still moved by
|
|
419
|
-
* `votedFor`. Writes the same tags the arena would (kradle.voteOptions.<voteId>
|
|
420
|
-
* and kradle.voteOptions.<voteId>.<option>).
|
|
421
|
-
*
|
|
422
|
-
* @param {string} voteId - The vote's id, e.g. "selectroom".
|
|
423
|
-
* @param {string} default - Option assigned to non-voters, e.g. "red".
|
|
424
|
-
* @throws {Error} If the vote or default option isn't declared in config.ts's votingOptions.
|
|
425
|
-
*
|
|
426
|
-
* @example
|
|
427
|
-
* Actions.assignDefaultVotes({ voteId: "selectroom", default: "red" });
|
|
428
|
-
*/
|
|
429
|
-
assignDefaultVotes: ({ voteId, default: defaultOption }: {
|
|
430
|
-
voteId: string;
|
|
431
|
-
default: string;
|
|
432
|
-
}) => void;
|
|
433
|
-
/**
|
|
434
|
-
* log a message with the watcher
|
|
435
|
-
* @param {string} message - The message to send.
|
|
436
|
-
* @param {Score} variable - The variable to log.
|
|
437
|
-
* @param {boolean} store - Whether to store the variable in the backend.
|
|
438
|
-
*/
|
|
439
|
-
log_variable: ({ message, variable, store }: {
|
|
440
|
-
message: string;
|
|
441
|
-
variable: Score;
|
|
442
|
-
store: boolean;
|
|
443
|
-
}) => void;
|
|
444
|
-
/**
|
|
445
|
-
* Summon an item at a specific location.
|
|
446
|
-
* @param {ITEMS} item - The item to summon.
|
|
447
|
-
* @param {number} x - The x coordinate of the location.
|
|
448
|
-
* @param {number} y - The y coordinate of the location.
|
|
449
|
-
* @param {number} z - The z coordinate of the location.
|
|
450
|
-
* @param {boolean} absolute - Whether the coordinates are absolute or relative.
|
|
451
|
-
*/
|
|
452
|
-
summonItem: ({ item, x, y, z, absolute }: {
|
|
453
|
-
item: ITEMS;
|
|
454
|
-
x: number;
|
|
455
|
-
y: number;
|
|
456
|
-
z: number;
|
|
457
|
-
absolute: boolean;
|
|
458
|
-
}) => void;
|
|
459
|
-
/**
|
|
460
|
-
* Count the number of a specific item in a target's inventory.
|
|
461
|
-
* @param params - The parameters object.
|
|
462
|
-
* @param params.target - The target to count items for.
|
|
463
|
-
* @param params.item - The item to count.
|
|
464
|
-
* @returns The variable containing the item count.
|
|
465
|
-
*/
|
|
466
|
-
countItems: ({ target, item }: {
|
|
467
|
-
target: TargetNames;
|
|
468
|
-
item: ITEMS;
|
|
469
|
-
}) => Score<string | undefined>;
|
|
470
|
-
/**
|
|
471
|
-
* Compute the maximum value of an individual score across all
|
|
472
|
-
* participants and store it in a global Variable. Returns the variable.
|
|
473
|
-
*
|
|
474
|
-
* Why this helper exists: end-state and end-condition checks evaluated
|
|
475
|
-
* from `events.on_tick` run in server context (the caller is a non-player
|
|
476
|
-
* entity), so an `if score @s X matches Y` check on a per-player score
|
|
477
|
-
* silently fails because @s has no entry on the per-player objective.
|
|
478
|
-
* Wrapping the comparison in this helper materializes a global "max
|
|
479
|
-
* across players" value that IS safe to reference from those checks.
|
|
480
|
-
*
|
|
481
|
-
* @param {Score} score - The per-player score to aggregate.
|
|
482
|
-
* @param {number} [min=0] - Lower bound to seed the result with. Pass a
|
|
483
|
-
* negative value if your per-player score can go below 0 (e.g. climb's
|
|
484
|
-
* `current_height` defaulting to -1000); otherwise the default `0`
|
|
485
|
-
* would mask negative actual maxes.
|
|
486
|
-
* @returns {Score} An anonymous Score containing the max.
|
|
487
|
-
*
|
|
488
|
-
* @example
|
|
489
|
-
* // In a custom_variables global updater:
|
|
490
|
-
* max_diamonds: {
|
|
491
|
-
* type: "global",
|
|
492
|
-
* default: 0,
|
|
493
|
-
* updater: (value, { diamonds }) => {
|
|
494
|
-
* value.set(Actions.maxPlayerScore({ score: diamonds }));
|
|
495
|
-
* },
|
|
496
|
-
* },
|
|
497
|
-
*
|
|
498
|
-
* // Then end-states can reference the global:
|
|
499
|
-
* .events(({ max_diamonds }) => ({
|
|
500
|
-
* on_tick: () => Actions.setEndStates({
|
|
501
|
-
* winner_found: max_diamonds.greaterOrEqualThan(5),
|
|
502
|
-
* }),
|
|
503
|
-
* }))
|
|
504
|
-
*
|
|
505
|
-
* @example
|
|
506
|
-
* // Climb's max_height — y can go below 0:
|
|
507
|
-
* max_height_global: {
|
|
508
|
-
* type: "global",
|
|
509
|
-
* default: -1000,
|
|
510
|
-
* updater: (value, { max_height }) => {
|
|
511
|
-
* value.set(Actions.maxPlayerScore({ score: max_height, min: -1000 }));
|
|
512
|
-
* },
|
|
513
|
-
* },
|
|
514
|
-
*/
|
|
515
|
-
maxPlayerScore: ({ score, min }: {
|
|
516
|
-
score: Score;
|
|
517
|
-
min?: number;
|
|
518
|
-
}) => Score;
|
|
519
|
-
/**
|
|
520
|
-
* Returns a Sandstone condition that's true when the executing player
|
|
521
|
-
* (in `as @s` context) is standing on `block`. The default is a
|
|
522
|
-
* single-cell check (block at `~ ~-1 ~`), but `slop` widens the check
|
|
523
|
-
* to a `(2*slop+1)×(2*slop+1)` patch around the player's foot position
|
|
524
|
-
* — useful when the agent's pathfinder leaves them slightly off-center
|
|
525
|
-
* from a target block (e.g. mineflayer's `goToNearestBlock` reports
|
|
526
|
-
* success once within ~1.5 blocks of the target, so the agent is
|
|
527
|
-
* commonly off by a fractional block in x/z).
|
|
528
|
-
*
|
|
529
|
-
* Compiles to: `block ~ ~-1 ~ <block>` for slop=0, or an `_.or(...)` of
|
|
530
|
-
* 9 / 25 / etc. cell checks for slop=1 / 2 / etc.
|
|
531
|
-
*
|
|
532
|
-
* @example
|
|
533
|
-
* // PD-style "did the agent step on the cooperate pad?" check
|
|
534
|
-
* choice: {
|
|
535
|
-
* type: "individual",
|
|
536
|
-
* default: 0,
|
|
537
|
-
* updater: (value) => {
|
|
538
|
-
* _.if(Actions.isStandingOn({ block: "minecraft:lime_wool", slop: 1 }), () => {
|
|
539
|
-
* value.set(COOPERATE);
|
|
540
|
-
* });
|
|
541
|
-
* },
|
|
542
|
-
* },
|
|
543
|
-
*/
|
|
544
|
-
isStandingOn: ({ block, slop }: {
|
|
545
|
-
block: BLOCKS;
|
|
546
|
-
slop?: number;
|
|
547
|
-
}) => ConditionType;
|
|
548
|
-
/**
|
|
549
|
-
* Count instances of a block within an axis-aligned region. Useful for
|
|
550
|
-
* detecting agent-built structures without pinning detection to a single
|
|
551
|
-
* coordinate (which breaks the moment the agent moves before building).
|
|
552
|
-
*
|
|
553
|
-
* Implementation note: emits one `execute if block` check per cell in the
|
|
554
|
-
* region at codegen time, so the region is hard-capped at 4096 cells
|
|
555
|
-
* (~64×8×8) to keep the generated datapack reasonable.
|
|
556
|
-
*
|
|
557
|
-
* @param block The block ID to count (e.g. "minecraft:cobblestone").
|
|
558
|
-
* @param from First corner of the region (inclusive).
|
|
559
|
-
* @param to Opposite corner (inclusive).
|
|
560
|
-
* @param absolute Whether `from` / `to` are absolute world coordinates.
|
|
561
|
-
* @returns A Sandstone `Score` containing the count.
|
|
562
|
-
*
|
|
563
|
-
* @example
|
|
564
|
-
* // Detect any 5+ cobblestone block tower built within a 12×6×12 zone:
|
|
565
|
-
* const count = Actions.countBlocksInRegion({
|
|
566
|
-
* block: "minecraft:cobblestone",
|
|
567
|
-
* from: { x: -6, y: -60, z: -6 },
|
|
568
|
-
* to: { x: 6, y: -55, z: 6 },
|
|
569
|
-
* absolute: true,
|
|
570
|
-
* });
|
|
571
|
-
* _.if(count.greaterOrEqualThan(5), () => Actions.announce({ message: "Tower built!" }));
|
|
572
|
-
*/
|
|
573
|
-
countBlocksInRegion: ({ block, from, to, absolute, }: {
|
|
574
|
-
block: BLOCKS;
|
|
575
|
-
from: {
|
|
576
|
-
x: number;
|
|
577
|
-
y: number;
|
|
578
|
-
z: number;
|
|
579
|
-
};
|
|
580
|
-
to: {
|
|
581
|
-
x: number;
|
|
582
|
-
y: number;
|
|
583
|
-
z: number;
|
|
584
|
-
};
|
|
585
|
-
absolute: boolean;
|
|
586
|
-
}) => Score;
|
|
587
|
-
/**
|
|
588
|
-
* Count instances of a block in a region centered on a target. Same idea
|
|
589
|
-
* as `countBlocksInRegion` but the bounds are *relative to the target's
|
|
590
|
-
* current position* — useful when the region of interest moves with a
|
|
591
|
-
* player (e.g. "how many X blocks are around the agent right now").
|
|
592
|
-
*
|
|
593
|
-
* What this is NOT: it does not verify a structure (the matches don't
|
|
594
|
-
* have to be contiguous), and it does not prove the target placed them.
|
|
595
|
-
* Treat the result as "presence count in a volume." Turn it into "the
|
|
596
|
-
* agent placed N of these" only when the block type doesn't spawn
|
|
597
|
-
* naturally in your world (and your arena init didn't pre-place any), or
|
|
598
|
-
* by clearing the volume first and counting the delta.
|
|
599
|
-
*
|
|
600
|
-
* Implementation note: emits one `execute as <target> at @s if block`
|
|
601
|
-
* check per cell at codegen time, so the region is hard-capped at 4096
|
|
602
|
-
* cells just like `countBlocksInRegion`.
|
|
603
|
-
*
|
|
604
|
-
* @example
|
|
605
|
-
* // Count diamond_block instances within 6 blocks of the agent. Diamond
|
|
606
|
-
* // blocks don't generate naturally, so in a flat-world challenge whose
|
|
607
|
-
* // arena init doesn't pre-place any, this is equivalently the count of
|
|
608
|
-
* // diamond blocks the agent has placed within reach.
|
|
609
|
-
* diamond_blocks_nearby: {
|
|
610
|
-
* type: "individual",
|
|
611
|
-
* default: 0,
|
|
612
|
-
* updater: (value) => {
|
|
613
|
-
* value.set(Actions.countBlocksRelativeTo({
|
|
614
|
-
* target: "self",
|
|
615
|
-
* block: "minecraft:diamond_block",
|
|
616
|
-
* dxRange: [-6, 6],
|
|
617
|
-
* dyRange: [-2, 4],
|
|
618
|
-
* dzRange: [-6, 6],
|
|
619
|
-
* }));
|
|
620
|
-
* },
|
|
621
|
-
* }
|
|
622
|
-
*/
|
|
623
|
-
countBlocksRelativeTo: ({ target, block, dxRange, dyRange, dzRange, }: {
|
|
624
|
-
target: TargetNames;
|
|
625
|
-
block: BLOCKS;
|
|
626
|
-
dxRange: [number, number];
|
|
627
|
-
dyRange: [number, number];
|
|
628
|
-
dzRange: [number, number];
|
|
629
|
-
}) => Score;
|
|
630
|
-
/**
|
|
631
|
-
* Get the current player's position as x, y, z Score variables.
|
|
632
|
-
* Must be called in a player context (e.g., inside forEveryPlayer or when @s is a player).
|
|
633
|
-
* @returns An object with x, y, z Score variables containing the player's coordinates.
|
|
634
|
-
*/
|
|
635
|
-
getCurrentPlayerPosition: () => {
|
|
636
|
-
x: Score<string | undefined>;
|
|
637
|
-
y: Score<string | undefined>;
|
|
638
|
-
z: Score<string | undefined>;
|
|
639
|
-
};
|
|
640
|
-
/**
|
|
641
|
-
* Get a location marker entity by name.
|
|
642
|
-
* Returns a selector that targets the marker entity with the specified location tag.
|
|
643
|
-
* Locations must be defined in config.ts under "challengeConfig.locations".
|
|
644
|
-
* @param {string} name - The name of the location (must match a key in config.locations).
|
|
645
|
-
* @returns A selector targeting the location marker entity.
|
|
646
|
-
* @throws {Error} If KRADLE_CHALLENGE_LOCATIONS is set and the location name is not in the list.
|
|
647
|
-
*/
|
|
648
|
-
getLocation: ({ name }: {
|
|
649
|
-
name: string;
|
|
650
|
-
}) => SelectorClass<true, false>;
|
|
651
|
-
/**
|
|
652
|
-
* Build a box (4 walls + optional floor/roof) in a single call. Replaces
|
|
653
|
-
* the typical 5+ `Actions.fill` calls per arena.
|
|
654
|
-
*
|
|
655
|
-
* @param block The wall block (e.g. "minecraft:stone").
|
|
656
|
-
* @param from First corner (inclusive).
|
|
657
|
-
* @param to Opposite corner (inclusive).
|
|
658
|
-
* @param absolute Whether coordinates are absolute or player-relative.
|
|
659
|
-
* @param hollow When true (default), only walls are placed; the interior is left untouched.
|
|
660
|
-
* When false, the entire volume is filled with `block`.
|
|
661
|
-
* @param floor Optional block to fill the floor with (overrides `block` for floor only).
|
|
662
|
-
* @param roof Optional block to fill the roof with.
|
|
663
|
-
* @param clearInside When true and `hollow=true`, the interior volume is set to air
|
|
664
|
-
* (useful for clearing existing terrain inside the new box).
|
|
665
|
-
*
|
|
666
|
-
* @example
|
|
667
|
-
* // 13x13x5 stone arena with a stone-bricks floor, no roof, interior cleared
|
|
668
|
-
* Actions.box({
|
|
669
|
-
* block: "minecraft:stone",
|
|
670
|
-
* from: { x: -6, y: -60, z: -6 },
|
|
671
|
-
* to: { x: 6, y: -55, z: 6 },
|
|
672
|
-
* absolute: true,
|
|
673
|
-
* hollow: true,
|
|
674
|
-
* floor: "minecraft:stone_bricks",
|
|
675
|
-
* clearInside: true,
|
|
676
|
-
* });
|
|
677
|
-
*/
|
|
678
|
-
box: ({ block, from, to, absolute, hollow, floor, roof, clearInside, }: {
|
|
679
|
-
block: BLOCKS;
|
|
680
|
-
from: {
|
|
681
|
-
x: number;
|
|
682
|
-
y: number;
|
|
683
|
-
z: number;
|
|
684
|
-
};
|
|
685
|
-
to: {
|
|
686
|
-
x: number;
|
|
687
|
-
y: number;
|
|
688
|
-
z: number;
|
|
689
|
-
};
|
|
690
|
-
absolute: boolean;
|
|
691
|
-
hollow?: boolean;
|
|
692
|
-
floor?: BLOCKS;
|
|
693
|
-
roof?: BLOCKS;
|
|
694
|
-
clearInside?: BLOCKS | boolean;
|
|
695
|
-
}) => void;
|
|
696
|
-
/**
|
|
697
|
-
* Give every participant a list of items in one call. Replaces the
|
|
698
|
-
* sequence of `Actions.give({ target: "all", item: …, count: … })` calls
|
|
699
|
-
* that opens nearly every multi-player start_challenge (castle-ctf has
|
|
700
|
-
* six of them for the iron-sword + 4 armor pieces + food loadout).
|
|
701
|
-
*
|
|
702
|
-
* @example PvP standard kit:
|
|
703
|
-
* ```ts
|
|
704
|
-
* Actions.giveAll([
|
|
705
|
-
* { item: "minecraft:iron_sword" },
|
|
706
|
-
* { item: "minecraft:iron_helmet" },
|
|
707
|
-
* { item: "minecraft:iron_chestplate" },
|
|
708
|
-
* { item: "minecraft:iron_leggings" },
|
|
709
|
-
* { item: "minecraft:iron_boots" },
|
|
710
|
-
* { item: "minecraft:cooked_beef", count: 5 },
|
|
711
|
-
* ]);
|
|
712
|
-
* ```
|
|
713
|
-
*
|
|
714
|
-
* `count` defaults to 1. For role-specific equipment, use plain
|
|
715
|
-
* `Actions.give({ target: roleName, … })`.
|
|
716
|
-
*/
|
|
717
|
-
giveAll: (items: Array<{
|
|
718
|
-
item: ITEMS;
|
|
719
|
-
count?: number;
|
|
720
|
-
}>) => void;
|
|
721
|
-
/**
|
|
722
|
-
* "When the block at this absolute coordinate stops being `expected`, set
|
|
723
|
-
* `into` to 1." The standard goal_broken / flag_broken global-variable
|
|
724
|
-
* updater idiom. Latches at 1 — once tripped, stays tripped (so the
|
|
725
|
-
* end_state fires consistently even if the block is later replaced).
|
|
726
|
-
*
|
|
727
|
-
* Replaces the 4-line `_.if(_.not(_.block(abs(...), ...)), () => value.set(1))`
|
|
728
|
-
* pattern that appears in ~10 challenges' custom_variable updaters
|
|
729
|
-
* (castle-ctf×2, castle-siege×4, defender-striker, beanstalk, tower-trio,
|
|
730
|
-
* tunnel-rush, sky-walker, …). Removes the need to import `abs` from
|
|
731
|
-
* sandstone for this purpose.
|
|
732
|
-
*
|
|
733
|
-
* For multi-block checks ("all N landmarks broken" — diamond-hunt,
|
|
734
|
-
* return-home), keep using the manual `_.if(_.and(...conditions), …)`
|
|
735
|
-
* pattern — this helper is single-block only.
|
|
736
|
-
*
|
|
737
|
-
* @example castle-ctf red flag (latching — once broken, stays broken):
|
|
738
|
-
* ```ts
|
|
739
|
-
* red_flag_broken: {
|
|
740
|
-
* type: "global",
|
|
741
|
-
* default: 0,
|
|
742
|
-
* updater: (value) => {
|
|
743
|
-
* // Latch: only flip 0→1, never reset to 0. The returned Score is
|
|
744
|
-
* // itself a Condition (truthy = non-zero), so no `.equalTo(1)` needed.
|
|
745
|
-
* _.if(Actions.detectBlockMissing({
|
|
746
|
-
* at: { x: RED_BASE.x, y: RED_BASE.y + 1, z: RED_BASE.z },
|
|
747
|
-
* expected: "minecraft:red_wool",
|
|
748
|
-
* }), () => value.set(1));
|
|
749
|
-
* },
|
|
750
|
-
* }
|
|
751
|
-
* ```
|
|
752
|
-
*
|
|
753
|
-
* @returns {Score} An anonymous Score: 1 if the block at `at` is NOT
|
|
754
|
-
* `expected`, 0 if it is. Non-latching — recomputed every call. Wrap in
|
|
755
|
-
* `_.if(missing, () => value.set(1))` (the Score is itself a Condition,
|
|
756
|
-
* truthy = non-zero) for the latching "once broken, stays broken" pattern.
|
|
757
|
-
*/
|
|
758
|
-
detectBlockMissing: ({ at, expected }: {
|
|
759
|
-
at: {
|
|
760
|
-
x: number;
|
|
761
|
-
y: number;
|
|
762
|
-
z: number;
|
|
763
|
-
};
|
|
764
|
-
expected: BLOCKS;
|
|
765
|
-
}) => Score;
|
|
766
|
-
/**
|
|
767
|
-
* Summon a single configurable entity with optional health, attack damage,
|
|
768
|
-
* movement speed, and tags. Uses Sandstone's typed `summon` + NBT helpers
|
|
769
|
-
* (`NBT.byte`, `NBT.float`) so that booleans and NBT primitives serialize
|
|
770
|
-
* correctly — sandstone otherwise emits JS `true` as `{}` (an invalid NBT
|
|
771
|
-
* token), which broke boss-brawl's `CustomNameVisible: true` summon early on.
|
|
772
|
-
*
|
|
773
|
-
* For boss-style configured mobs (boss-solo, boss-brawl). Use
|
|
774
|
-
* `Actions.summonMultiple` for plain entities without stat overrides.
|
|
775
|
-
*
|
|
776
|
-
* @example A 60-HP fast-moving boss zombie:
|
|
777
|
-
* ```ts
|
|
778
|
-
* Actions.summonEntityWithStats({
|
|
779
|
-
* entity: "minecraft:zombie",
|
|
780
|
-
* x: 0, y: -60, z: 0, absolute: true,
|
|
781
|
-
* health: 60,
|
|
782
|
-
* attackDamage: 6,
|
|
783
|
-
* movementSpeed: 0.18,
|
|
784
|
-
* tags: ["boss"], // for `Actions.countEntities({ tag: "boss", … })`
|
|
785
|
-
* });
|
|
786
|
-
* ```
|
|
787
|
-
*/
|
|
788
|
-
summonEntityWithStats: ({ entity, x, y, z, absolute, health, attackDamage, movementSpeed, tags, }: {
|
|
789
|
-
entity: ENTITY_TYPES;
|
|
790
|
-
x: number;
|
|
791
|
-
y: number;
|
|
792
|
-
z: number;
|
|
793
|
-
absolute: boolean;
|
|
794
|
-
health?: number;
|
|
795
|
-
attackDamage?: number;
|
|
796
|
-
movementSpeed?: number;
|
|
797
|
-
tags?: string[];
|
|
798
|
-
}) => void;
|
|
799
|
-
/**
|
|
800
|
-
* Count entities matching any combination of `entity` type, `tag`, and/or
|
|
801
|
-
* `volume`, returning the count as an anonymous `Score`. At least one
|
|
802
|
-
* filter must be provided (counting "every entity in the world" is almost
|
|
803
|
-
* always a bug — guarded at runtime).
|
|
804
|
-
*
|
|
805
|
-
* Use this in a global custom_variable updater whose value tracks "how
|
|
806
|
-
* many Xs are currently in the world", e.g. boss alive (zombie count),
|
|
807
|
-
* chickens left, sheep in a pen.
|
|
808
|
-
*
|
|
809
|
-
* @param entity Optional entity type (e.g. `"minecraft:zombie"`).
|
|
810
|
-
* @param tag Optional tag filter (Minecraft `@e[tag=…]`). Used by e.g.
|
|
811
|
-
* boss-brawl, which counts zombies tagged `"boss"` to ignore wave-spawned mooks.
|
|
812
|
-
* @param volume Optional bounding box (Minecraft-style: corner + dx/dy/dz
|
|
813
|
-
* extents, absolute coords). Omit to count anywhere in the world.
|
|
814
|
-
* @returns {Score} An anonymous Score holding the count.
|
|
815
|
-
*
|
|
816
|
-
* @example boss_alive — counts zombies anywhere
|
|
817
|
-
* ```ts
|
|
818
|
-
* boss_alive: {
|
|
819
|
-
* type: "global",
|
|
820
|
-
* default: 1,
|
|
821
|
-
* updater: (value) => {
|
|
822
|
-
* value.set(Actions.countEntities({ entity: "minecraft:zombie" }));
|
|
823
|
-
* },
|
|
824
|
-
* }
|
|
825
|
-
* ```
|
|
826
|
-
*
|
|
827
|
-
* @example boss-brawl — count only the tagged boss zombies
|
|
828
|
-
* ```ts
|
|
829
|
-
* value.set(Actions.countEntities({ entity: "minecraft:zombie", tag: "boss" }));
|
|
830
|
-
* ```
|
|
831
|
-
*
|
|
832
|
-
* @example sheep_in_pen — counts sheep inside a 3×1×3 box
|
|
833
|
-
* ```ts
|
|
834
|
-
* value.set(Actions.countEntities({
|
|
835
|
-
* entity: "minecraft:sheep",
|
|
836
|
-
* volume: { x: 14, y: -59, z: -1, dx: 2, dy: 1, dz: 2 },
|
|
837
|
-
* }));
|
|
838
|
-
* ```
|
|
839
|
-
*/
|
|
840
|
-
countEntities: ({ entity, tag, volume, }: {
|
|
841
|
-
entity?: ENTITY_TYPES;
|
|
842
|
-
tag?: string;
|
|
843
|
-
volume?: {
|
|
844
|
-
x: number;
|
|
845
|
-
y: number;
|
|
846
|
-
z: number;
|
|
847
|
-
dx: number;
|
|
848
|
-
dy: number;
|
|
849
|
-
dz: number;
|
|
850
|
-
};
|
|
851
|
-
}) => Score;
|
|
852
|
-
/**
|
|
853
|
-
* Build a flat open arena: a single-block-thick floor at `center.y` with
|
|
854
|
-
* cleared airspace above up to `headroom` blocks tall. The "no walls,
|
|
855
|
-
* just open ground for things to move on" pattern shared by sumo-arena,
|
|
856
|
-
* boss-brawl, wave-survival, stalker, and one half of defender-striker.
|
|
857
|
-
*
|
|
858
|
-
* For arenas with walls, use `Actions.box({ hollow: true, floor: … })`.
|
|
859
|
-
*
|
|
860
|
-
* @example
|
|
861
|
-
* Actions.flatArena({
|
|
862
|
-
* block: "minecraft:stone",
|
|
863
|
-
* center: { x: 0, y: -60, z: 0 },
|
|
864
|
-
* radius: 10, // 21×21 footprint
|
|
865
|
-
* headroom: 4, // 4 blocks of air above the floor (default 4)
|
|
866
|
-
* });
|
|
867
|
-
*/
|
|
868
|
-
flatArena: ({ block, center, radius, headroom, }: {
|
|
869
|
-
block: BLOCKS;
|
|
870
|
-
center: {
|
|
871
|
-
x: number;
|
|
872
|
-
y: number;
|
|
873
|
-
z: number;
|
|
874
|
-
};
|
|
875
|
-
radius: number;
|
|
876
|
-
/** How many blocks of air to clear above the floor. Default 4. */
|
|
877
|
-
headroom?: number;
|
|
878
|
-
}) => void;
|
|
879
|
-
/**
|
|
880
|
-
* Apply a non-lethal knockback / displacement to a target via Minecraft's
|
|
881
|
-
* `effect` command. The default effect is a brief levitation (lifts the
|
|
882
|
-
* target straight up without dealing damage).
|
|
883
|
-
*
|
|
884
|
-
* Use `mode: "slowfall"` to combine levitation with slow falling so the
|
|
885
|
-
* target doesn't take fall damage on landing.
|
|
886
|
-
*
|
|
887
|
-
* @example
|
|
888
|
-
* // Periodic knockback in King-of-the-Hill style:
|
|
889
|
-
* Actions.knockbackWithLevitation({ target: "all", durationSeconds: 2, amplifier: 6 });
|
|
890
|
-
*
|
|
891
|
-
* // Knock with slow-fall for safe landing:
|
|
892
|
-
* Actions.knockbackWithLevitation({ target: "self", mode: "slowfall", durationSeconds: 3 });
|
|
893
|
-
*/
|
|
894
|
-
knockbackWithLevitation: ({ target, durationSeconds, amplifier, mode, }: {
|
|
895
|
-
target: TargetNames;
|
|
896
|
-
durationSeconds?: number;
|
|
897
|
-
amplifier?: number;
|
|
898
|
-
mode?: "levitation" | "slowfall";
|
|
899
|
-
}) => void;
|
|
900
|
-
};
|
|
901
|
-
//# sourceMappingURL=actions.d.ts.map
|