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,148 @@
1
+ import { shortname } from "./utils.js";
2
+ /**
3
+ * Represents an entity that exists across both packs — a behavior (server-side)
4
+ * definition and optionally a resource (client-side) definition.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const zombie = addon.getEntity("minecraft:zombie");
9
+ * zombie?.getLootTables(); // LootTable[]
10
+ * zombie?.getSpawnRule(); // SpawnRule | null
11
+ * zombie?.getAnimations(); // [{ shortname, animation }]
12
+ * zombie?.getRenderControllers(); // RenderController[]
13
+ * ```
14
+ */
15
+ export class Entity {
16
+ constructor(identifier, behaviorData, behaviorFilePath, resourceData, resourceFilePath, addon) {
17
+ this.identifier = identifier;
18
+ this.behaviorData = behaviorData;
19
+ this.behaviorFilePath = behaviorFilePath;
20
+ this.resourceData = resourceData;
21
+ this.resourceFilePath = resourceFilePath;
22
+ this._addon = addon;
23
+ }
24
+ get _rpDescription() {
25
+ const inner = this.resourceData?.["minecraft:client_entity"] ?? {};
26
+ return inner["description"] ?? {};
27
+ }
28
+ /**
29
+ * The shortname → full animation ID map declared in the resource entity file.
30
+ * @example `{ "move": "animation.humanoid.move" }`
31
+ */
32
+ get animationShortnames() {
33
+ return this._rpDescription["animations"] ?? {};
34
+ }
35
+ /**
36
+ * The shortname → full particle identifier map declared in the resource entity file.
37
+ * @example `{ "stun_particles": "minecraft:stunned_emitter" }`
38
+ */
39
+ get particleShortnames() {
40
+ return this._rpDescription["particle_effects"] ?? {};
41
+ }
42
+ /**
43
+ * The list of render controller IDs declared in the resource entity file.
44
+ */
45
+ get renderControllerIds() {
46
+ const raw = this._rpDescription["render_controllers"];
47
+ if (!Array.isArray(raw))
48
+ return [];
49
+ return raw.flatMap((entry) => {
50
+ if (typeof entry === "string")
51
+ return [entry];
52
+ if (typeof entry === "object" && entry !== null)
53
+ return Object.keys(entry);
54
+ return [];
55
+ });
56
+ }
57
+ /**
58
+ * The shortname → sound event ID map declared in the resource entity file's
59
+ * `description.sounds`. These are per-entity sound bindings separate from
60
+ * the global `sounds.json` mappings.
61
+ *
62
+ * @example `{ "hurt": "mob.zombie.hurt", "step": "mob.zombie.step" }`
63
+ */
64
+ get soundShortnames() {
65
+ return this._rpDescription["sounds"] ?? {};
66
+ }
67
+ /**
68
+ * Returns all loot tables this entity can drop, by recursively searching
69
+ * its behavior data for `minecraft:loot` component entries.
70
+ */
71
+ getLootTables() {
72
+ return this._collectLootPaths(this.behaviorData).flatMap((p) => {
73
+ const lt = this._addon.getLootTableByPath(p);
74
+ return lt ? [lt] : [];
75
+ });
76
+ }
77
+ /** Returns this entity's spawn rule, or null if none exists. */
78
+ getSpawnRule() {
79
+ return this._addon.getSpawnRule(this.identifier);
80
+ }
81
+ /**
82
+ * Resolves this entity's animation shortnames into `Animation` instances.
83
+ * Animation controller references are excluded — use `getAnimationControllers()` for those.
84
+ */
85
+ getAnimations() {
86
+ return Object.entries(this.animationShortnames).flatMap(([sn, fullId]) => {
87
+ if (fullId.startsWith("controller."))
88
+ return [];
89
+ const animation = this._addon.getAnimation(fullId);
90
+ return animation ? [{ shortname: sn, animation }] : [];
91
+ });
92
+ }
93
+ /**
94
+ * Resolves this entity's animation controller shortnames into `AnimationController` instances.
95
+ */
96
+ getAnimationControllers() {
97
+ return Object.entries(this.animationShortnames).flatMap(([sn, fullId]) => {
98
+ if (!fullId.startsWith("controller.animation."))
99
+ return [];
100
+ const controller = this._addon.getAnimationController(fullId);
101
+ return controller ? [{ shortname: sn, controller }] : [];
102
+ });
103
+ }
104
+ /** Resolves this entity's render controller IDs into `RenderController` instances. */
105
+ getRenderControllers() {
106
+ return this.renderControllerIds.flatMap((id) => {
107
+ const rc = this._addon.getRenderController(id);
108
+ return rc ? [rc] : [];
109
+ });
110
+ }
111
+ /** Resolves this entity's particle shortnames into `Particle` instances. */
112
+ getParticles() {
113
+ return Object.entries(this.particleShortnames).flatMap(([sn, fullId]) => {
114
+ const particle = this._addon.getParticle(fullId);
115
+ return particle ? [{ shortname: sn, particle }] : [];
116
+ });
117
+ }
118
+ /**
119
+ * Returns the sound events for this entity from `sounds/sounds.json`.
120
+ *
121
+ * The entity identifier is stripped to its shortname for the lookup
122
+ * (e.g. `"minecraft:zombie"` → `"zombie"`).
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * addon.getEntity("minecraft:zombie")?.getSoundEvents()
127
+ * .map(e => `${e.event} → ${e.definitionId}`);
128
+ * ```
129
+ */
130
+ getSoundEvents() {
131
+ return this._addon.getEntitySoundEvents(shortname(this.identifier));
132
+ }
133
+ _collectLootPaths(obj) {
134
+ if (typeof obj !== "object" || obj === null)
135
+ return [];
136
+ const paths = [];
137
+ for (const [key, value] of Object.entries(obj)) {
138
+ if (key === "minecraft:loot" && typeof value === "object" && value !== null) {
139
+ const table = value["table"];
140
+ if (typeof table === "string")
141
+ paths.push(table);
142
+ }
143
+ paths.push(...this._collectLootPaths(value));
144
+ }
145
+ return [...new Set(paths)];
146
+ }
147
+ }
148
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","sourceRoot":"","sources":["../../src/internal/entity.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,MAAM;IAoBjB,YACE,UAAkB,EAClB,YAAqC,EACrC,gBAAwB,EACxB,YAA4C,EAC5C,gBAA+B,EAC/B,KAAY;QAEZ,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,IAAY,cAAc;QACxB,MAAM,KAAK,GAAI,IAAI,CAAC,YAAY,EAAE,CAAC,yBAAyB,CAA6B,IAAI,EAAE,CAAC;QAChG,OAAQ,KAAK,CAAC,aAAa,CAA6B,IAAI,EAAE,CAAC;IACjE,CAAC;IAED;;;OAGG;IAC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AAK,CAAC,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,72 @@
1
+ import type { AddOn } from "./addon.js";
2
+ import type { Attachable } from "./attachable.js";
3
+ import type { Recipe } from "./recipe.js";
4
+ import type { Entity } from "./entity.js";
5
+ import type { Block } from "./block.js";
6
+ /**
7
+ * Represents an item definition file from the behavior pack's `items/` directory.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const spear = addon.getItem("minecraft:copper_spear");
12
+ * console.log(spear?.getTexturePath()); // "textures/items/spear/copper_spear"
13
+ * console.log(spear?.getAttachable()); // Attachable | null
14
+ * console.log(spear?.getRecipes()); // Recipe[]
15
+ * console.log(spear?.getDroppedByEntities()); // Entity[]
16
+ * console.log(spear?.getDroppedByBlocks()); // Block[]
17
+ * ```
18
+ */
19
+ export declare class Item {
20
+ /** The namespaced item identifier, e.g. `"minecraft:copper_spear"`. */
21
+ readonly identifier: string;
22
+ /** The raw parsed JSON of the item's behavior file. */
23
+ readonly data: Record<string, unknown>;
24
+ /**
25
+ * Absolute path to the item's behavior file on disk.
26
+ * Empty string when loaded from browser `File[]`.
27
+ */
28
+ readonly filePath: string;
29
+ private readonly _addon;
30
+ constructor(identifier: string, data: Record<string, unknown>, filePath: string, addon: AddOn);
31
+ /**
32
+ * Resolves this item's display texture path by reading its `minecraft:icon` component
33
+ * shortname and looking it up in the resource pack's `item_texture.json`.
34
+ *
35
+ * @returns The texture file path (without extension), e.g. `"textures/items/iron_sword"`.
36
+ * Returns null if the item has no icon component or the shortname isn't in item_texture.json.
37
+ */
38
+ getTexturePath(): string | null;
39
+ /**
40
+ * Returns the attachable definition for this item, or null if no attachable exists.
41
+ */
42
+ getAttachable(): Attachable | null;
43
+ /**
44
+ * Returns all recipes in the addon whose result matches this item's identifier.
45
+ */
46
+ getRecipes(): Recipe[];
47
+ /**
48
+ * Returns all entities that can drop this item, by searching every entity's
49
+ * loot tables for entries matching this item's identifier.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * addon.getItem("minecraft:rotten_flesh")?.getDroppedByEntities();
54
+ * // [Entity<"minecraft:zombie">, Entity<"minecraft:drowned">, ...]
55
+ * ```
56
+ */
57
+ getDroppedByEntities(): Entity[];
58
+ /**
59
+ * Returns all blocks that can drop this item, by resolving each block's
60
+ * `minecraft:loot` component and checking if this item appears in it.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * addon.getItem("minecraft:diamond")?.getDroppedByBlocks();
65
+ * // [Block<"minecraft:diamond_ore">, ...]
66
+ * ```
67
+ */
68
+ getDroppedByBlocks(): Block[];
69
+ private _getComponents;
70
+ private _extractIcon;
71
+ }
72
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../src/internal/item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,qBAAa,IAAI;IACf,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,uDAAuD;IACvD,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,IAAI,MAAM,GAAG,IAAI;IAW/B;;OAEG;IACH,aAAa,IAAI,UAAU,GAAG,IAAI;IAIlC;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;IAItB;;;;;;;;;OASG;IACH,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;;;;;;;;OASG;IACH,kBAAkB,IAAI,KAAK,EAAE;IAO7B,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;CAYrB"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Represents an item definition file from the behavior pack's `items/` directory.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const spear = addon.getItem("minecraft:copper_spear");
7
+ * console.log(spear?.getTexturePath()); // "textures/items/spear/copper_spear"
8
+ * console.log(spear?.getAttachable()); // Attachable | null
9
+ * console.log(spear?.getRecipes()); // Recipe[]
10
+ * console.log(spear?.getDroppedByEntities()); // Entity[]
11
+ * console.log(spear?.getDroppedByBlocks()); // Block[]
12
+ * ```
13
+ */
14
+ export class Item {
15
+ constructor(identifier, data, filePath, addon) {
16
+ this.identifier = identifier;
17
+ this.data = data;
18
+ this.filePath = filePath;
19
+ this._addon = addon;
20
+ }
21
+ /**
22
+ * Resolves this item's display texture path by reading its `minecraft:icon` component
23
+ * shortname and looking it up in the resource pack's `item_texture.json`.
24
+ *
25
+ * @returns The texture file path (without extension), e.g. `"textures/items/iron_sword"`.
26
+ * Returns null if the item has no icon component or the shortname isn't in item_texture.json.
27
+ */
28
+ getTexturePath() {
29
+ const textures = this._addon.itemTextures;
30
+ if (!textures)
31
+ return null;
32
+ const icon = this._extractIcon(this._getComponents());
33
+ if (!icon)
34
+ return null;
35
+ const entry = textures.texture_data[icon];
36
+ if (!entry)
37
+ return null;
38
+ const tex = entry.textures;
39
+ return Array.isArray(tex) ? (tex[0] ?? null) : tex;
40
+ }
41
+ /**
42
+ * Returns the attachable definition for this item, or null if no attachable exists.
43
+ */
44
+ getAttachable() {
45
+ return this._addon.getAttachable(this.identifier);
46
+ }
47
+ /**
48
+ * Returns all recipes in the addon whose result matches this item's identifier.
49
+ */
50
+ getRecipes() {
51
+ return this._addon.getAllRecipes().filter((r) => r.getResultStack()?.identifier === this.identifier);
52
+ }
53
+ /**
54
+ * Returns all entities that can drop this item, by searching every entity's
55
+ * loot tables for entries matching this item's identifier.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * addon.getItem("minecraft:rotten_flesh")?.getDroppedByEntities();
60
+ * // [Entity<"minecraft:zombie">, Entity<"minecraft:drowned">, ...]
61
+ * ```
62
+ */
63
+ getDroppedByEntities() {
64
+ return this._addon.getAllEntities().filter((entity) => entity.getLootTables().some((lt) => lt.getItemIdentifiers().includes(this.identifier)));
65
+ }
66
+ /**
67
+ * Returns all blocks that can drop this item, by resolving each block's
68
+ * `minecraft:loot` component and checking if this item appears in it.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * addon.getItem("minecraft:diamond")?.getDroppedByBlocks();
73
+ * // [Block<"minecraft:diamond_ore">, ...]
74
+ * ```
75
+ */
76
+ getDroppedByBlocks() {
77
+ return this._addon.getAllBlocks().filter((block) => {
78
+ const lt = block.getLootTable();
79
+ return lt !== null && lt.getItemIdentifiers().includes(this.identifier);
80
+ });
81
+ }
82
+ _getComponents() {
83
+ const itemDef = this.data["minecraft:item"] ?? {};
84
+ return itemDef["components"] ?? {};
85
+ }
86
+ _extractIcon(components) {
87
+ const iconComp = components["minecraft:icon"];
88
+ if (!iconComp)
89
+ return null;
90
+ if (typeof iconComp === "string")
91
+ return iconComp;
92
+ if (typeof iconComp === "object") {
93
+ const ic = iconComp;
94
+ if (typeof ic["texture"] === "string")
95
+ return ic["texture"];
96
+ const textures = ic["textures"];
97
+ if (textures?.default)
98
+ return textures.default;
99
+ }
100
+ return null;
101
+ }
102
+ }
103
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../../src/internal/item.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG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AAC,OAAO,CAAC;QACjD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ import type { Item } from "./item.js";
2
+ import type { AddOn } from "./addon.js";
3
+ /**
4
+ * Represents a recipe output — an item definition paired with the number of
5
+ * items produced. Bedrock recipes can yield more than one of an item, e.g.
6
+ * a shaped recipe for `minecraft:stick` produces 4.
7
+ *
8
+ * `item` is null when the result identifier exists in the recipe file but has
9
+ * no corresponding item definition in the behavior pack.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const stack = addon.getRecipesFor("minecraft:stick")[0]?.getResultStack();
14
+ * console.log(stack?.item?.identifier); // "minecraft:stick"
15
+ * console.log(stack?.count); // 4
16
+ * ```
17
+ */
18
+ export declare class ItemStack {
19
+ /** The resolved item definition, or null if not found in the addon. */
20
+ readonly item: Item | null;
21
+ /** The raw identifier string from the recipe file, e.g. `"minecraft:stick"`. */
22
+ readonly identifier: string;
23
+ /** How many items this recipe produces. Always at least 1. */
24
+ readonly count: number;
25
+ constructor(identifier: string, count: number, addon: AddOn);
26
+ }
27
+ //# sourceMappingURL=itemStack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itemStack.d.ts","sourceRoot":"","sources":["../../src/internal/itemStack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAS;IACpB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC3B,gFAAgF;IAChF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAK5D"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Represents a recipe output — an item definition paired with the number of
3
+ * items produced. Bedrock recipes can yield more than one of an item, e.g.
4
+ * a shaped recipe for `minecraft:stick` produces 4.
5
+ *
6
+ * `item` is null when the result identifier exists in the recipe file but has
7
+ * no corresponding item definition in the behavior pack.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const stack = addon.getRecipesFor("minecraft:stick")[0]?.getResultStack();
12
+ * console.log(stack?.item?.identifier); // "minecraft:stick"
13
+ * console.log(stack?.count); // 4
14
+ * ```
15
+ */
16
+ export class ItemStack {
17
+ constructor(identifier, count, addon) {
18
+ this.identifier = identifier;
19
+ this.count = count;
20
+ this.item = addon.getItem(identifier);
21
+ }
22
+ }
23
+ //# sourceMappingURL=itemStack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"itemStack.js","sourceRoot":"","sources":["../../src/internal/itemStack.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,SAAS;IAQpB,YAAY,UAAkB,EAAE,KAAa,EAAE,KAAY;QACzD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ import type { LootEntry, LootPool } from "./types.js";
2
+ export type { LootEntry, LootPool };
3
+ /**
4
+ * Represents a loot table file from the behavior pack's `loot_tables/` directory.
5
+ * Loot tables define what items drop from entities, blocks, or chests.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const lt = addon.getLootTableByPath("loot_tables/entities/zombie.json");
10
+ * console.log(lt?.getItemIdentifiers()); // ["minecraft:rotten_flesh", ...]
11
+ * ```
12
+ */
13
+ export declare class LootTable {
14
+ /** The raw parsed JSON of the loot table file. */
15
+ readonly data: Record<string, unknown>;
16
+ /**
17
+ * Absolute path to the loot table file on disk.
18
+ * Empty string when loaded from browser `File[]`.
19
+ */
20
+ readonly filePath: string;
21
+ /** Path relative to the behavior pack root, e.g. `"loot_tables/entities/zombie.json"`. */
22
+ readonly relativePath: string;
23
+ /** The parsed list of loot pools. Each pool rolls independently. */
24
+ readonly pools: LootPool[];
25
+ constructor(data: Record<string, unknown>, filePath: string, relativePath: string);
26
+ /**
27
+ * Returns a flat, deduplicated list of all item identifiers that can drop
28
+ * from this loot table. Only includes entries of type `"item"`.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * lt.getItemIdentifiers(); // ["minecraft:rotten_flesh", "minecraft:iron_ingot"]
33
+ * ```
34
+ */
35
+ getItemIdentifiers(): string[];
36
+ private _parsePools;
37
+ }
38
+ //# sourceMappingURL=lootTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lootTable.d.ts","sourceRoot":"","sources":["../../src/internal/lootTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;AAEpC;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0FAA0F;IAC1F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC;gBAEf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAOjF;;;;;;;;OAQG;IACH,kBAAkB,IAAI,MAAM,EAAE;IAQ9B,OAAO,CAAC,WAAW;CAoBpB"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Represents a loot table file from the behavior pack's `loot_tables/` directory.
3
+ * Loot tables define what items drop from entities, blocks, or chests.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const lt = addon.getLootTableByPath("loot_tables/entities/zombie.json");
8
+ * console.log(lt?.getItemIdentifiers()); // ["minecraft:rotten_flesh", ...]
9
+ * ```
10
+ */
11
+ export class LootTable {
12
+ constructor(data, filePath, relativePath) {
13
+ this.data = data;
14
+ this.filePath = filePath;
15
+ this.relativePath = relativePath;
16
+ this.pools = this._parsePools(data);
17
+ }
18
+ /**
19
+ * Returns a flat, deduplicated list of all item identifiers that can drop
20
+ * from this loot table. Only includes entries of type `"item"`.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * lt.getItemIdentifiers(); // ["minecraft:rotten_flesh", "minecraft:iron_ingot"]
25
+ * ```
26
+ */
27
+ getItemIdentifiers() {
28
+ const ids = [];
29
+ for (const pool of this.pools)
30
+ for (const entry of pool.entries)
31
+ if (entry.type === "item" && entry.name)
32
+ ids.push(entry.name);
33
+ return [...new Set(ids)];
34
+ }
35
+ _parsePools(data) {
36
+ const raw = data["pools"];
37
+ if (!Array.isArray(raw))
38
+ return [];
39
+ return raw.map((p) => {
40
+ const pool = p;
41
+ const entries = [];
42
+ if (Array.isArray(pool["entries"])) {
43
+ for (const e of pool["entries"]) {
44
+ entries.push({
45
+ type: e["type"] ?? "item",
46
+ name: e["name"] ?? null,
47
+ weight: e["weight"] ?? 1,
48
+ functions: Array.isArray(e["functions"])
49
+ ? e["functions"] : [],
50
+ });
51
+ }
52
+ }
53
+ return { rolls: pool["rolls"], entries };
54
+ });
55
+ }
56
+ }
57
+ //# sourceMappingURL=lootTable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lootTable.js","sourceRoot":"","sources":["../../src/internal/lootTable.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IAapB,YAAY,IAA6B,EAAE,QAAgB,EAAE,YAA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AC;wBACpC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;4BACtC,CAAC,CAAE,CAAC,CAAC,WAAW,CAA+B,CAAC,CAAC,CAAC,EAAE;qBACvD,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAsB,EAAE,OAAO,EAAE,CAAC;QAChE,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Represents a particle effect definition from the resource pack's `particles/` directory.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const particle = addon.getParticle("minecraft:stunned_emitter");
7
+ * console.log(particle?.texturePath); // "textures/particle/particles"
8
+ * ```
9
+ */
10
+ export declare class Particle {
11
+ /** The namespaced particle identifier, e.g. `"minecraft:stunned_emitter"`. */
12
+ readonly identifier: string;
13
+ /** The raw parsed JSON of the particle file. */
14
+ readonly data: Record<string, unknown>;
15
+ /**
16
+ * Absolute path to the particle file on disk.
17
+ * Empty string when loaded from browser `File[]`.
18
+ */
19
+ readonly filePath: string;
20
+ constructor(identifier: string, data: Record<string, unknown>, filePath: string);
21
+ private get _description();
22
+ /**
23
+ * The texture path used by this particle effect, as defined in `basic_render_parameters.texture`.
24
+ * e.g. `"textures/particle/particles"`. Returns null if not specified.
25
+ */
26
+ get texturePath(): string | null;
27
+ /**
28
+ * The material used by this particle effect, as defined in `basic_render_parameters.material`.
29
+ * e.g. `"particles_alpha"`. Returns null if not specified.
30
+ */
31
+ get material(): string | null;
32
+ /** The full components object for this particle effect. */
33
+ get components(): Record<string, unknown>;
34
+ }
35
+ //# sourceMappingURL=particle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"particle.d.ts","sourceRoot":"","sources":["../../src/internal/particle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,qBAAa,QAAQ;IACnB,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,gDAAgD;IAChD,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;;;OAGG;IACH,IAAI,WAAW,IAAI,MAAM,GAAG,IAAI,CAG/B;IAED;;;OAGG;IACH,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAG5B;IAED,2DAA2D;IAC3D,IAAI,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGxC;CACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Represents a particle effect definition from the resource pack's `particles/` directory.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const particle = addon.getParticle("minecraft:stunned_emitter");
7
+ * console.log(particle?.texturePath); // "textures/particle/particles"
8
+ * ```
9
+ */
10
+ export class Particle {
11
+ constructor(identifier, data, filePath) {
12
+ this.identifier = identifier;
13
+ this.data = data;
14
+ this.filePath = filePath;
15
+ }
16
+ get _description() {
17
+ const inner = this.data["particle_effect"] ?? {};
18
+ return inner["description"] ?? {};
19
+ }
20
+ /**
21
+ * The texture path used by this particle effect, as defined in `basic_render_parameters.texture`.
22
+ * e.g. `"textures/particle/particles"`. Returns null if not specified.
23
+ */
24
+ get texturePath() {
25
+ const params = this._description["basic_render_parameters"];
26
+ return params?.["texture"] ?? null;
27
+ }
28
+ /**
29
+ * The material used by this particle effect, as defined in `basic_render_parameters.material`.
30
+ * e.g. `"particles_alpha"`. Returns null if not specified.
31
+ */
32
+ get material() {
33
+ const params = this._description["basic_render_parameters"];
34
+ return params?.["material"] ?? null;
35
+ }
36
+ /** The full components object for this particle effect. */
37
+ get components() {
38
+ const inner = this.data["particle_effect"] ?? {};
39
+ return inner["components"] ?? {};
40
+ }
41
+ }
42
+ //# sourceMappingURL=particle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"particle.js","sourceRoot":"","sources":["../../src/internal/particle.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,OAAO,QAAQ;IAWnB,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,iBAAiB,CAA6B,IAAI,EAAE,CAAC;QAC9E,OAAQ,KAAK,CAAC,aAAa,CAA6B,IAAI,EAAE,CAAC;IACjE,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAwC,CAAC;QACnG,OAAQ,MAAM,EAAE,CAAC,SAAS,CAAY,IAAI,IAAI,CAAC;IACjD,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAwC,CAAC;QACnG,OAAQ,MAAM,EAAE,CAAC,UAAU,CAAY,IAAI,IAAI,CAAC;IAClD,CAAC;IAED,2DAA2D;IAC3D,IAAI,UAAU;QACZ,MAAM,KAAK,GAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAA6B,IAAI,EAAE,CAAC;QAC9E,OAAQ,KAAK,CAAC,YAAY,CAA6B,IAAI,EAAE,CAAC;IAChE,CAAC;CACF"}