@kradle/cli 0.2.3 → 0.2.4
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/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -261,7 +261,7 @@ current_y_position: {
|
|
|
261
261
|
type: "individual",
|
|
262
262
|
objective_type: "dummy",
|
|
263
263
|
updater: (value) => {
|
|
264
|
-
|
|
264
|
+
value.set(Actions.getCurrentPlayerPosition().y)
|
|
265
265
|
},
|
|
266
266
|
}
|
|
267
267
|
```
|
|
@@ -323,6 +323,8 @@ score.lowerOrEqualThan(number | Score);
|
|
|
323
323
|
|
|
324
324
|
### Lifecycle Events
|
|
325
325
|
|
|
326
|
+
All lifecycle events run globally (not per-player).
|
|
327
|
+
|
|
326
328
|
#### `start_challenge`
|
|
327
329
|
|
|
328
330
|
Runs once when the challenge starts. Use for global setup.
|
|
@@ -337,19 +339,19 @@ start_challenge: () => {
|
|
|
337
339
|
|
|
338
340
|
#### `init_participants`
|
|
339
341
|
|
|
340
|
-
Runs
|
|
342
|
+
Runs 1 second after start_challenge. Use for player setup. It still runs globally.
|
|
341
343
|
|
|
342
344
|
```typescript
|
|
343
345
|
init_participants: () => {
|
|
344
|
-
Actions.give({ target: "
|
|
345
|
-
Actions.setAttribute({ target: "
|
|
346
|
-
Actions.teleport({ target: "
|
|
346
|
+
Actions.give({ target: "all", item: "minecraft:diamond_sword", count: 1 });
|
|
347
|
+
Actions.setAttribute({ target: "all", attribute_: "generic.max_health", value: 40 });
|
|
348
|
+
Actions.teleport({ target: "all", x: 0, y: 100, z: 0, absolute: true });
|
|
347
349
|
}
|
|
348
350
|
```
|
|
349
351
|
|
|
350
352
|
#### `on_tick`
|
|
351
353
|
|
|
352
|
-
Runs every tick
|
|
354
|
+
Runs every tick. Use sparingly for performance.
|
|
353
355
|
|
|
354
356
|
```typescript
|
|
355
357
|
on_tick: () => {
|
|
@@ -402,7 +404,7 @@ Score events watch a variable and trigger when it reaches a specified target val
|
|
|
402
404
|
```typescript
|
|
403
405
|
{
|
|
404
406
|
score: variables.death_count,
|
|
405
|
-
mode: "fire_once", // Triggers once when death_count changes from
|
|
407
|
+
mode: "fire_once", // Triggers once when death_count changes away from initial value
|
|
406
408
|
actions: () => {
|
|
407
409
|
Actions.announce({ message: "First death!" });
|
|
408
410
|
},
|
|
@@ -417,6 +419,8 @@ Score events watch a variable and trigger when it reaches a specified target val
|
|
|
417
419
|
|
|
418
420
|
Advancement events trigger when a Minecraft advancement criterion is met. Internally, an advancement is created that grants when the criterion triggers, which then fires the event. The `criteria` array follows the [Minecraft Advancement JSON format](https://minecraft.fandom.com/wiki/Advancement/JSON_format).
|
|
419
421
|
|
|
422
|
+
Advancement-based events always fire per-player.
|
|
423
|
+
|
|
420
424
|
**Parameters:**
|
|
421
425
|
- `criteria` (required): Array of advancement trigger objects with optional conditions
|
|
422
426
|
- `mode` (required): `"fire_once"` or `"repeatable"`
|
|
@@ -476,6 +480,13 @@ See the [Minecraft Wiki](https://minecraft.fandom.com/wiki/Advancement/JSON_form
|
|
|
476
480
|
|
|
477
481
|
## Actions
|
|
478
482
|
|
|
483
|
+
Actions are higher-level functions that wrap common Minecraft operations. They provide:
|
|
484
|
+
- Automatic target mapping (`"all"`, `"self"`, team names → proper selectors)
|
|
485
|
+
- Integration with Kradle's interface (e.g., `Actions.announce` messages appear in Kradle)
|
|
486
|
+
- Consistent API for common operations
|
|
487
|
+
|
|
488
|
+
For advanced use cases not covered by Actions, you can fall back to Sandstone's lower-level functions directly (`give`, `tellraw`, `effect`, `kill`, `execute`, etc.). See [Sandstone Integration](#sandstone-integration).
|
|
489
|
+
|
|
479
490
|
All actions are called via the `Actions` object:
|
|
480
491
|
|
|
481
492
|
```typescript
|
|
@@ -497,28 +508,44 @@ Broadcast message to all players with KRADLE tag.
|
|
|
497
508
|
|
|
498
509
|
```typescript
|
|
499
510
|
Actions.announce({
|
|
500
|
-
message:
|
|
511
|
+
message: JSONTextComponent; // Message (string or formatted object)
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
// Simple string:
|
|
515
|
+
Actions.announce({ message: "Game starting!" });
|
|
516
|
+
|
|
517
|
+
// Formatted JSONTextComponent:
|
|
518
|
+
Actions.announce({
|
|
519
|
+
message: [
|
|
520
|
+
{ text: "Player ", color: "white" },
|
|
521
|
+
{ selector: "@s", color: "gold", bold: true },
|
|
522
|
+
{ text: " won the game!", color: "green" }
|
|
523
|
+
]
|
|
501
524
|
});
|
|
502
525
|
```
|
|
503
526
|
|
|
504
527
|
#### `Actions.tellraw(params)`
|
|
505
528
|
|
|
506
|
-
Send formatted message to specific target.
|
|
529
|
+
Send formatted message to specific target. **Note:** These messages are only visible to players in-game and will not appear in Kradle's interface. Use `Actions.announce` for messages that should be visible in Kradle.
|
|
507
530
|
|
|
508
531
|
```typescript
|
|
509
532
|
Actions.tellraw({
|
|
510
|
-
target: TargetNames;
|
|
511
|
-
message:
|
|
533
|
+
target: TargetNames; // "all", "self", or any selector
|
|
534
|
+
message: JSONTextComponent; // Message (string or formatted object)
|
|
512
535
|
});
|
|
513
536
|
|
|
514
|
-
//
|
|
537
|
+
// Examples:
|
|
515
538
|
Actions.tellraw({
|
|
516
539
|
target: "all",
|
|
517
540
|
message: ["Hello, ", { text: "world!", color: "gold", bold: true }]
|
|
518
541
|
});
|
|
519
542
|
Actions.tellraw({
|
|
520
543
|
target: "self",
|
|
521
|
-
message:
|
|
544
|
+
message: "You won!"
|
|
545
|
+
});
|
|
546
|
+
Actions.tellraw({
|
|
547
|
+
target: "self",
|
|
548
|
+
message: { text: "Critical hit!", color: "red", bold: true }
|
|
522
549
|
});
|
|
523
550
|
```
|
|
524
551
|
|
|
@@ -611,6 +638,39 @@ variables.my_diamond_count.set(count);
|
|
|
611
638
|
|
|
612
639
|
**Note:** This action creates a temporary variable internally using `Variable()` and uses `execute.store.result.score` with `clear` command (count 0) to count items without removing them from the inventory.
|
|
613
640
|
|
|
641
|
+
#### `Actions.getCurrentPlayerPosition()`
|
|
642
|
+
|
|
643
|
+
Get the current player's position as x, y, z Score variables. Must be called in a player context (e.g., inside `forEveryPlayer`, individual variables updaters, or when `@s` is a player). This is the prefered way of checking a player's position.
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
Actions.getCurrentPlayerPosition(): { x: Score; y: Score; z: Score }
|
|
647
|
+
|
|
648
|
+
// Example - Check if player is above Y=100:
|
|
649
|
+
const pos = Actions.getCurrentPlayerPosition();
|
|
650
|
+
_.if(pos.y.greaterThan(100), () => {
|
|
651
|
+
Actions.announce({ message: "You reached the sky!" });
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
// Example - Store position in custom variables:
|
|
655
|
+
const { x, y, z } = Actions.getCurrentPlayerPosition();
|
|
656
|
+
variables.player_x.set(x);
|
|
657
|
+
variables.player_y.set(y);
|
|
658
|
+
variables.player_z.set(z);
|
|
659
|
+
|
|
660
|
+
// Example - Check if player is in a specific area:
|
|
661
|
+
const pos = Actions.getCurrentPlayerPosition();
|
|
662
|
+
_.if(_.and(
|
|
663
|
+
pos.x.greaterThan(0),
|
|
664
|
+
pos.x.lowerThan(100),
|
|
665
|
+
pos.z.greaterThan(0),
|
|
666
|
+
pos.z.lowerThan(100)
|
|
667
|
+
), () => {
|
|
668
|
+
Actions.announce({ message: "You're in the zone!" });
|
|
669
|
+
});
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
**Note:** This returns integer coordinates (block position). The values are truncated from the player's exact floating-point position.
|
|
673
|
+
|
|
614
674
|
### Entities
|
|
615
675
|
|
|
616
676
|
#### `Actions.summonMultiple(params)`
|
|
@@ -1045,7 +1105,7 @@ createChallenge({
|
|
|
1045
1105
|
Actions.announce({ message: "First to kill 2 pigs wins!" });
|
|
1046
1106
|
},
|
|
1047
1107
|
init_participants: () => {
|
|
1048
|
-
Actions.give({ target: "
|
|
1108
|
+
Actions.give({ target: "all", item: "minecraft:iron_sword", count: 1 });
|
|
1049
1109
|
},
|
|
1050
1110
|
}))
|
|
1051
1111
|
.custom_events(({ pigs_farmed }) => [
|
|
@@ -1080,7 +1140,7 @@ createChallenge({
|
|
|
1080
1140
|
type: "individual",
|
|
1081
1141
|
objective_type: "dummy",
|
|
1082
1142
|
updater: (value) => {
|
|
1083
|
-
|
|
1143
|
+
value.set(Actions.getCurrentPlayerPosition().y)
|
|
1084
1144
|
},
|
|
1085
1145
|
},
|
|
1086
1146
|
max_height: {
|
|
@@ -1124,8 +1184,8 @@ createChallenge({
|
|
|
1124
1184
|
Actions.announce({ message: "Climb as high as you can!" });
|
|
1125
1185
|
},
|
|
1126
1186
|
init_participants: () => {
|
|
1127
|
-
Actions.give({ target: "
|
|
1128
|
-
Actions.give({ target: "
|
|
1187
|
+
Actions.give({ target: "all", item: "minecraft:cobblestone", count: 64 });
|
|
1188
|
+
Actions.give({ target: "all", item: "minecraft:cobblestone", count: 64 });
|
|
1129
1189
|
},
|
|
1130
1190
|
}))
|
|
1131
1191
|
.custom_events(() => [])
|
|
@@ -1176,9 +1236,9 @@ createChallenge({
|
|
|
1176
1236
|
Actions.announce({ message: "Last player standing wins!" });
|
|
1177
1237
|
},
|
|
1178
1238
|
init_participants: () => {
|
|
1179
|
-
Actions.give({ target: "
|
|
1180
|
-
Actions.give({ target: "
|
|
1181
|
-
Actions.give({ target: "
|
|
1239
|
+
Actions.give({ target: "all", item: "minecraft:stone_sword", count: 1 });
|
|
1240
|
+
Actions.give({ target: "all", item: "minecraft:leather_chestplate", count: 1 });
|
|
1241
|
+
Actions.give({ target: "all", item: "minecraft:cooked_beef", count: 10 });
|
|
1182
1242
|
},
|
|
1183
1243
|
}))
|
|
1184
1244
|
.custom_events(({ kills }) => [
|
|
@@ -1237,7 +1297,7 @@ createChallenge({
|
|
|
1237
1297
|
},
|
|
1238
1298
|
init_participants: () => {
|
|
1239
1299
|
// Different items based on role would be set via role-specific logic
|
|
1240
|
-
Actions.give({ target: "
|
|
1300
|
+
Actions.give({ target: "all", item: "minecraft:wooden_sword", count: 1 });
|
|
1241
1301
|
},
|
|
1242
1302
|
}))
|
|
1243
1303
|
.custom_events(() => [])
|
|
@@ -1301,7 +1361,7 @@ createChallenge({
|
|
|
1301
1361
|
Actions.announce({ message: "Capture the enemy flag and return to base!" });
|
|
1302
1362
|
},
|
|
1303
1363
|
init_participants: () => {
|
|
1304
|
-
Actions.give({ target: "
|
|
1364
|
+
Actions.give({ target: "all", item: "minecraft:iron_sword", count: 1 });
|
|
1305
1365
|
},
|
|
1306
1366
|
}))
|
|
1307
1367
|
.custom_events(({ captured_flag }) => [
|
|
@@ -1378,6 +1438,10 @@ current_y: {
|
|
|
1378
1438
|
type: "individual",
|
|
1379
1439
|
objective_type: "dummy",
|
|
1380
1440
|
updater: (value) => {
|
|
1441
|
+
// Prefered way: using the dedicated Action
|
|
1442
|
+
value.set(Actions.getCurrentPlayerPosition().y)
|
|
1443
|
+
|
|
1444
|
+
// Alternative way: using execute.store + data.get
|
|
1381
1445
|
execute.as("@s").store.result.score(value).run.data.get.entity("@s", "Pos[1]");
|
|
1382
1446
|
},
|
|
1383
1447
|
}
|