@kradle/challenges 0.1.0 → 0.2.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/AGENTS.md +283 -0
- package/CLAUDE.md +1 -0
- package/LLM_README.md +1532 -0
- package/README.md +489 -1
- package/dist/actions.d.ts +23 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +27 -1
- package/dist/actions.js.map +1 -1
- package/dist/challenge.js +1 -1
- package/dist/challenge.js.map +1 -1
- package/package.json +1 -1
- package/src/actions.ts +32 -3
- package/src/challenge.ts +1 -1
package/README.md
CHANGED
|
@@ -1 +1,489 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- This file is for human consumption. If you are an LLM or any AI Agent, make sure to read LLM_README.md for an exhaustive explanation of this package. -->
|
|
2
|
+
|
|
3
|
+
# @kradle/challenges
|
|
4
|
+
|
|
5
|
+
A TypeScript framework for creating Minecraft datapack-based challenges with event-driven game logic, score tracking, and player role management. Built on top of [Sandstone](https://sandstone.dev/).
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
We strongly recommend using [Kradle's CLI](https://github.com/kradle-ai/cli) to create challenges with the CLI. Make sure to read the CLI's README
|
|
10
|
+
|
|
11
|
+
If you still want to perform a manual installation, you also need to install the Sandstone peer-dependency:
|
|
12
|
+
```bash
|
|
13
|
+
npm install @kradle/challenges sandstone@0.14.0-alpha.13
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
Like for installation, we strongly recommend using Kradle's CLI to bootstrap a challenge:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Will create a challenge in challenges/my-challenge/
|
|
22
|
+
kradle challenge create my-challenge
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## API Overview
|
|
27
|
+
|
|
28
|
+
### `createChallenge(config)`
|
|
29
|
+
|
|
30
|
+
Creates a new challenge with the specified configuration.
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
createChallenge({
|
|
34
|
+
name: string; // Challenge name (used for datapack)
|
|
35
|
+
kradle_challenge_path: string; // Output directory for generated datapack
|
|
36
|
+
roles: readonly string[]; // Player roles (e.g., ["attacker", "defender"])
|
|
37
|
+
GAME_DURATION?: number; // Duration in ticks (default: 6000 = 5 minutes)
|
|
38
|
+
custom_variables: Record<string, VariableDefinition>;
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Fluent Builder Methods
|
|
43
|
+
|
|
44
|
+
The challenge builder uses a fluent API:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
createChallenge(config)
|
|
48
|
+
.events(callback) // Define lifecycle event handlers
|
|
49
|
+
.custom_events(callback) // Define score/advancement-triggered events
|
|
50
|
+
.end_condition(callback) // Define when the game ends
|
|
51
|
+
.win_conditions(callback) // Define win conditions per role
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Variables
|
|
55
|
+
|
|
56
|
+
Variables are the core mechanism for tracking game state. All variables are automatically updated each tick.
|
|
57
|
+
|
|
58
|
+
### Built-in Variables
|
|
59
|
+
|
|
60
|
+
These variables are always available:
|
|
61
|
+
|
|
62
|
+
| Variable | Type | Description |
|
|
63
|
+
|----------|------|-------------|
|
|
64
|
+
| `death_count` | individual | Number of times the player has died |
|
|
65
|
+
| `has_never_died` | individual | 1 if player hasn't died, 0 otherwise |
|
|
66
|
+
| `alive_players` | global | Count of living participants |
|
|
67
|
+
| `main_score` | individual | Primary score displayed on sidebar |
|
|
68
|
+
| `game_timer` | global | Ticks elapsed since game start |
|
|
69
|
+
| `game_state` | global | Current state (0=CREATED, 1=OFF, 2=ON) |
|
|
70
|
+
| `player_count` | global | Total number of participants |
|
|
71
|
+
| `player_number` | individual | Unique player ID (1 to N) |
|
|
72
|
+
|
|
73
|
+
### Custom Variable Types
|
|
74
|
+
|
|
75
|
+
#### Individual Variables (per-player)
|
|
76
|
+
|
|
77
|
+
Track values for each player separately.
|
|
78
|
+
|
|
79
|
+
**Objective-based** (uses Minecraft statistics):
|
|
80
|
+
```typescript
|
|
81
|
+
pigs_killed: {
|
|
82
|
+
type: "individual",
|
|
83
|
+
objective_type: "minecraft.killed:minecraft.pig",
|
|
84
|
+
default: 0,
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Dummy** (computed values):
|
|
89
|
+
```typescript
|
|
90
|
+
current_height: {
|
|
91
|
+
type: "individual",
|
|
92
|
+
objective_type: "dummy",
|
|
93
|
+
updater: (value) => {
|
|
94
|
+
value.set(Actions.getPlayerPosition().y)
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Global Variables (shared)
|
|
100
|
+
|
|
101
|
+
Track values across all players.
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
max_score: {
|
|
105
|
+
type: "global",
|
|
106
|
+
hidden: false, // optional: hide from scoreboard
|
|
107
|
+
default: 0,
|
|
108
|
+
updater: (value, { main_score }) => {
|
|
109
|
+
value.set(0);
|
|
110
|
+
forEveryPlayer(() => {
|
|
111
|
+
_.if(main_score.greaterThan(value), () => {
|
|
112
|
+
value.set(main_score);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Updater Functions
|
|
120
|
+
|
|
121
|
+
Updaters run every tick and receive `(currentValue, allVariables)`:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
updater: (value, { main_score, death_count, game_timer }) => {
|
|
125
|
+
// Set value based on other variables
|
|
126
|
+
value.set(0);
|
|
127
|
+
_.if(main_score.greaterThan(10), () => {
|
|
128
|
+
value.set(1);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
If you track a Minecraft objective, you do not need an updater!
|
|
134
|
+
|
|
135
|
+
## Events
|
|
136
|
+
|
|
137
|
+
### Lifecycle Events
|
|
138
|
+
|
|
139
|
+
Lifecycle events are triggered once on specific occasions.
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
.events((variables, roles) => ({
|
|
143
|
+
start_challenge: () => {
|
|
144
|
+
// Runs once when the challenge starts
|
|
145
|
+
Actions.setTime({ time: "day" });
|
|
146
|
+
Actions.announce({ message: "Game starting!" });
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
init_participants: () => {
|
|
150
|
+
// Runs 1s after the challenge starts
|
|
151
|
+
Actions.give({ target: "all", item: "minecraft:diamond_sword", count: 1 });
|
|
152
|
+
Actions.setAttribute({ target: "all", attribute_: "generic.max_health", value: 40 });
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
on_tick: () => {
|
|
156
|
+
// Runs once every tick
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
end_challenge: () => {
|
|
160
|
+
// Runs when the challenge ends
|
|
161
|
+
Actions.announce({ message: "Game over!" });
|
|
162
|
+
},
|
|
163
|
+
}))
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Custom Events
|
|
167
|
+
|
|
168
|
+
Custom events trigger actions based on score thresholds or Minecraft advancements.
|
|
169
|
+
|
|
170
|
+
#### Score-based events
|
|
171
|
+
|
|
172
|
+
Score events watch a variable and trigger when it reaches a target value.
|
|
173
|
+
|
|
174
|
+
- **`score`**: The variable to watch.
|
|
175
|
+
- **`target`** (optional): The target value. If omitted, triggers on any score change
|
|
176
|
+
- **`mode`**:
|
|
177
|
+
- `"fire_once"`: Triggers once when the score reaches the target (per player for individual variables)
|
|
178
|
+
- `"repeatable"`: Triggers every tick while the score is at target
|
|
179
|
+
|
|
180
|
+
For individual variables, events fire per-player; for global variables, events fire globally.
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
.custom_events((variables, roles) => [
|
|
184
|
+
{
|
|
185
|
+
score: variables.diamonds,
|
|
186
|
+
target: 5,
|
|
187
|
+
mode: "fire_once",
|
|
188
|
+
actions: () => {
|
|
189
|
+
Actions.announce({ message: "Someone collected 5 diamonds!" });
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
])
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
If `target` is omitted, the event triggers whenever the score changes (useful for reacting to any increment).
|
|
196
|
+
|
|
197
|
+
#### Advancement-based events
|
|
198
|
+
|
|
199
|
+
Advancement events trigger when a Minecraft advancement criterion is met (e.g., player attacks, item picked up). The criteria follow the [Minecraft Advancement JSON format](https://minecraft.fandom.com/wiki/Advancement/JSON_format).
|
|
200
|
+
|
|
201
|
+
Advancement-based events always fire per-player.
|
|
202
|
+
|
|
203
|
+
- **`criteria`**: Array of advancement triggers with optional conditions
|
|
204
|
+
- **`mode`**:
|
|
205
|
+
- `"fire_once"`: Triggers once per player when the advancement is granted
|
|
206
|
+
- `"repeatable"`: Triggers every time the advancement criterion is met (advancement is auto-revoked to allow re-triggering)
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
.custom_events((variables, roles) => [
|
|
210
|
+
{
|
|
211
|
+
criteria: [
|
|
212
|
+
{
|
|
213
|
+
trigger: "minecraft:player_hurt_entity",
|
|
214
|
+
conditions: {
|
|
215
|
+
entity: { type: "minecraft:player" } // Only PvP hits
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
],
|
|
219
|
+
mode: "repeatable",
|
|
220
|
+
actions: () => {
|
|
221
|
+
Actions.increment({ variable: variables.pvp_hits });
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
])
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## End Conditions
|
|
228
|
+
|
|
229
|
+
Define when the game ends:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
.end_condition(({ objective_complete }) => objective_complete.equalTo(1))
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Multiple conditions can be combined:
|
|
236
|
+
```typescript
|
|
237
|
+
.end_condition(({ alive_players, objective_complete }) =>
|
|
238
|
+
_.or(
|
|
239
|
+
alive_players.equalTo(1),
|
|
240
|
+
objective_complete.equalTo(1)
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Ending conditions are evaluated once per tick, at the global level (not individually). It means you should not check for individual variables here - instead, you should aggregate these individual variables into a global custom variable, that you then check in the ending condition.
|
|
246
|
+
|
|
247
|
+
## Win Conditions
|
|
248
|
+
|
|
249
|
+
Define how winners are determined per role:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
.win_conditions((variables, { attacker, defender }) => ({
|
|
253
|
+
[attacker]: variables.kills.greaterOrEqualThan(5),
|
|
254
|
+
[defender]: variables.survived.equalTo(1),
|
|
255
|
+
}))
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Actions
|
|
259
|
+
|
|
260
|
+
Actions are higher-level functions that wrap common Minecraft operations, designed to work seamlessly with Kradle's challenge system. They handle target mapping, formatting, and integration with Kradle's interface automatically.
|
|
261
|
+
|
|
262
|
+
For more advanced use cases, you can always fall back to Sandstone's lower-level functions directly (e.g., `give`, `tellraw`, `effect`, `kill`, `execute`). See the [Sandstone Integration](#sandstone-integration) section below.
|
|
263
|
+
|
|
264
|
+
### Communication
|
|
265
|
+
```typescript
|
|
266
|
+
// Simple string message
|
|
267
|
+
Actions.announce({ message: "Hello everyone!" });
|
|
268
|
+
|
|
269
|
+
// Formatted JSONTextComponent message
|
|
270
|
+
Actions.announce({
|
|
271
|
+
message: [
|
|
272
|
+
{ text: "Player ", color: "white" },
|
|
273
|
+
{ selector: "@s", color: "gold", bold: true },
|
|
274
|
+
{ text: " scored!", color: "green" }
|
|
275
|
+
]
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
// Send to specific target (only visible in-game, not in Kradle's interface)
|
|
279
|
+
Actions.tellraw({ target: "all", message: ["Hello ", { text: "world", color: "gold" }] });
|
|
280
|
+
Actions.tellraw({ target: "self", message: { text: "You win!", color: "green", bold: true } });
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Items & Inventory
|
|
284
|
+
```typescript
|
|
285
|
+
Actions.give({ target: "self", item: "minecraft:diamond_sword", count: 1 });
|
|
286
|
+
Actions.giveLoot({
|
|
287
|
+
target: "self",
|
|
288
|
+
items: [
|
|
289
|
+
{ name: "minecraft:diamond", count: 5, weight: 1 },
|
|
290
|
+
{ name: "minecraft:iron_ingot", count: 10, weight: 3 }
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
Actions.clear({ target: "self" });
|
|
294
|
+
|
|
295
|
+
// Count items - returns a Score variable
|
|
296
|
+
const count = Actions.countItems({ target: "self", item: "minecraft:diamond" });
|
|
297
|
+
// Use in conditions or set to custom variables
|
|
298
|
+
_.if(count.greaterThan(5), () => { /* ... */ });
|
|
299
|
+
|
|
300
|
+
// Get player position - returns { x, y, z } Score variables
|
|
301
|
+
const pos = Actions.getCurrentPlayerPosition();
|
|
302
|
+
_.if(pos.y.greaterThan(100), () => { /* player is high up */ });
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Entities
|
|
306
|
+
```typescript
|
|
307
|
+
Actions.summonMultiple({ entity: "minecraft:zombie", count: 5, x: 0, y: 64, z: 0, absolute: true });
|
|
308
|
+
Actions.kill({ selector: Selector("@e", { type: "minecraft:zombie" }) });
|
|
309
|
+
Actions.teleport({ target: "self", x: 0, y: 100, z: 0, absolute: true });
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### World
|
|
313
|
+
```typescript
|
|
314
|
+
Actions.setBlock({ block: "minecraft:diamond_block", x: 0, y: 64, z: 0, absolute: true });
|
|
315
|
+
Actions.fill({
|
|
316
|
+
block: "minecraft:stone",
|
|
317
|
+
x1: 0, y1: 64, z1: 0,
|
|
318
|
+
x2: 10, y2: 64, z2: 10,
|
|
319
|
+
absolute: true,
|
|
320
|
+
mode: "fill" // "fill", "line", or "pyramid"
|
|
321
|
+
});
|
|
322
|
+
Actions.setTime({ time: "day" }); // or "night" or specific tick value
|
|
323
|
+
Actions.gamerule({ rule: "doDaylightCycle", value: false });
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Scores
|
|
327
|
+
```typescript
|
|
328
|
+
Actions.set({ variable: variables.main_score, value: 10 });
|
|
329
|
+
Actions.set({ variable: variables.main_score, value: variables.diamonds });
|
|
330
|
+
Actions.increment({ variable: variables.counter });
|
|
331
|
+
Actions.decrement({ variable: variables.counter });
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Player Attributes
|
|
335
|
+
```typescript
|
|
336
|
+
Actions.setAttribute({ target: "self", attribute_: "generic.max_health", value: 40 });
|
|
337
|
+
Actions.setAttribute({ target: "self", attribute_: "generic.movement_speed", value: 0.2 });
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Custom Commands
|
|
341
|
+
```typescript
|
|
342
|
+
Actions.custom(() => {
|
|
343
|
+
// Any Sandstone code here
|
|
344
|
+
execute.as("@a").run.effect.give("@s", "speed", 10, 1);
|
|
345
|
+
});
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Utilities
|
|
349
|
+
|
|
350
|
+
### `forEveryPlayer(callback)`
|
|
351
|
+
|
|
352
|
+
Execute code for each participant at their location:
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
import { forEveryPlayer } from "@kradle/challenges";
|
|
356
|
+
|
|
357
|
+
forEveryPlayer(() => {
|
|
358
|
+
// Runs as each player, at their position
|
|
359
|
+
execute.run.particle("minecraft:flame", rel(0, 1, 0));
|
|
360
|
+
});
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
## Example: Battle Royale
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import { createChallenge, Actions, forEveryPlayer } from "@kradle/challenges";
|
|
367
|
+
import { _, Selector } from "sandstone";
|
|
368
|
+
|
|
369
|
+
createChallenge({
|
|
370
|
+
name: "battle-royale",
|
|
371
|
+
kradle_challenge_path: "./output",
|
|
372
|
+
roles: ["fighter"] as const,
|
|
373
|
+
GAME_DURATION: 5 * 60 * 20,
|
|
374
|
+
custom_variables: {
|
|
375
|
+
kills: {
|
|
376
|
+
type: "individual",
|
|
377
|
+
objective_type: "playerKillCount",
|
|
378
|
+
default: 0,
|
|
379
|
+
},
|
|
380
|
+
sole_survivor: {
|
|
381
|
+
type: "individual",
|
|
382
|
+
updater: (value, { alive_players, has_never_died }) => {
|
|
383
|
+
value.set(0);
|
|
384
|
+
_.if(_.and(
|
|
385
|
+
alive_players.equalTo(1),
|
|
386
|
+
has_never_died.equalTo(1)
|
|
387
|
+
), () => {
|
|
388
|
+
value.set(1);
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
})
|
|
394
|
+
.events(() => ({
|
|
395
|
+
start_challenge: () => {
|
|
396
|
+
Actions.setTime({ time: "day" });
|
|
397
|
+
Actions.announce({ message: "Last player standing wins!" });
|
|
398
|
+
},
|
|
399
|
+
init_participants: () => {
|
|
400
|
+
Actions.give({ target: "all", item: "minecraft:stone_sword", count: 1 });
|
|
401
|
+
Actions.give({ target: "all", item: "minecraft:leather_chestplate", count: 1 });
|
|
402
|
+
},
|
|
403
|
+
}))
|
|
404
|
+
.custom_events(({ kills }) => [
|
|
405
|
+
{
|
|
406
|
+
score: kills,
|
|
407
|
+
target: 1,
|
|
408
|
+
mode: "fire_once",
|
|
409
|
+
actions: () => {
|
|
410
|
+
Actions.announce({ message: "First blood!" });
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
])
|
|
414
|
+
.end_condition(({ alive_players }) => alive_players.equalTo(1))
|
|
415
|
+
.win_conditions(({ sole_survivor }, { fighter }) => ({
|
|
416
|
+
[fighter]: sole_survivor.equalTo(1),
|
|
417
|
+
}));
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Example: Capture the Flag
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
import { createChallenge, Actions } from "@kradle/challenges";
|
|
424
|
+
import { _, Selector, rel } from "sandstone";
|
|
425
|
+
import type { Score } from "sandstone";
|
|
426
|
+
|
|
427
|
+
createChallenge({
|
|
428
|
+
name: "capture-the-flag",
|
|
429
|
+
kradle_challenge_path: "./output",
|
|
430
|
+
roles: ["red_team", "blue_team"] as const,
|
|
431
|
+
GAME_DURATION: 5 * 60 * 20,
|
|
432
|
+
custom_variables: {
|
|
433
|
+
holds_enemy_flag: {
|
|
434
|
+
type: "individual",
|
|
435
|
+
updater: (value: Score) => {
|
|
436
|
+
value.set(0);
|
|
437
|
+
// Check if player holds the enemy team's banner
|
|
438
|
+
_.if(Selector("@s", {
|
|
439
|
+
nbt: { Inventory: [{ id: "minecraft:red_banner" }] }
|
|
440
|
+
}), () => {
|
|
441
|
+
value.set(1);
|
|
442
|
+
});
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
at_home_base: {
|
|
446
|
+
type: "individual",
|
|
447
|
+
updater: (value: Score) => {
|
|
448
|
+
value.set(0);
|
|
449
|
+
_.if(_.block(rel(0, -1, 0), "minecraft:blue_wool"), () => {
|
|
450
|
+
value.set(1);
|
|
451
|
+
});
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
captured_flag: {
|
|
455
|
+
type: "individual",
|
|
456
|
+
updater: (value, { holds_enemy_flag, at_home_base }) => {
|
|
457
|
+
value.set(0);
|
|
458
|
+
_.if(_.and(
|
|
459
|
+
holds_enemy_flag.equalTo(1),
|
|
460
|
+
at_home_base.equalTo(1)
|
|
461
|
+
), () => {
|
|
462
|
+
value.set(1);
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
})
|
|
468
|
+
.events(() => ({
|
|
469
|
+
start_challenge: () => {
|
|
470
|
+
Actions.announce({ message: "Capture the enemy flag!" });
|
|
471
|
+
},
|
|
472
|
+
}))
|
|
473
|
+
.custom_events(({ captured_flag }) => [
|
|
474
|
+
{
|
|
475
|
+
score: captured_flag,
|
|
476
|
+
target: 1,
|
|
477
|
+
mode: "fire_once",
|
|
478
|
+
actions: () => {
|
|
479
|
+
Actions.announce({ message: "Flag captured!" });
|
|
480
|
+
},
|
|
481
|
+
},
|
|
482
|
+
])
|
|
483
|
+
.end_condition(({ captured_flag }) => captured_flag.equalTo(1))
|
|
484
|
+
.win_conditions(({ captured_flag }, { red_team, blue_team }) => ({
|
|
485
|
+
[red_team]: captured_flag.equalTo(1),
|
|
486
|
+
[blue_team]: captured_flag.equalTo(0),
|
|
487
|
+
}));
|
|
488
|
+
```
|
|
489
|
+
|
package/dist/actions.d.ts
CHANGED
|
@@ -149,11 +149,11 @@ export declare const Actions: {
|
|
|
149
149
|
}) => void;
|
|
150
150
|
/**
|
|
151
151
|
* Send a chat message to a target.
|
|
152
|
-
* @param {
|
|
152
|
+
* @param {JSONTextComponent} message - The message to send.
|
|
153
153
|
* @param {TargetNames} target - The target to send the message to.
|
|
154
154
|
*/
|
|
155
155
|
tellraw: ({ message, target }: {
|
|
156
|
-
message:
|
|
156
|
+
message: JSONTextComponent;
|
|
157
157
|
target: TargetNames;
|
|
158
158
|
}) => void;
|
|
159
159
|
/**
|
|
@@ -205,5 +205,26 @@ export declare const Actions: {
|
|
|
205
205
|
z: number;
|
|
206
206
|
absolute: boolean;
|
|
207
207
|
}) => void;
|
|
208
|
+
/**
|
|
209
|
+
* Count the number of a specific item in a target's inventory.
|
|
210
|
+
* @param params - The parameters object.
|
|
211
|
+
* @param params.target - The target to count items for.
|
|
212
|
+
* @param params.item - The item to count.
|
|
213
|
+
* @returns The variable containing the item count.
|
|
214
|
+
*/
|
|
215
|
+
countItems: ({ target, item }: {
|
|
216
|
+
target: TargetNames;
|
|
217
|
+
item: ITEMS;
|
|
218
|
+
}) => Score<string | undefined>;
|
|
219
|
+
/**
|
|
220
|
+
* Get the current player's position as x, y, z Score variables.
|
|
221
|
+
* Must be called in a player context (e.g., inside forEveryPlayer or when @s is a player).
|
|
222
|
+
* @returns An object with x, y, z Score variables containing the player's coordinates.
|
|
223
|
+
*/
|
|
224
|
+
getCurrentPlayerPosition: () => {
|
|
225
|
+
x: Score<string | undefined>;
|
|
226
|
+
y: Score<string | undefined>;
|
|
227
|
+
z: Score<string | undefined>;
|
|
228
|
+
};
|
|
208
229
|
};
|
|
209
230
|
//# sourceMappingURL=actions.d.ts.map
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAMN,KAAK,SAAS,EAGd,KAAK,iBAAiB,EAOtB,KAAK,KAAK,EAEV,aAAa,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AACA,OAAO,EAMN,KAAK,SAAS,EAGd,KAAK,iBAAiB,EAOtB,KAAK,KAAK,EAEV,aAAa,EASb,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAG7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGlD,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC,KAAK,GAAG,MAAM,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAkB1F;AAED,eAAO,MAAM,OAAO;IACnB;;;OAGG;4BACqB;QAAE,OAAO,EAAE,iBAAiB,CAAA;KAAE;IAItD;;;OAGG;wBACiB;QAAE,MAAM,EAAE,WAAW,CAAA;KAAE;IAI3C;;;;OAIG;uBACgB,MAAM,IAAI;IAI7B;;;;;;;;;;OAUG;+DAWA;QACF,KAAK,EAAE,MAAM,CAAC;QACd,EAA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SONTextComponent} message - The message to send.
|
|
225
225
|
* @param {TargetNames} target - The target to send the message to.
|
|
226
226
|
*/
|
|
227
227
|
tellraw: ({ message, target }) => {
|
|
@@ -272,5 +272,31 @@ exports.Actions = {
|
|
|
272
272
|
const abs = absolute ? "" : "~";
|
|
273
273
|
(0, sandstone_1.raw)(`summon item ${abs}${x} ${abs}${y} ${abs}${z} {Item:{id:"${item}",Count:1b}}`);
|
|
274
274
|
},
|
|
275
|
+
/**
|
|
276
|
+
* Count the number of a specific item in a target's inventory.
|
|
277
|
+
* @param params - The parameters object.
|
|
278
|
+
* @param params.target - The target to count items for.
|
|
279
|
+
* @param params.item - The item to count.
|
|
280
|
+
* @returns The variable containing the item count.
|
|
281
|
+
*/
|
|
282
|
+
countItems: ({ target, item }) => {
|
|
283
|
+
const variable = (0, sandstone_1.Variable)();
|
|
284
|
+
sandstone_1.execute.store.result.score(variable).run.clear(mapTarget(target), item, 0);
|
|
285
|
+
return variable;
|
|
286
|
+
},
|
|
287
|
+
/**
|
|
288
|
+
* Get the current player's position as x, y, z Score variables.
|
|
289
|
+
* Must be called in a player context (e.g., inside forEveryPlayer or when @s is a player).
|
|
290
|
+
* @returns An object with x, y, z Score variables containing the player's coordinates.
|
|
291
|
+
*/
|
|
292
|
+
getCurrentPlayerPosition: () => {
|
|
293
|
+
const x = (0, sandstone_1.Variable)();
|
|
294
|
+
const y = (0, sandstone_1.Variable)();
|
|
295
|
+
const z = (0, sandstone_1.Variable)();
|
|
296
|
+
sandstone_1.execute.store.result.score(x).run.data.get.entity("@s", "Pos[0]");
|
|
297
|
+
sandstone_1.execute.store.result.score(y).run.data.get.entity("@s", "Pos[1]");
|
|
298
|
+
sandstone_1.execute.store.result.score(z).run.data.get.entity("@s", "Pos[2]");
|
|
299
|
+
return { x, y, z };
|
|
300
|
+
},
|
|
275
301
|
};
|
|
276
302
|
//# sourceMappingURL=actions.js.map
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":";;;;;;AAqCA,8BAkBC;AAvDD,8DAAiC;AACjC,yCA2BmB;AAEnB,yCAAsC;AACtC,2CAA8E;AAM9E,SAAgB,SAAS,CAAC,MAA8B;IACvD,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,KAAK;YACT,OAAO,eAAG,CAAC;QACZ,KAAK,MAAM;YACV,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,YAAY,yBAAa,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC;IACf,CAAC;IAED,6CAA6C;IAC7C,IAAI,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,IAAA,oBAAQ,EAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,qCAAqC;AAC9E,CAAC;AAEY,QAAA,OAAO,GAAG;IACtB;;;OAGG;IACH,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAkC,EAAE,EAAE;QACzD,IAAA,mBAAO,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,uBAAW,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,KAAK,EAAE,CAAC,EAAE,MAAM,EAA2B,EAAE,EAAE;QAC9C,IAAA,iBAAK,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACH,MAAM,EAAE,CAAC,QAAoB,EAAE,EAAE;QAChC,QAAQ,EAAE,CAAC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AAC;QAClE,mBAAO,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAClE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IACpB,CAAC;CACiD,CAAC"}
|
package/dist/challenge.js
CHANGED
|
@@ -230,7 +230,7 @@ class ChallengeBase {
|
|
|
230
230
|
const advancementsAsScoreCustomEvents = inputCustomEvents
|
|
231
231
|
.filter(isAdvancementCustomEvent)
|
|
232
232
|
.map((event, index) => {
|
|
233
|
-
const trigger = (event.criteria?.[0].trigger ?? "").split("minecraft:").at(-1)
|
|
233
|
+
const trigger = (event.criteria?.[0].trigger ?? "").split("minecraft:").at(-1)?.replace(/[:/]/g, "_");
|
|
234
234
|
const name = `adv_${trigger}__${index}`;
|
|
235
235
|
const score = getOrCreateObjective(getUniqueObjectiveName(name), "dummy")("@s");
|
|
236
236
|
this.addVariable(name, {
|