bedrock-kit 0.0.3

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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/dist/bedrockKit.d.ts +32 -0
  4. package/dist/bedrockKit.d.ts.map +1 -0
  5. package/dist/bedrockKit.js +33 -0
  6. package/dist/bedrockKit.js.map +1 -0
  7. package/dist/internal/addon.d.ts +198 -0
  8. package/dist/internal/addon.d.ts.map +1 -0
  9. package/dist/internal/addon.js +562 -0
  10. package/dist/internal/addon.js.map +1 -0
  11. package/dist/internal/animation.d.ts +53 -0
  12. package/dist/internal/animation.d.ts.map +1 -0
  13. package/dist/internal/animation.js +47 -0
  14. package/dist/internal/animation.js.map +1 -0
  15. package/dist/internal/attachable.d.ts +31 -0
  16. package/dist/internal/attachable.d.ts.map +1 -0
  17. package/dist/internal/attachable.js +35 -0
  18. package/dist/internal/attachable.js.map +1 -0
  19. package/dist/internal/biome.d.ts +62 -0
  20. package/dist/internal/biome.d.ts.map +1 -0
  21. package/dist/internal/biome.js +75 -0
  22. package/dist/internal/biome.js.map +1 -0
  23. package/dist/internal/block.d.ts +55 -0
  24. package/dist/internal/block.d.ts.map +1 -0
  25. package/dist/internal/block.js +75 -0
  26. package/dist/internal/block.js.map +1 -0
  27. package/dist/internal/entity.d.ts +107 -0
  28. package/dist/internal/entity.d.ts.map +1 -0
  29. package/dist/internal/entity.js +148 -0
  30. package/dist/internal/entity.js.map +1 -0
  31. package/dist/internal/item.d.ts +72 -0
  32. package/dist/internal/item.d.ts.map +1 -0
  33. package/dist/internal/item.js +103 -0
  34. package/dist/internal/item.js.map +1 -0
  35. package/dist/internal/itemStack.d.ts +27 -0
  36. package/dist/internal/itemStack.d.ts.map +1 -0
  37. package/dist/internal/itemStack.js +23 -0
  38. package/dist/internal/itemStack.js.map +1 -0
  39. package/dist/internal/lootTable.d.ts +38 -0
  40. package/dist/internal/lootTable.d.ts.map +1 -0
  41. package/dist/internal/lootTable.js +57 -0
  42. package/dist/internal/lootTable.js.map +1 -0
  43. package/dist/internal/particle.d.ts +35 -0
  44. package/dist/internal/particle.d.ts.map +1 -0
  45. package/dist/internal/particle.js +42 -0
  46. package/dist/internal/particle.js.map +1 -0
  47. package/dist/internal/recipe.d.ts +89 -0
  48. package/dist/internal/recipe.d.ts.map +1 -0
  49. package/dist/internal/recipe.js +198 -0
  50. package/dist/internal/recipe.js.map +1 -0
  51. package/dist/internal/renderController.d.ts +24 -0
  52. package/dist/internal/renderController.d.ts.map +1 -0
  53. package/dist/internal/renderController.js +19 -0
  54. package/dist/internal/renderController.js.map +1 -0
  55. package/dist/internal/sound.d.ts +85 -0
  56. package/dist/internal/sound.d.ts.map +1 -0
  57. package/dist/internal/sound.js +64 -0
  58. package/dist/internal/sound.js.map +1 -0
  59. package/dist/internal/spawnRule.d.ts +44 -0
  60. package/dist/internal/spawnRule.d.ts.map +1 -0
  61. package/dist/internal/spawnRule.js +57 -0
  62. package/dist/internal/spawnRule.js.map +1 -0
  63. package/dist/internal/tag.d.ts +43 -0
  64. package/dist/internal/tag.d.ts.map +1 -0
  65. package/dist/internal/tag.js +8 -0
  66. package/dist/internal/tag.js.map +1 -0
  67. package/dist/internal/tradingTable.d.ts +34 -0
  68. package/dist/internal/tradingTable.d.ts.map +1 -0
  69. package/dist/internal/tradingTable.js +62 -0
  70. package/dist/internal/tradingTable.js.map +1 -0
  71. package/dist/internal/types.d.ts +97 -0
  72. package/dist/internal/types.d.ts.map +1 -0
  73. package/dist/internal/types.js +3 -0
  74. package/dist/internal/types.js.map +1 -0
  75. package/dist/internal/utils.d.ts +39 -0
  76. package/dist/internal/utils.d.ts.map +1 -0
  77. package/dist/internal/utils.js +137 -0
  78. package/dist/internal/utils.js.map +1 -0
  79. package/package.json +35 -0
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Represents a single animation definition loaded from a resource pack animation file.
3
+ * Multiple animations are defined per file; each is keyed by its full ID.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const anim = addon.getAnimation("animation.humanoid.move");
8
+ * console.log(anim?.loop); // true
9
+ * ```
10
+ */
11
+ export class Animation {
12
+ constructor(id, data, filePath) {
13
+ this.id = id;
14
+ this.data = data;
15
+ this.filePath = filePath;
16
+ }
17
+ /** Whether this animation loops. Reads the `loop` property from the animation data. */
18
+ get loop() { return this.data["loop"] === true; }
19
+ }
20
+ /**
21
+ * Represents a single animation controller loaded from a resource pack
22
+ * `animation_controllers/` file. Animation controllers manage transitions
23
+ * between animation states for an entity.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const ctrl = addon.getAnimationController("controller.animation.zombie.move");
28
+ * console.log(ctrl?.initialState); // "default"
29
+ * console.log(ctrl?.states); // ["default", "attacking"]
30
+ * ```
31
+ */
32
+ export class AnimationController {
33
+ constructor(id, data, filePath) {
34
+ this.id = id;
35
+ this.data = data;
36
+ this.filePath = filePath;
37
+ }
38
+ /** The names of all states defined in this controller. */
39
+ get states() {
40
+ return Object.keys(this.data["states"] ?? {});
41
+ }
42
+ /** The name of the initial state this controller starts in. Null if not specified. */
43
+ get initialState() {
44
+ return this.data["initial_state"] ?? null;
45
+ }
46
+ }
47
+ //# sourceMappingURL=animation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.js","sourceRoot":"","sources":["../../src/internal/animation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IAWpB,YAAY,EAAU,EAAE,IAA6B,EAAE,QAAgB;QACrE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,uFAAuF;IACvF,IAAI,IAAI,KAAc,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;CAC3D;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,mBAAmB;IAW9B,YAAY,EAAU,EAAE,IAA6B,EAAE,QAAgB;QACrE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,0DAA0D;IAC1D,IAAI,MAAM;QACR,OAAO,MAAM,CAAC,IAAI,CAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAA6B,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IAED,sFAAsF;IACtF,IAAI,YAAY;QACd,OAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,CAAY,IAAI,IAAI,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Represents an attachable definition from the resource pack's `attachables/` directory.
3
+ * Attachables define how items are visually rendered when held or equipped.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const att = addon.getAttachable("minecraft:bow");
8
+ * console.log(att?.textures); // { default: "textures/items/bow_standby", ... }
9
+ * console.log(att?.materials); // { default: "entity_alphatest", ... }
10
+ * ```
11
+ */
12
+ export declare class Attachable {
13
+ /** The namespaced item identifier this attachable is for, e.g. `"minecraft:bow"`. */
14
+ readonly identifier: string;
15
+ /** The raw parsed JSON of the attachable file. */
16
+ readonly data: Record<string, unknown>;
17
+ /**
18
+ * Absolute path to the attachable file on disk.
19
+ * Empty string when loaded from browser `File[]`.
20
+ */
21
+ readonly filePath: string;
22
+ constructor(identifier: string, data: Record<string, unknown>, filePath: string);
23
+ private get _description();
24
+ /** Map of shortname → texture path. e.g. `{ "default": "textures/items/bow_standby" }`. */
25
+ get textures(): Record<string, string>;
26
+ /** Map of shortname → material name. e.g. `{ "default": "entity_alphatest" }`. */
27
+ get materials(): Record<string, string>;
28
+ /** Map of shortname → geometry identifier. */
29
+ get geometry(): Record<string, string>;
30
+ }
31
+ //# sourceMappingURL=attachable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachable.d.ts","sourceRoot":"","sources":["../../src/internal/attachable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IACrB,qFAAqF;IACrF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM;IAM/E,OAAO,KAAK,YAAY,GAGvB;IAED,2FAA2F;IAC3F,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAErC;IACD,kFAAkF;IAClF,IAAI,SAAS,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAEtC;IACD,8CAA8C;IAC9C,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAErC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Represents an attachable definition from the resource pack's `attachables/` directory.
3
+ * Attachables define how items are visually rendered when held or equipped.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const att = addon.getAttachable("minecraft:bow");
8
+ * console.log(att?.textures); // { default: "textures/items/bow_standby", ... }
9
+ * console.log(att?.materials); // { default: "entity_alphatest", ... }
10
+ * ```
11
+ */
12
+ export class Attachable {
13
+ constructor(identifier, data, filePath) {
14
+ this.identifier = identifier;
15
+ this.data = data;
16
+ this.filePath = filePath;
17
+ }
18
+ get _description() {
19
+ const inner = this.data["minecraft:attachable"] ?? {};
20
+ return inner["description"] ?? {};
21
+ }
22
+ /** Map of shortname → texture path. e.g. `{ "default": "textures/items/bow_standby" }`. */
23
+ get textures() {
24
+ return this._description["textures"] ?? {};
25
+ }
26
+ /** Map of shortname → material name. e.g. `{ "default": "entity_alphatest" }`. */
27
+ get materials() {
28
+ return this._description["materials"] ?? {};
29
+ }
30
+ /** Map of shortname → geometry identifier. */
31
+ get geometry() {
32
+ return this._description["geometry"] ?? {};
33
+ }
34
+ }
35
+ //# sourceMappingURL=attachable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachable.js","sourceRoot":"","sources":["../../src/internal/attachable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IAWrB,YAAY,UAAkB,EAAE,IAA6B,EAAE,QAAgB;QAC7E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAY,YAAY;QACtB,MAAM,KAAK,GAAI,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAA6B,IAAI,EAAE,CAAC;QACnF,OAAQ,KAAK,CAAC,aAAa,CAA6B,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,2FAA2F;IAC3F,IAAI,QAAQ;QACV,OAAQ,IAAI,CAAC,YAAY,CAAC,UAAU,CAA4B,IAAI,EAAE,CAAC;IACzE,CAAC;IACD,kFAAkF;IAClF,IAAI,SAAS;QACX,OAAQ,IAAI,CAAC,YAAY,CAAC,WAAW,CAA4B,IAAI,EAAE,CAAC;IAC1E,CAAC;IACD,8CAA8C;IAC9C,IAAI,QAAQ;QACV,OAAQ,IAAI,CAAC,YAAY,CAAC,UAAU,CAA4B,IAAI,EAAE,CAAC;IACzE,CAAC;CACF"}
@@ -0,0 +1,62 @@
1
+ import type { AddOn } from "./addon.js";
2
+ import type { Entity } from "./entity.js";
3
+ import type { MusicDefinition } from "./sound.js";
4
+ /**
5
+ * Represents a biome definition file from the behavior pack's `biomes/` directory.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const biome = addon.getBiome("minecraft:bamboo_jungle");
10
+ * console.log(biome?.climate?.temperature); // 0.95
11
+ * console.log(biome?.getEntities().map(e => e.identifier));
12
+ * ```
13
+ */
14
+ export declare class Biome {
15
+ /** The namespaced biome identifier, e.g. `"minecraft:bamboo_jungle"`. */
16
+ readonly identifier: string;
17
+ /** The raw parsed JSON of the biome file. */
18
+ readonly data: Record<string, unknown>;
19
+ /**
20
+ * Absolute path to the biome file on disk.
21
+ * Empty string when loaded from browser `File[]`.
22
+ */
23
+ readonly filePath: string;
24
+ private readonly _addon;
25
+ constructor(identifier: string, data: Record<string, unknown>, filePath: string, addon: AddOn);
26
+ /**
27
+ * The full components object from the biome definition.
28
+ * Keys are Bedrock component names such as `"minecraft:climate"`, `"minecraft:tags"`, etc.
29
+ */
30
+ get components(): Record<string, unknown>;
31
+ /**
32
+ * The `minecraft:climate` component, which contains properties like
33
+ * `temperature`, `downfall`, and `snow_accumulation`. Returns null if absent.
34
+ */
35
+ get climate(): Record<string, unknown> | null;
36
+ /**
37
+ * Returns all entities whose spawn rule references at least one tag that this biome has.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * addon.getBiome("minecraft:bamboo_jungle")
42
+ * ?.getEntities()
43
+ * .map(e => e.identifier);
44
+ * // ["minecraft:panda", "minecraft:ocelot", ...]
45
+ * ```
46
+ */
47
+ getEntities(): Entity[];
48
+ /**
49
+ * Returns the music definition for this biome from `sounds/music_definitions.json`.
50
+ *
51
+ * Looks up the biome's shortname (e.g. `"minecraft:bamboo_jungle"` → `"bamboo_jungle"`).
52
+ * Returns null if no music definition exists for this biome.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * addon.getBiome("minecraft:bamboo_jungle")?.getMusicDefinition()?.eventName;
57
+ * // "music.overworld.bamboo_jungle"
58
+ * ```
59
+ */
60
+ getMusicDefinition(): MusicDefinition | null;
61
+ }
62
+ //# sourceMappingURL=biome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"biome.d.ts","sourceRoot":"","sources":["../../src/internal/biome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD;;;;;;;;;GASG;AACH,qBAAa,KAAK;IAChB,yEAAyE;IACzE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAO7F;;;OAGG;IACH,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGxC;IAED;;;OAGG;IACH,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAE5C;IAED;;;;;;;;;;OAUG;IACH,WAAW,IAAI,MAAM,EAAE;IAcvB;;;;;;;;;;;OAWG;IACH,kBAAkB,IAAI,eAAe,GAAG,IAAI;CAG7C"}
@@ -0,0 +1,75 @@
1
+ import { shortname } from "./utils.js";
2
+ /**
3
+ * Represents a biome definition file from the behavior pack's `biomes/` directory.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const biome = addon.getBiome("minecraft:bamboo_jungle");
8
+ * console.log(biome?.climate?.temperature); // 0.95
9
+ * console.log(biome?.getEntities().map(e => e.identifier));
10
+ * ```
11
+ */
12
+ export class Biome {
13
+ constructor(identifier, data, filePath, addon) {
14
+ this.identifier = identifier;
15
+ this.data = data;
16
+ this.filePath = filePath;
17
+ this._addon = addon;
18
+ }
19
+ /**
20
+ * The full components object from the biome definition.
21
+ * Keys are Bedrock component names such as `"minecraft:climate"`, `"minecraft:tags"`, etc.
22
+ */
23
+ get components() {
24
+ const inner = this.data["minecraft:biome"] ?? {};
25
+ return inner["components"] ?? {};
26
+ }
27
+ /**
28
+ * The `minecraft:climate` component, which contains properties like
29
+ * `temperature`, `downfall`, and `snow_accumulation`. Returns null if absent.
30
+ */
31
+ get climate() {
32
+ return this.components["minecraft:climate"] ?? null;
33
+ }
34
+ /**
35
+ * Returns all entities whose spawn rule references at least one tag that this biome has.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * addon.getBiome("minecraft:bamboo_jungle")
40
+ * ?.getEntities()
41
+ * .map(e => e.identifier);
42
+ * // ["minecraft:panda", "minecraft:ocelot", ...]
43
+ * ```
44
+ */
45
+ getEntities() {
46
+ const tagsComp = this.components["minecraft:tags"];
47
+ const biomeTags = tagsComp
48
+ ? tagsComp["tags"] ?? []
49
+ : [];
50
+ if (biomeTags.length === 0)
51
+ return [];
52
+ return this._addon.getAllEntities().filter((entity) => {
53
+ const spawnRule = entity.getSpawnRule();
54
+ if (!spawnRule)
55
+ return false;
56
+ return spawnRule.getBiomeTags().some((tag) => biomeTags.includes(tag));
57
+ });
58
+ }
59
+ /**
60
+ * Returns the music definition for this biome from `sounds/music_definitions.json`.
61
+ *
62
+ * Looks up the biome's shortname (e.g. `"minecraft:bamboo_jungle"` → `"bamboo_jungle"`).
63
+ * Returns null if no music definition exists for this biome.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * addon.getBiome("minecraft:bamboo_jungle")?.getMusicDefinition()?.eventName;
68
+ * // "music.overworld.bamboo_jungle"
69
+ * ```
70
+ */
71
+ getMusicDefinition() {
72
+ return this._addon.getMusicDefinition(shortname(this.identifier));
73
+ }
74
+ }
75
+ //# sourceMappingURL=biome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"biome.js","sourceRoot":"","sources":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S,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ import type { AddOn } from "./addon.js";
2
+ import type { LootTable } from "./lootTable.js";
3
+ import type { SoundEvent } from "./sound.js";
4
+ /**
5
+ * Represents a block definition file from the behavior pack's `blocks/` directory.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const block = addon.getBlock("tsunami_dungeons:golem_heart");
10
+ * console.log(block?.getTexturePath("*")); // "textures/blocks/golem_heart"
11
+ * console.log(block?.getLootTable()); // LootTable | null
12
+ * ```
13
+ */
14
+ export declare class Block {
15
+ /** The namespaced block identifier, e.g. `"minecraft:dirt"`. */
16
+ readonly identifier: string;
17
+ /** The raw parsed JSON of the block's behavior file. */
18
+ readonly data: Record<string, unknown>;
19
+ /**
20
+ * Absolute path to the block's behavior file on disk.
21
+ * Empty string when loaded from browser `File[]`.
22
+ */
23
+ readonly filePath: string;
24
+ private readonly _addon;
25
+ constructor(identifier: string, data: Record<string, unknown>, filePath: string, addon: AddOn);
26
+ /**
27
+ * Resolves the texture path for the given face of this block by reading its
28
+ * `minecraft:material_instances` component and looking up the shortname in
29
+ * the resource pack's `terrain_texture.json`.
30
+ *
31
+ * @param face - `"up"`, `"down"`, `"side"`, or `"*"` for the wildcard/default face.
32
+ */
33
+ getTexturePath(face?: "up" | "down" | "side" | "*"): string | null;
34
+ /**
35
+ * Returns the loot table for this block by resolving the path in its
36
+ * `minecraft:loot` component. Returns null if absent.
37
+ */
38
+ getLootTable(): LootTable | null;
39
+ /**
40
+ * Returns the sound events for this block from `sounds/sounds.json`.
41
+ *
42
+ * Looks up the block's shortname (e.g. `"minecraft:amethyst_block"` → `"amethyst_block"`)
43
+ * in `block_sounds`. Returns an empty array if no sound events are defined.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * addon.getBlock("minecraft:amethyst_block")?.getSoundEvents()
48
+ * .find(e => e.event === "break")?.definitionId;
49
+ * // "break.amethyst_block"
50
+ * ```
51
+ */
52
+ getSoundEvents(): SoundEvent[];
53
+ private _getComponents;
54
+ }
55
+ //# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/internal/block.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;;;GASG;AACH,qBAAa,KAAK;IAChB,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAEnB,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;IAO7F;;;;;;OAMG;IACH,cAAc,CAAC,IAAI,GAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,GAAS,GAAG,MAAM,GAAG,IAAI;IAiBvE;;;OAGG;IACH,YAAY,IAAI,SAAS,GAAG,IAAI;IAMhC;;;;;;;;;;;;OAYG;IACH,cAAc,IAAI,UAAU,EAAE;IAI9B,OAAO,CAAC,cAAc;CAIvB"}
@@ -0,0 +1,75 @@
1
+ import { shortname } from "./utils.js";
2
+ /**
3
+ * Represents a block definition file from the behavior pack's `blocks/` directory.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const block = addon.getBlock("tsunami_dungeons:golem_heart");
8
+ * console.log(block?.getTexturePath("*")); // "textures/blocks/golem_heart"
9
+ * console.log(block?.getLootTable()); // LootTable | null
10
+ * ```
11
+ */
12
+ export class Block {
13
+ constructor(identifier, data, filePath, addon) {
14
+ this.identifier = identifier;
15
+ this.data = data;
16
+ this.filePath = filePath;
17
+ this._addon = addon;
18
+ }
19
+ /**
20
+ * Resolves the texture path for the given face of this block by reading its
21
+ * `minecraft:material_instances` component and looking up the shortname in
22
+ * the resource pack's `terrain_texture.json`.
23
+ *
24
+ * @param face - `"up"`, `"down"`, `"side"`, or `"*"` for the wildcard/default face.
25
+ */
26
+ getTexturePath(face = "*") {
27
+ const textures = this._addon.terrainTextures;
28
+ if (!textures)
29
+ return null;
30
+ const materialInstances = this._getComponents()["minecraft:material_instances"];
31
+ if (!materialInstances)
32
+ return null;
33
+ const instance = materialInstances[face] ??
34
+ materialInstances["*"];
35
+ const sn = instance?.["texture"];
36
+ if (!sn)
37
+ return null;
38
+ const entry = textures.texture_data[sn];
39
+ if (!entry)
40
+ return null;
41
+ const tex = entry.textures;
42
+ return Array.isArray(tex) ? (tex[0] ?? null) : tex;
43
+ }
44
+ /**
45
+ * Returns the loot table for this block by resolving the path in its
46
+ * `minecraft:loot` component. Returns null if absent.
47
+ */
48
+ getLootTable() {
49
+ const lootPath = this._getComponents()["minecraft:loot"];
50
+ if (typeof lootPath !== "string")
51
+ return null;
52
+ return this._addon.getLootTableByPath(lootPath);
53
+ }
54
+ /**
55
+ * Returns the sound events for this block from `sounds/sounds.json`.
56
+ *
57
+ * Looks up the block's shortname (e.g. `"minecraft:amethyst_block"` → `"amethyst_block"`)
58
+ * in `block_sounds`. Returns an empty array if no sound events are defined.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * addon.getBlock("minecraft:amethyst_block")?.getSoundEvents()
63
+ * .find(e => e.event === "break")?.definitionId;
64
+ * // "break.amethyst_block"
65
+ * ```
66
+ */
67
+ getSoundEvents() {
68
+ return this._addon.getBlockSoundEvents(shortname(this.identifier));
69
+ }
70
+ _getComponents() {
71
+ const blockDef = this.data["minecraft:block"] ?? {};
72
+ return blockDef["components"] ?? {};
73
+ }
74
+ }
75
+ //# sourceMappingURL=block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.js","sourceRoot":"","sources":["../../src/internal/block.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,OAAO,KAAK;IAYhB,YAAY,UAAkB,EAAE,IAA6B,EAAE,QAAgB,EAAE,KAAY;QAC3F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,OAAqC,GAAG;QACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,8BAA8B,CACzC,CAAC;QACtC,IAAI,CAAC,iBAAiB;YAAE,OAAO,IAAI,CAAC;QACpC,MAAM,QAAQ,GACX,iBAAiB,CAAC,IAAI,CAA6B;YACnD,iBAAiB,CAAC,GAAG,CAA6B,CAAC;QACtD,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC,SAAS,CAAuB,CAAC;QACvD,IAAI,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;QACrB,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QACxB,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC3B,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACrD,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC,CAAC;QACzD,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAClD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,CAAC;IAEO,cAAc;QACpB,MAAM,QAAQ,GAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAA6B,IAAI,EAAE,CAAC;QACjF,OAAQ,QAAQ,CAAC,YAAY,CAA6B,IAAI,EAAE,CAAC;IACnE,CAAC;CACF"}
@@ -0,0 +1,107 @@
1
+ import type { AddOn } from "./addon.js";
2
+ import type { LootTable } from "./lootTable.js";
3
+ import type { SpawnRule } from "./spawnRule.js";
4
+ import type { Animation, AnimationController } from "./animation.js";
5
+ import type { RenderController } from "./renderController.js";
6
+ import type { Particle } from "./particle.js";
7
+ import type { SoundEvent } from "./sound.js";
8
+ /**
9
+ * Represents an entity that exists across both packs — a behavior (server-side)
10
+ * definition and optionally a resource (client-side) definition.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const zombie = addon.getEntity("minecraft:zombie");
15
+ * zombie?.getLootTables(); // LootTable[]
16
+ * zombie?.getSpawnRule(); // SpawnRule | null
17
+ * zombie?.getAnimations(); // [{ shortname, animation }]
18
+ * zombie?.getRenderControllers(); // RenderController[]
19
+ * ```
20
+ */
21
+ export declare class Entity {
22
+ /** The namespaced entity identifier, e.g. `"minecraft:zombie"`. */
23
+ readonly identifier: string;
24
+ /** Raw parsed JSON of the behavior pack (server-side) entity file. */
25
+ readonly behaviorData: Record<string, unknown>;
26
+ /**
27
+ * Absolute path to the behavior file on disk.
28
+ * Empty string if no behavior file exists or when loaded from browser `File[]`.
29
+ */
30
+ readonly behaviorFilePath: string;
31
+ /** Raw parsed JSON of the resource pack (client-side) entity file. Null if not present. */
32
+ readonly resourceData: Record<string, unknown> | null;
33
+ /**
34
+ * Absolute path to the resource file on disk. Null if not present.
35
+ * Empty string when loaded from browser `File[]`.
36
+ */
37
+ readonly resourceFilePath: string | null;
38
+ private readonly _addon;
39
+ constructor(identifier: string, behaviorData: Record<string, unknown>, behaviorFilePath: string, resourceData: Record<string, unknown> | null, resourceFilePath: string | null, addon: AddOn);
40
+ private get _rpDescription();
41
+ /**
42
+ * The shortname → full animation ID map declared in the resource entity file.
43
+ * @example `{ "move": "animation.humanoid.move" }`
44
+ */
45
+ get animationShortnames(): Record<string, string>;
46
+ /**
47
+ * The shortname → full particle identifier map declared in the resource entity file.
48
+ * @example `{ "stun_particles": "minecraft:stunned_emitter" }`
49
+ */
50
+ get particleShortnames(): Record<string, string>;
51
+ /**
52
+ * The list of render controller IDs declared in the resource entity file.
53
+ */
54
+ get renderControllerIds(): string[];
55
+ /**
56
+ * The shortname → sound event ID map declared in the resource entity file's
57
+ * `description.sounds`. These are per-entity sound bindings separate from
58
+ * the global `sounds.json` mappings.
59
+ *
60
+ * @example `{ "hurt": "mob.zombie.hurt", "step": "mob.zombie.step" }`
61
+ */
62
+ get soundShortnames(): Record<string, string>;
63
+ /**
64
+ * Returns all loot tables this entity can drop, by recursively searching
65
+ * its behavior data for `minecraft:loot` component entries.
66
+ */
67
+ getLootTables(): LootTable[];
68
+ /** Returns this entity's spawn rule, or null if none exists. */
69
+ getSpawnRule(): SpawnRule | null;
70
+ /**
71
+ * Resolves this entity's animation shortnames into `Animation` instances.
72
+ * Animation controller references are excluded — use `getAnimationControllers()` for those.
73
+ */
74
+ getAnimations(): Array<{
75
+ shortname: string;
76
+ animation: Animation;
77
+ }>;
78
+ /**
79
+ * Resolves this entity's animation controller shortnames into `AnimationController` instances.
80
+ */
81
+ getAnimationControllers(): Array<{
82
+ shortname: string;
83
+ controller: AnimationController;
84
+ }>;
85
+ /** Resolves this entity's render controller IDs into `RenderController` instances. */
86
+ getRenderControllers(): RenderController[];
87
+ /** Resolves this entity's particle shortnames into `Particle` instances. */
88
+ getParticles(): Array<{
89
+ shortname: string;
90
+ particle: Particle;
91
+ }>;
92
+ /**
93
+ * Returns the sound events for this entity from `sounds/sounds.json`.
94
+ *
95
+ * The entity identifier is stripped to its shortname for the lookup
96
+ * (e.g. `"minecraft:zombie"` → `"zombie"`).
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * addon.getEntity("minecraft:zombie")?.getSoundEvents()
101
+ * .map(e => `${e.event} → ${e.definitionId}`);
102
+ * ```
103
+ */
104
+ getSoundEvents(): SoundEvent[];
105
+ private _collectLootPaths;
106
+ }
107
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/internal/entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,U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