@kradle/challenges-sdk 0.18.0 → 0.19.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/CHANGELOG.md +24 -1
- package/LLM_README.md +22 -1
- package/README.md +21 -0
- package/dist/engine.d.ts +4 -4
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/chat.d.ts +7 -0
- package/dist/runtime/chat.d.ts.map +1 -0
- package/dist/runtime/chat.js +73 -0
- package/dist/runtime/chat.js.map +1 -0
- package/dist/runtime/reducer.d.ts.map +1 -1
- package/dist/runtime/reducer.js +61 -44
- package/dist/runtime/reducer.js.map +1 -1
- package/dist/runtime/types.d.ts +3 -3
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/types.js.map +1 -1
- package/dist/runtime/wire.d.ts +22 -1
- package/dist/runtime/wire.d.ts.map +1 -1
- package/dist/runtime/wire.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,27 @@ also hand-edit this file or the [Unreleased] section at any time.
|
|
|
17
17
|
|
|
18
18
|
## [Unreleased]
|
|
19
19
|
|
|
20
|
+
## [0.19.1] - 2026-10-08
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- A hook your challenge does not handle now costs nothing: the reducer keeps its state up to date and returns without building the event payload. A large block flush is the case that mattered: 357,166 changes went from 740 ms to 164 ms, under the time one event is allowed, so a challenge that reads no `on.blocksChanged` is no longer charged for the churn of a busy world. A block read after the flush gives the same block as before.
|
|
25
|
+
- A hook payload now reaches your handler as the reducer built it, with no copy in between. Every player in a payload (`player`, `attacker`, `killer`, `by`) is the same read-only view as `g.player(name)`, and every other field is still built for the call or copied out of the engine event, so nothing in a payload is shared with the engine. With an `on.blocksChanged` handler the same 357,166-change flush reduces in 290 ms, from 606 ms.
|
|
26
|
+
|
|
27
|
+
## [0.19.0] - 2026-10-01
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- `g.say(message)` and `g.tell(to, message)` take static rich text: a string, or a `ChatText` component with `text`, optional `extra` children, a named or six-digit hexadecimal `color`, and boolean `bold`, `italic`, `underlined` and `strikethrough` fields. An array joins components in order. Whitespace stays unchanged. Another field, an invalid color, a cycle, or nesting deeper than 64 levels fails the run (`bad_component`). A night in a werewolves game reads `g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }])`.
|
|
32
|
+
- Dynamic text stays in `g.tellraw(to, component)`, which keeps the broader Minecraft component API and its plain-text conversion for agents.
|
|
33
|
+
- New exported types: `ChatText` and `ChatColor`, from `@kradle/challenges-sdk` and from `@kradle/challenges-sdk/engine`.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- With a server that supports structured announcements, a human sees the formatted line without a Kradle prefix, an agent reads the same words as a system message, and a targeted message reaches its recipient alone — spectators get no copy. A label you write yourself, such as `[PRIVATE]`, stays part of your text. An older server uses the plain text and the chat route it used before, so no challenge code needs a change.
|
|
38
|
+
- `on.effectFailed` preserves the original effect kind with structured announcements. On an older engine a `tellraw` to an agent becomes an announcement, so its failure still names the kind `announce`.
|
|
39
|
+
- `README.md` and `LLM_README.md` describe static rich text in `say` and `tell`, with the `README.md` paragraph beside the author example.
|
|
40
|
+
|
|
20
41
|
## [0.18.0] - 2026-09-30
|
|
21
42
|
|
|
22
43
|
### Added
|
|
@@ -280,7 +301,9 @@ also hand-edit this file or the [Unreleased] section at any time.
|
|
|
280
301
|
- Voting primitives (`votedFor`, `promptVote`, `allVotesIn`, `assignDefaultVotes`) for challenges that use discuss-then-vote-then-act phases as an alternative to pad-based voting.
|
|
281
302
|
- Build-time validation of vote IDs and options against `KRADLE_CHALLENGE_VOTING_OPTIONS` (when set), matching the existing `getLocation`/`setEndState` pattern. `promptVote` also validates each announced option against the declared `votingOptions`.
|
|
282
303
|
|
|
283
|
-
[Unreleased]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.
|
|
304
|
+
[Unreleased]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.19.1...HEAD
|
|
305
|
+
[0.19.1]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.19.0...v0.19.1
|
|
306
|
+
[0.19.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.18.0...v0.19.0
|
|
284
307
|
[0.18.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.17.0...v0.18.0
|
|
285
308
|
[0.17.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.16.0...v0.17.0
|
|
286
309
|
[0.16.0]: https://github.com/Kradle-ai/challenges-sdk/compare/v0.15.0...v0.16.0
|
package/LLM_README.md
CHANGED
|
@@ -185,7 +185,28 @@ The steps register behavior and return the same challenge object. Use one chain
|
|
|
185
185
|
|
|
186
186
|
**Messages and metrics.** `g.say(message)`, `g.tell(to, message)`, `g.tellraw(to, component)` (a JSON text component as `/tellraw` takes it: `"text"`, `{ text, color, bold, extra }` or an array; a human sees the formatting, an agent reads the plain text as a system message), `g.title(to, { title, subtitle?, fadeIn?, stay?, fadeOut? })`, `g.log(message, { player?, data? })`, `g.setMetric(name, value, { player? })` (the last value per name reaches the run result), `g.achievement(player, id)` (an id is lowercase letters, digits, `_` and `-`; recorded once per player, listed on `game_over` and readable as `p.achievements`).
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
`g.say(message)` and `g.tell(to, message)` accept a string or static `ChatText`.
|
|
189
|
+
A component has `text`, optional `extra` children, a named or hexadecimal `color`,
|
|
190
|
+
and boolean `bold`, `italic`, `underlined`, or `strikethrough` fields. Arrays join
|
|
191
|
+
components in order. Whitespace stays unchanged. Other fields, invalid colors,
|
|
192
|
+
cycles, and nesting deeper than 64 levels produce `bad_component`.
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
// no-compile
|
|
196
|
+
g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }]);
|
|
197
|
+
g.tell(player, { text: "[PRIVATE] Your role is CUPID.", color: "light_purple" });
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
With a server that supports structured announcements, humans see the formatted
|
|
201
|
+
text without a Kradle prefix. Agents get the same words through the internal
|
|
202
|
+
message route. A targeted message reaches only its recipient; spectators do not
|
|
203
|
+
get a copy. Existing labels such as `[PRIVATE]` remain part of the author's text.
|
|
204
|
+
Older servers use the plain-text message and the existing prefixed chat route.
|
|
205
|
+
`g.tellraw(to, component)` retains its broader Minecraft component API and its
|
|
206
|
+
existing plain-text conversion for agents. Dynamic text belongs in `tellraw`,
|
|
207
|
+
not in `say` or `tell`.
|
|
208
|
+
|
|
209
|
+
**The chat gate.** `g.mute(to, { message? })`: the players' public chat lines reach nobody else, and their whispers are refused. `g.deafen(to, { message? })`: the players hear no chat line from anyone. `g.unmute(to, { message? })` and `g.undeafen(to, { message? })` undo them. System messages (`g.say`, `g.tell`, `g.tellraw`, titles) pass both gates, and `on.chat` still fires for every line. Each call sends the player a notice: the engine's default when `message` is absent, your own text, or none for `""` or `null`. `to` is one player, several, or `"all"` (every participant; the engine refuses the change for a player who is not in the world, so a late joiner needs the call again). The gate is not readable from the context: keep it in your state when the rules need it. With structured announcements, `on.effectFailed` preserves the original effect kind. On a legacy engine, a `tellraw` to an agent becomes an announcement, so its failure names the kind `announce`. A werewolves night is `g.mute(villagers); g.deafen(villagers)`: the wolves talk in public and only the wolves hear it.
|
|
189
210
|
|
|
190
211
|
**Scores and roster.** `g.setScore(player, n)`, `g.addScore(player, delta)` (refused when `outcome.scores` exists), `g.eliminate(player)`, `g.random.int(lo, hi)`, `g.random.pick(items)`, `g.random.shuffle(items)`, `g.random.weighted(items)`.
|
|
191
212
|
|
package/README.md
CHANGED
|
@@ -93,6 +93,27 @@ const challenge = defineChallenge(config, {
|
|
|
93
93
|
export default challenge;
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
`g.say(message)` and `g.tell(to, message)` accept a string or static `ChatText`.
|
|
97
|
+
A component has `text`, optional `extra` children, a named or hexadecimal `color`,
|
|
98
|
+
and boolean `bold`, `italic`, `underlined`, or `strikethrough` fields. Arrays join
|
|
99
|
+
components in order. Whitespace stays unchanged. Other fields, invalid colors,
|
|
100
|
+
cycles, and nesting deeper than 64 levels produce `bad_component`.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
// no-compile
|
|
104
|
+
g.say([{ text: "Night falls. ", color: "gray" }, { text: "Close your eyes.", bold: true }]);
|
|
105
|
+
g.tell(player, { text: "[PRIVATE] Your role is CUPID.", color: "light_purple" });
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
With a server that supports structured announcements, humans see the formatted
|
|
109
|
+
text without a Kradle prefix. Agents get the same words through the internal
|
|
110
|
+
message route. A targeted message reaches only its recipient; spectators do not
|
|
111
|
+
get a copy. Existing labels such as `[PRIVATE]` remain part of the author's text.
|
|
112
|
+
Older servers use the plain-text message and the existing prefixed chat route.
|
|
113
|
+
`g.tellraw(to, component)` retains its broader Minecraft component API and its
|
|
114
|
+
existing plain-text conversion for agents. Dynamic text belongs in `tellraw`,
|
|
115
|
+
not in `say` or `tell`.
|
|
116
|
+
|
|
96
117
|
Kradle pays each participant its final `score` as points, so `outcome.scores`
|
|
97
118
|
(or `g.setScore` / `g.addScore`) is what a game is worth. `g.achievement(player, id)`
|
|
98
119
|
records an achievement once per player (`p.achievements`); Kradle records
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { AnyChallenge } from "./runtime/builder.js";
|
|
2
|
-
export { ChallengeError, type ErrorCategory
|
|
3
|
-
export { MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, type State,
|
|
2
|
+
export { ChallengeError, categoryOf, type ErrorCategory } from "./runtime/errors.js";
|
|
3
|
+
export { assertJson, MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, parseBlockState, type State, splitBatches, } from "./runtime/reducer.js";
|
|
4
4
|
export { type Duration, type Ticks, toTicks } from "./runtime/time.js";
|
|
5
|
-
export type { Action, BlockId, Box, Capability, ContainerItem, Effect, EffectId, EndReason, EngineChallenge, EntityTypeId, Event, GameMode, ItemId, ItemMeta, ItemStack, Json, ManifestVote, Participant, PlayerSample, RuntimeManifest, SdkEndState, SlotChange, Status,
|
|
5
|
+
export type { Action, BlockId, Box, Capability, ChatColor, ChatText, ContainerItem, Effect, EffectId, EndReason, EngineChallenge, EntityTypeId, Event, GameMode, GateEffect, ItemId, ItemMeta, ItemStack, Json, ManifestVote, Participant, PlayerSample, RuntimeManifest, SdkEndState, SlotChange, Status, TextComponent, TitleTimes, Vec3, } from "./runtime/wire.js";
|
|
6
6
|
export { ALL_CAPABILITIES, MINECRAFT_TARGET } from "./runtime/wire.js";
|
|
7
|
-
export type { ChunkMessage, Entity, EntityMove, Equipment, EquipmentChange, EquipmentSlot, Equipped, WorldState } from "./runtime/world.js";
|
|
7
|
+
export type { ChunkMessage, Entity, EntityMove, Equipment, EquipmentChange, EquipmentSlot, Equipped, WorldState, } from "./runtime/world.js";
|
|
8
8
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EACN,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,KAAK,KAAK,EACV,YAAY,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,MAAM,EACN,OAAO,EACP,GAAG,EACH,UAAU,EACV,SAAS,EACT,QAAQ,EACR,aAAa,EACb,MAAM,EACN,QAAQ,EACR,SAAS,EACT,eAAe,EACf,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,EACf,WAAW,EACX,UAAU,EACV,MAAM,EACN,aAAa,EACb,UAAU,EACV,IAAI,GACJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,YAAY,EACX,YAAY,EACZ,MAAM,EACN,UAAU,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,GACV,MAAM,oBAAoB,CAAC"}
|
package/dist/engine.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MINECRAFT_TARGET = exports.ALL_CAPABILITIES = exports.toTicks = exports.splitBatches = exports.parseBlockState = exports.
|
|
3
|
+
exports.MINECRAFT_TARGET = exports.ALL_CAPABILITIES = exports.toTicks = exports.splitBatches = exports.parseBlockState = exports.MAX_FILL_VOLUME = exports.MAX_BATCH_EFFECTS = exports.assertJson = exports.categoryOf = exports.ChallengeError = void 0;
|
|
4
4
|
var errors_js_1 = require("./runtime/errors.js");
|
|
5
5
|
Object.defineProperty(exports, "ChallengeError", { enumerable: true, get: function () { return errors_js_1.ChallengeError; } });
|
|
6
6
|
Object.defineProperty(exports, "categoryOf", { enumerable: true, get: function () { return errors_js_1.categoryOf; } });
|
|
7
7
|
var reducer_js_1 = require("./runtime/reducer.js");
|
|
8
|
+
Object.defineProperty(exports, "assertJson", { enumerable: true, get: function () { return reducer_js_1.assertJson; } });
|
|
8
9
|
Object.defineProperty(exports, "MAX_BATCH_EFFECTS", { enumerable: true, get: function () { return reducer_js_1.MAX_BATCH_EFFECTS; } });
|
|
9
10
|
Object.defineProperty(exports, "MAX_FILL_VOLUME", { enumerable: true, get: function () { return reducer_js_1.MAX_FILL_VOLUME; } });
|
|
10
|
-
Object.defineProperty(exports, "assertJson", { enumerable: true, get: function () { return reducer_js_1.assertJson; } });
|
|
11
11
|
Object.defineProperty(exports, "parseBlockState", { enumerable: true, get: function () { return reducer_js_1.parseBlockState; } });
|
|
12
12
|
Object.defineProperty(exports, "splitBatches", { enumerable: true, get: function () { return reducer_js_1.splitBatches; } });
|
|
13
13
|
var time_js_1 = require("./runtime/time.js");
|
package/dist/engine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":";;;AAGA,iDAAqF;AAA5E,2GAAA,cAAc,OAAA;
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":";;;AAGA,iDAAqF;AAA5E,2GAAA,cAAc,OAAA;AAAE,uGAAA,UAAU,OAAA;AACnC,mDAO8B;AAN7B,wGAAA,UAAU,OAAA;AACV,+GAAA,iBAAiB,OAAA;AACjB,6GAAA,eAAe,OAAA;AACf,6GAAA,eAAe,OAAA;AAEf,0GAAA,YAAY,OAAA;AAEb,6CAAuE;AAAnC,kGAAA,OAAO,OAAA;AAgC3C,6CAAuE;AAA9D,2GAAA,gBAAgB,OAAA;AAAE,2GAAA,gBAAgB,OAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export { ChallengeError, type ErrorCategory } from "./runtime/errors.js";
|
|
|
3
3
|
export { MAX_BATCH_EFFECTS, MAX_FILL_VOLUME, MAX_TRANSITIONS_PER_EVENT } from "./runtime/reducer.js";
|
|
4
4
|
export { winBy } from "./runtime/rules.js";
|
|
5
5
|
export { addDuration, asMinutes, asSeconds, type Duration, minutes, seconds, subtractDuration, TICKS_PER_SECOND, type Ticks, ticks, toTicks, } from "./runtime/time.js";
|
|
6
|
-
export type { BlockMatch, BlockPos, BlockSpec, BlockState, ChallengeApi, ChallengeConfig, Ctx, CtxOf, Decl, DeepReadonly, EndStateOf, GameRuleId, Handlers, Init, ItemMatch, ItemRequest, LocationOf, NotifyCtx, NotifyCtxOf, ObservedPlayer, OptionFor, Outcome, ParamSpec, ParamsOf, PhaseSpec, PhaseStep, Player, PlayerIn, PlayerOf, Random, ReadCtx, ReadCtxOf, ReadPlayer, ReadPlayerOf, Result, RoleOf, Roster, SetupCtx, SetupCtxOf, StateDecl, TitleOptions, To,
|
|
6
|
+
export type { BlockMatch, BlockPos, BlockSpec, BlockState, ChallengeApi, ChallengeConfig, Ctx, CtxOf, Decl, DeepReadonly, EndStateOf, GameRuleId, GateOptions, Handlers, Init, ItemMatch, ItemRequest, LocationOf, NotifyCtx, NotifyCtxOf, ObservedPlayer, OptionFor, Outcome, ParamSpec, ParamsOf, PhaseSpec, PhaseStep, Player, PlayerIn, PlayerOf, Random, ReadCtx, ReadCtxOf, ReadPlayer, ReadPlayerOf, Result, RoleOf, Roster, SetupCtx, SetupCtxOf, StateDecl, TitleOptions, To, VoteIdOf, VoteRule, World, } from "./runtime/types.js";
|
|
7
7
|
export { PLAYER_VOTE, WORLD_DEFAULTS } from "./runtime/types.js";
|
|
8
|
+
export type { BlockId, Box, ChatColor, ChatText, EffectId, EndReason, EntityTypeId, GameMode, ItemId, ItemMeta, ItemStack, Json, SdkEndState, Status, TextComponent, Vec3, } from "./runtime/wire.js";
|
|
8
9
|
export { MINECRAFT_TARGET } from "./runtime/wire.js";
|
|
9
|
-
export type { BlockId, Box, EffectId, TextComponent, EndReason, EntityTypeId, GameMode, ItemId, ItemMeta, ItemStack, Json, SdkEndState, Status, Vec3, } from "./runtime/wire.js";
|
|
10
10
|
export { blockIdOf, bounds, type Entity, type EntityFilter, type Equipment, inBox } from "./runtime/world.js";
|
|
11
11
|
import type { BlockPos } from "./runtime/types.js";
|
|
12
12
|
import type { Vec3 } from "./runtime/wire.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,KAAK,QAAQ,EACb,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,EACL,OAAO,GACP,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,GAAG,EACH,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,YAAY,EACZ,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,EAAE,EACF,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EACN,WAAW,EACX,SAAS,EACT,SAAS,EACT,KAAK,QAAQ,EACb,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,KAAK,KAAK,EACV,KAAK,EACL,OAAO,GACP,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,eAAe,EACf,GAAG,EACH,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,OAAO,EACP,SAAS,EACT,UAAU,EACV,YAAY,EACZ,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,KAAK,GACL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACjE,YAAY,EACX,OAAO,EACP,GAAG,EACH,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,WAAW,EACX,MAAM,EACN,aAAa,EACb,IAAI,GACJ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE9G,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,8EAA8E;AAC9E,eAAO,MAAM,UAAU,GAAI,GAAG,IAAI,KAAG,QAA4E,CAAC;AAClH,iGAAiG;AACjG,eAAO,MAAM,KAAK,GAAI,IAAI,IAAI,KAAG,QAAmF,CAAC;AACrH,wCAAwC;AACxC,eAAO,MAAM,KAAK,GAAI,IAAI,IAAI,KAAG,QAAmF,CAAC;AACrH,sCAAsC;AACtC,eAAO,MAAM,MAAM,GAAI,IAAI,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAG,IAIlD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,10 @@ exports.below = below;
|
|
|
42
42
|
const above = (at) => ({ x: Math.floor(at.x), y: Math.floor(at.y) + 1, z: Math.floor(at.z) });
|
|
43
43
|
exports.above = above;
|
|
44
44
|
/** `at` moved by `d` on each axis. */
|
|
45
|
-
const offset = (at, d) => ({
|
|
45
|
+
const offset = (at, d) => ({
|
|
46
|
+
x: at.x + (d.x ?? 0),
|
|
47
|
+
y: at.y + (d.y ?? 0),
|
|
48
|
+
z: at.z + (d.z ?? 0),
|
|
49
|
+
});
|
|
46
50
|
exports.offset = offset;
|
|
47
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8CAA8C;AAC9C,mDAA0F;AAA9C,6GAAA,eAAe,OAAA;AAC3D,iDAAyE;AAAhE,2GAAA,cAAc,OAAA;AACvB,mDAAqG;AAA5F,+GAAA,iBAAiB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,uHAAA,yBAAyB,OAAA;AACtE,+CAA2C;AAAlC,iGAAA,KAAK,OAAA;AACd,6CAY2B;AAX1B,sGAAA,WAAW,OAAA;AACX,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AAET,kGAAA,OAAO,OAAA;AACP,kGAAA,OAAO,OAAA;AACP,2GAAA,gBAAgB,OAAA;AAChB,2GAAA,gBAAgB,OAAA;AAEhB,gGAAA,KAAK,OAAA;AACL,kGAAA,OAAO,OAAA;AAkDR,+CAAiE;AAAxD,uGAAA,WAAW,OAAA;AAAE,0GAAA,cAAc,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8CAA8C;AAC9C,mDAA0F;AAA9C,6GAAA,eAAe,OAAA;AAC3D,iDAAyE;AAAhE,2GAAA,cAAc,OAAA;AACvB,mDAAqG;AAA5F,+GAAA,iBAAiB,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,uHAAA,yBAAyB,OAAA;AACtE,+CAA2C;AAAlC,iGAAA,KAAK,OAAA;AACd,6CAY2B;AAX1B,sGAAA,WAAW,OAAA;AACX,oGAAA,SAAS,OAAA;AACT,oGAAA,SAAS,OAAA;AAET,kGAAA,OAAO,OAAA;AACP,kGAAA,OAAO,OAAA;AACP,2GAAA,gBAAgB,OAAA;AAChB,2GAAA,gBAAgB,OAAA;AAE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AACrH,sCAAsC;AAC/B,MAAM,MAAM,GAAG,CAAC,EAAQ,EAAE,CAAgB,EAAQ,EAAE,CAAC,CAAC;IAC5D,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;CACpB,CAAC,CAAC;AAJU,QAAA,MAAM,UAIhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../../src/runtime/chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAsB1C,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,CAAA;CAAE,CAwClF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chatText = chatText;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const colors = new Set([
|
|
6
|
+
"black",
|
|
7
|
+
"dark_blue",
|
|
8
|
+
"dark_green",
|
|
9
|
+
"dark_aqua",
|
|
10
|
+
"dark_red",
|
|
11
|
+
"dark_purple",
|
|
12
|
+
"gold",
|
|
13
|
+
"gray",
|
|
14
|
+
"dark_gray",
|
|
15
|
+
"blue",
|
|
16
|
+
"green",
|
|
17
|
+
"aqua",
|
|
18
|
+
"red",
|
|
19
|
+
"light_purple",
|
|
20
|
+
"yellow",
|
|
21
|
+
"white",
|
|
22
|
+
]);
|
|
23
|
+
const styles = new Set(["bold", "italic", "underlined", "strikethrough"]);
|
|
24
|
+
/** Validate, copy, and flatten static text before it enters an effect. */
|
|
25
|
+
function chatText(value) {
|
|
26
|
+
const ancestors = new Set();
|
|
27
|
+
let message = "";
|
|
28
|
+
function copy(v, depth) {
|
|
29
|
+
const bad = () => (0, errors_js_1.apiError)("bad_component", "say/tell: expected static chat text");
|
|
30
|
+
if (typeof v === "string") {
|
|
31
|
+
message += v;
|
|
32
|
+
return v;
|
|
33
|
+
}
|
|
34
|
+
if (!v || typeof v !== "object" || ancestors.has(v) || depth > 64)
|
|
35
|
+
throw bad();
|
|
36
|
+
ancestors.add(v);
|
|
37
|
+
try {
|
|
38
|
+
if (Array.isArray(v))
|
|
39
|
+
return v.length === 0 ? "" : Array.from(v, (child) => copy(child, depth + 1));
|
|
40
|
+
const obj = v;
|
|
41
|
+
if (typeof obj.text !== "string")
|
|
42
|
+
throw bad();
|
|
43
|
+
const result = { text: obj.text };
|
|
44
|
+
for (const key of Object.keys(obj)) {
|
|
45
|
+
if (key === "text" || key === "extra")
|
|
46
|
+
continue;
|
|
47
|
+
if (obj[key] === undefined && (styles.has(key) || key === "color"))
|
|
48
|
+
continue;
|
|
49
|
+
if (styles.has(key) && typeof obj[key] === "boolean")
|
|
50
|
+
result[key] = obj[key];
|
|
51
|
+
else if (key === "color" &&
|
|
52
|
+
typeof obj[key] === "string" &&
|
|
53
|
+
(colors.has(obj[key]) || /^#[0-9a-fA-F]{6}$/.test(obj[key])))
|
|
54
|
+
result[key] = obj[key];
|
|
55
|
+
else
|
|
56
|
+
throw bad();
|
|
57
|
+
}
|
|
58
|
+
message += obj.text;
|
|
59
|
+
if (obj.extra !== undefined) {
|
|
60
|
+
if (!Array.isArray(obj.extra))
|
|
61
|
+
throw bad();
|
|
62
|
+
result.extra = obj.extra.map((child) => copy(child, depth + 1));
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
ancestors.delete(v);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const component = copy(value, 0);
|
|
71
|
+
return typeof value === "string" ? { message } : { message, component };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/runtime/chat.ts"],"names":[],"mappings":";;AAwBA,4BAwCC;AAhED,2CAAuC;AAGvC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACtB,OAAO;IACP,WAAW;IACX,YAAY;IACZ,WAAW;IACX,UAAU;IACV,aAAa;IACb,MAAM;IACN,MAAM;IACN,WAAW;IACX,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,cAAc;IACd,QAAQ;IACR,OAAO;CACP,CAAC,CAAC;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AAE1E,0EAA0E;AAC1E,SAAgB,QAAQ,CAAC,KAAc;IACtC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,SAAS,IAAI,CAAC,CAAU,EAAE,KAAa;QACtC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,IAAA,oBAAQ,EAAC,eAAe,EAAE,qCAAqC,CAAC,CAAC;QACnF,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,CAAC;YACb,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,EAAE;YAAE,MAAM,GAAG,EAAE,CAAC;QAC/E,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,CAAC;YACJ,IAAI,KAAK,CAAC,OAAO,CA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C,IAAI,CAAC;YACpB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,MAAM,GAAG,EAAE,CAAC;gBAC3C,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC;YACD,OAAO,MAAkB,CAAC;QAC3B,CAAC;gBAAS,CAAC;YACV,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/runtime/reducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/runtime/reducer.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAW,MAAM,WAAW,CAAC;AAC/D,OAAO,KAAK,EAEX,SAAS,EACT,UAAU,EACV,eAAe,EAGf,QAAQ,EAIR,OAAO,EACP,SAAS,EAGT,SAAS,EAET,KAAK,EACL,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACX,MAAM,EACN,OAAO,EACP,GAAG,EACH,UAAU,EAGV,MAAM,EACN,SAAS,EACT,KAAK,EACL,MAAM,EACN,SAAS,EACT,IAAI,EAEJ,eAAe,EAEf,MAAM,EAEN,IAAI,E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oGAAoG;AACpG,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAgC7D;AAeD,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAS1D;AAED,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAKxD;AAsDD,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAmB1D;AAmKD,wBAAgB,aAAa,CAAC,GAAG,EAAE,UAAU,GAAG;IAC/C,IAAI,EAAE,MAAM,KAAK,CAAC;IAClB,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;CAC5E,CA8nDA"}
|
package/dist/runtime/reducer.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.parseBlockState = parseBlockState;
|
|
|
22
22
|
exports.blockSpecString = blockSpecString;
|
|
23
23
|
exports.splitBatches = splitBatches;
|
|
24
24
|
exports.createReducer = createReducer;
|
|
25
|
+
const chat_js_1 = require("./chat.js");
|
|
25
26
|
const errors_js_1 = require("./errors.js");
|
|
26
27
|
const time_js_1 = require("./time.js");
|
|
27
28
|
const types_js_1 = require("./types.js");
|
|
@@ -312,19 +313,13 @@ function snapshot(value, seen = new WeakMap()) {
|
|
|
312
313
|
out[k] = snapshot(v, seen);
|
|
313
314
|
return out;
|
|
314
315
|
}
|
|
315
|
-
/**
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
if (Array.isArray(value))
|
|
323
|
-
return value.map((x) => viewPayload(r, x));
|
|
324
|
-
const out = {};
|
|
325
|
-
for (const [k, v] of Object.entries(value))
|
|
326
|
-
out[k] = viewPayload(r, v);
|
|
327
|
-
return out;
|
|
316
|
+
/**
|
|
317
|
+
* A player in a hook payload: the handler view, or `undefined` for none. Every other payload field is
|
|
318
|
+
* built fresh for the fire, copied out of the event (the harness logs and replays the event object),
|
|
319
|
+
* or frozen (an entity), so the payload goes to the handler as it is: no walk.
|
|
320
|
+
*/
|
|
321
|
+
function viewOf(r, p) {
|
|
322
|
+
return p === undefined ? undefined : playerView(r, p, true);
|
|
328
323
|
}
|
|
329
324
|
function createReducer(def) {
|
|
330
325
|
const config = def.config;
|
|
@@ -630,12 +625,13 @@ function createReducer(def) {
|
|
|
630
625
|
// ---- notifications
|
|
631
626
|
say(message) {
|
|
632
627
|
notify("say");
|
|
633
|
-
push({ kind: "announce", message });
|
|
628
|
+
push({ kind: "announce", ...(0, chat_js_1.chatText)(message) });
|
|
634
629
|
},
|
|
635
630
|
tell(to, message) {
|
|
636
631
|
notify("tell");
|
|
632
|
+
const text = (0, chat_js_1.chatText)(message);
|
|
637
633
|
for (const name of targets(to))
|
|
638
|
-
push({ kind: "announce",
|
|
634
|
+
push({ kind: "announce", ...text, to: name });
|
|
639
635
|
},
|
|
640
636
|
tellraw(to, component) {
|
|
641
637
|
notify("tellraw");
|
|
@@ -724,7 +720,15 @@ function createReducer(def) {
|
|
|
724
720
|
write("give");
|
|
725
721
|
const id = typeof item === "string" ? item : item.id;
|
|
726
722
|
const n = count ?? (typeof item === "string" ? 1 : (item.count ?? 1));
|
|
727
|
-
const meta = typeof item === "string"
|
|
723
|
+
const meta = typeof item === "string"
|
|
724
|
+
? {}
|
|
725
|
+
: {
|
|
726
|
+
name: item.name,
|
|
727
|
+
lore: item.lore,
|
|
728
|
+
enchantments: item.enchantments,
|
|
729
|
+
damage: item.damage,
|
|
730
|
+
components: item.components,
|
|
731
|
+
};
|
|
728
732
|
push(compact({ kind: "give", player: p.name, item: id, count: n, ...meta }));
|
|
729
733
|
},
|
|
730
734
|
clear(p, item, count) {
|
|
@@ -922,14 +926,27 @@ function createReducer(def) {
|
|
|
922
926
|
return g;
|
|
923
927
|
}
|
|
924
928
|
// ------------------------------------------------------------ dispatch
|
|
925
|
-
/**
|
|
929
|
+
/** Whether a global `.on()` set or the current phase handles `key`. */
|
|
930
|
+
function hasHandler(s, key) {
|
|
931
|
+
for (const set of def.on)
|
|
932
|
+
if (set[key])
|
|
933
|
+
return true;
|
|
934
|
+
return Boolean(phaseSpec(s)?.on?.[key]);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* One event to the ordered global group, then, in the same entry, to the phase's handler.
|
|
938
|
+
* Without a handler nothing runs and the payload is not built: a function payload is called only
|
|
939
|
+
* then (a block flush can carry hundreds of thousands of changes).
|
|
940
|
+
*/
|
|
926
941
|
function fire(r, key, payload) {
|
|
927
942
|
const s = r.s;
|
|
928
943
|
if (r.req.end || s.status !== "PLAYING")
|
|
929
944
|
return;
|
|
945
|
+
if (!hasHandler(s, key))
|
|
946
|
+
return;
|
|
930
947
|
const entry = s.phaseEntries;
|
|
931
948
|
const g = ctxOf(r, "full");
|
|
932
|
-
const e =
|
|
949
|
+
const e = typeof payload === "function" ? payload() : payload;
|
|
933
950
|
for (const set of def.on) {
|
|
934
951
|
if (r.req.end)
|
|
935
952
|
break;
|
|
@@ -1454,11 +1471,11 @@ function createReducer(def) {
|
|
|
1454
1471
|
for (const { m, before, after } of edges) {
|
|
1455
1472
|
for (const zone of after)
|
|
1456
1473
|
if (!before.includes(zone))
|
|
1457
|
-
fire(r, "zoneEntered", { player: m.p, zone });
|
|
1474
|
+
fire(r, "zoneEntered", { player: viewOf(r, m.p), zone });
|
|
1458
1475
|
for (const zone of before)
|
|
1459
1476
|
if (!after.includes(zone))
|
|
1460
|
-
fire(r, "zoneLeft", { player: m.p, zone });
|
|
1461
|
-
fire(r, "move", { player: m.p, from: m.from, to: { ...m.to } });
|
|
1477
|
+
fire(r, "zoneLeft", { player: viewOf(r, m.p), zone });
|
|
1478
|
+
fire(r, "move", { player: viewOf(r, m.p), from: m.from, to: { ...m.to } });
|
|
1462
1479
|
}
|
|
1463
1480
|
}
|
|
1464
1481
|
function sampleOther(s, d) {
|
|
@@ -1513,7 +1530,7 @@ function createReducer(def) {
|
|
|
1513
1530
|
if (changes.length === 0)
|
|
1514
1531
|
return;
|
|
1515
1532
|
const by = e.by === undefined ? undefined : s.players[e.by];
|
|
1516
|
-
fire(r, "container", { at: { ...e.at }, block: e.block, items: after, changes, by, removed: false });
|
|
1533
|
+
fire(r, "container", { at: { ...e.at }, block: e.block, items: after, changes, by: viewOf(r, by), removed: false });
|
|
1517
1534
|
}
|
|
1518
1535
|
/** Applies one event and dispatches its handlers. */
|
|
1519
1536
|
function step(r, e) {
|
|
@@ -1586,7 +1603,7 @@ function createReducer(def) {
|
|
|
1586
1603
|
if (e.gamemode !== undefined)
|
|
1587
1604
|
p.gamemode = e.gamemode;
|
|
1588
1605
|
if (playing())
|
|
1589
|
-
fire(r, "joined", { player: p });
|
|
1606
|
+
fire(r, "joined", { player: viewOf(r, p) });
|
|
1590
1607
|
break;
|
|
1591
1608
|
}
|
|
1592
1609
|
case "gamemode": {
|
|
@@ -1599,7 +1616,7 @@ function createReducer(def) {
|
|
|
1599
1616
|
}
|
|
1600
1617
|
p.gamemode = e.gamemode;
|
|
1601
1618
|
if (playing())
|
|
1602
|
-
fire(r, "gamemode", { player: p, gamemode: e.gamemode });
|
|
1619
|
+
fire(r, "gamemode", { player: viewOf(r, p), gamemode: e.gamemode });
|
|
1603
1620
|
break;
|
|
1604
1621
|
}
|
|
1605
1622
|
case "player_left": {
|
|
@@ -1610,7 +1627,7 @@ function createReducer(def) {
|
|
|
1610
1627
|
}
|
|
1611
1628
|
p.connected = false;
|
|
1612
1629
|
if (playing())
|
|
1613
|
-
fire(r, "left", { player: p });
|
|
1630
|
+
fire(r, "left", { player: viewOf(r, p) });
|
|
1614
1631
|
break;
|
|
1615
1632
|
}
|
|
1616
1633
|
case "tick": {
|
|
@@ -1664,7 +1681,7 @@ function createReducer(def) {
|
|
|
1664
1681
|
if (batchName !== undefined) {
|
|
1665
1682
|
delete s.batches[e.id];
|
|
1666
1683
|
if (playing())
|
|
1667
|
-
fire(r, "batchDone", { name: batchName, ok: e.ok, failed: e.failed ?? [] });
|
|
1684
|
+
fire(r, "batchDone", { name: batchName, ok: e.ok, failed: snapshot(e.failed ?? []) });
|
|
1668
1685
|
return;
|
|
1669
1686
|
}
|
|
1670
1687
|
const w = s.walks[e.id];
|
|
@@ -1678,7 +1695,7 @@ function createReducer(def) {
|
|
|
1678
1695
|
}
|
|
1679
1696
|
const p = resolve(w.player);
|
|
1680
1697
|
if (p && playing())
|
|
1681
|
-
fire(r, "walkDone", { player: p, ok: e.ok });
|
|
1698
|
+
fire(r, "walkDone", { player: viewOf(r, p), ok: e.ok });
|
|
1682
1699
|
}
|
|
1683
1700
|
break;
|
|
1684
1701
|
}
|
|
@@ -1688,7 +1705,7 @@ function createReducer(def) {
|
|
|
1688
1705
|
fire(r, "effectFailed", {
|
|
1689
1706
|
kind: e.kind,
|
|
1690
1707
|
detail: e.detail,
|
|
1691
|
-
effect: e.effect,
|
|
1708
|
+
effect: snapshot(e.effect),
|
|
1692
1709
|
batch: e.batch && s.batches[e.batch.id] !== undefined
|
|
1693
1710
|
? { name: s.batches[e.batch.id], index: e.batch.index }
|
|
1694
1711
|
: undefined,
|
|
@@ -1710,7 +1727,7 @@ function createReducer(def) {
|
|
|
1710
1727
|
const p = resolve(e.name);
|
|
1711
1728
|
if (!p || !playing())
|
|
1712
1729
|
return;
|
|
1713
|
-
fire(r, "damaged", { player: p, amount: e.amount, cause: e.cause, attacker: resolve(e.attacker) });
|
|
1730
|
+
fire(r, "damaged", { player: viewOf(r, p), amount: e.amount, cause: e.cause, attacker: viewOf(r, resolve(e.attacker)) });
|
|
1714
1731
|
break;
|
|
1715
1732
|
}
|
|
1716
1733
|
case "player_died": {
|
|
@@ -1728,7 +1745,7 @@ function createReducer(def) {
|
|
|
1728
1745
|
p.eliminated = true;
|
|
1729
1746
|
r.actions.push({ type: "effect", effect: { kind: "eliminate", player: p.name } });
|
|
1730
1747
|
}
|
|
1731
|
-
fire(r, "died", { player: p, cause: e.cause, killer });
|
|
1748
|
+
fire(r, "died", { player: viewOf(r, p), cause: e.cause, killer: viewOf(r, killer) });
|
|
1732
1749
|
break;
|
|
1733
1750
|
}
|
|
1734
1751
|
case "player_respawned": {
|
|
@@ -1738,14 +1755,14 @@ function createReducer(def) {
|
|
|
1738
1755
|
if (!p.eliminated)
|
|
1739
1756
|
p.alive = true;
|
|
1740
1757
|
if (playing())
|
|
1741
|
-
fire(r, "respawned", { player: p });
|
|
1758
|
+
fire(r, "respawned", { player: viewOf(r, p) });
|
|
1742
1759
|
break;
|
|
1743
1760
|
}
|
|
1744
1761
|
case "item_picked_up": {
|
|
1745
1762
|
const p = resolve(e.name);
|
|
1746
1763
|
if (!p || !playing())
|
|
1747
1764
|
return;
|
|
1748
|
-
fire(r, "pickup", { player: p, item: e.item, count: e.count, at: e.at });
|
|
1765
|
+
fire(r, "pickup", { player: viewOf(r, p), item: e.item, count: e.count, at: { ...e.at } });
|
|
1749
1766
|
break;
|
|
1750
1767
|
}
|
|
1751
1768
|
case "inventory": {
|
|
@@ -1766,7 +1783,7 @@ function createReducer(def) {
|
|
|
1766
1783
|
return;
|
|
1767
1784
|
for (const item of new Set([...Object.keys(before), ...Object.keys(after)])) {
|
|
1768
1785
|
if ((before[item] ?? 0) !== (after[item] ?? 0)) {
|
|
1769
|
-
fire(r, "inventory", { player: p, item: item, count: after[item] ?? 0 });
|
|
1786
|
+
fire(r, "inventory", { player: viewOf(r, p), item: item, count: after[item] ?? 0 });
|
|
1770
1787
|
}
|
|
1771
1788
|
}
|
|
1772
1789
|
break;
|
|
@@ -1829,7 +1846,7 @@ function createReducer(def) {
|
|
|
1829
1846
|
return;
|
|
1830
1847
|
s.world = (0, world_js_1.removeEntity)(s.world, e.id);
|
|
1831
1848
|
if (playing())
|
|
1832
|
-
fire(r, "entityRemoved", { entity: (0, world_js_1.freezeObservation)(prev), cause: e.cause, killer: resolve(e.killer) });
|
|
1849
|
+
fire(r, "entityRemoved", { entity: (0, world_js_1.freezeObservation)(prev), cause: e.cause, killer: viewOf(r, resolve(e.killer)) });
|
|
1833
1850
|
break;
|
|
1834
1851
|
}
|
|
1835
1852
|
case "chunk":
|
|
@@ -1848,9 +1865,9 @@ function createReducer(def) {
|
|
|
1848
1865
|
case "blocks_changed": {
|
|
1849
1866
|
s.world = (0, world_js_1.setBlocks)(s.world, e.changes);
|
|
1850
1867
|
if (playing()) {
|
|
1851
|
-
fire(r, "blocksChanged", {
|
|
1852
|
-
changes: e.changes.map((c) => compact({ x: c.x, y: c.y, z: c.z, block: c.block, was: c.was, cause: c.cause, by: resolve(c.by) })),
|
|
1853
|
-
});
|
|
1868
|
+
fire(r, "blocksChanged", () => ({
|
|
1869
|
+
changes: e.changes.map((c) => compact({ x: c.x, y: c.y, z: c.z, block: c.block, was: c.was, cause: c.cause, by: viewOf(r, resolve(c.by)) })),
|
|
1870
|
+
}));
|
|
1854
1871
|
}
|
|
1855
1872
|
break;
|
|
1856
1873
|
}
|
|
@@ -1866,7 +1883,7 @@ function createReducer(def) {
|
|
|
1866
1883
|
s.world = (0, world_js_1.setBlocks)(s.world, [{ ...e.at, block: e.after ?? world_js_1.AIR }]);
|
|
1867
1884
|
const p = resolve(e.name);
|
|
1868
1885
|
if (p && playing())
|
|
1869
|
-
fire(r, "blockBroken", { player: p, at: { ...e.at }, block: parseBlockState(e.block) });
|
|
1886
|
+
fire(r, "blockBroken", { player: viewOf(r, p), at: { ...e.at }, block: parseBlockState(e.block) });
|
|
1870
1887
|
break;
|
|
1871
1888
|
}
|
|
1872
1889
|
case "block_placed": {
|
|
@@ -1874,25 +1891,25 @@ function createReducer(def) {
|
|
|
1874
1891
|
s.world = (0, world_js_1.setBlocks)(s.world, changes);
|
|
1875
1892
|
const p = resolve(e.name);
|
|
1876
1893
|
if (p && playing())
|
|
1877
|
-
fire(r, "blockPlaced", { player: p, at: { ...e.at }, block: parseBlockState(e.block) });
|
|
1894
|
+
fire(r, "blockPlaced", { player: viewOf(r, p), at: { ...e.at }, block: parseBlockState(e.block) });
|
|
1878
1895
|
break;
|
|
1879
1896
|
}
|
|
1880
1897
|
case "block_used": {
|
|
1881
1898
|
const p = resolve(e.name);
|
|
1882
1899
|
if (p && playing())
|
|
1883
|
-
fire(r, "blockUsed", { player: p, at: { ...e.at }, block: parseBlockState(e.block), item: e.item });
|
|
1900
|
+
fire(r, "blockUsed", { player: viewOf(r, p), at: { ...e.at }, block: parseBlockState(e.block), item: e.item });
|
|
1884
1901
|
break;
|
|
1885
1902
|
}
|
|
1886
1903
|
case "chat": {
|
|
1887
1904
|
const p = resolve(e.from);
|
|
1888
1905
|
if (p && playing())
|
|
1889
|
-
fire(r, "chat", { player: p, text: e.text });
|
|
1906
|
+
fire(r, "chat", { player: viewOf(r, p), text: e.text });
|
|
1890
1907
|
break;
|
|
1891
1908
|
}
|
|
1892
1909
|
case "animation": {
|
|
1893
1910
|
const p = resolve(e.name);
|
|
1894
1911
|
if (p && playing())
|
|
1895
|
-
fire(r, "animation", { player: p, animation: e.animation });
|
|
1912
|
+
fire(r, "animation", { player: viewOf(r, p), animation: e.animation });
|
|
1896
1913
|
break;
|
|
1897
1914
|
}
|
|
1898
1915
|
case "vote_attempt":
|
|
@@ -1901,7 +1918,7 @@ function createReducer(def) {
|
|
|
1901
1918
|
case "custom": {
|
|
1902
1919
|
if (!playing())
|
|
1903
1920
|
return;
|
|
1904
|
-
fire(r, "custom", { name: e.name, player: resolve(e.player), data: e.data });
|
|
1921
|
+
fire(r, "custom", { name: e.name, player: viewOf(r, resolve(e.player)), data: snapshot(e.data) });
|
|
1905
1922
|
break;
|
|
1906
1923
|
}
|
|
1907
1924
|
}
|
|
@@ -1974,7 +1991,7 @@ function createReducer(def) {
|
|
|
1974
1991
|
}
|
|
1975
1992
|
v.cast[p.name] = e.option;
|
|
1976
1993
|
r.actions.push({ type: "vote_decision", attemptId: e.attemptId, accepted: true, round: v.round });
|
|
1977
|
-
fire(r, "vote", { player: p, voteId: e.voteId, option: e.option });
|
|
1994
|
+
fire(r, "vote", { player: viewOf(r, p), voteId: e.voteId, option: e.option });
|
|
1978
1995
|
}
|
|
1979
1996
|
// ------------------------------------------------------------ reduce
|
|
1980
1997
|
const reduce = (input, event) => {
|