@adeficior/data-modifier 1.0.0-rc.12 → 1.0.0-rc.14

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 (233) hide show
  1. package/dist/common/id.d.ts +1 -0
  2. package/dist/common/id.js +4 -0
  3. package/dist/common/id.js.map +1 -1
  4. package/dist/common/ingredient/filter.d.ts +6 -0
  5. package/dist/common/ingredient/filter.js +97 -0
  6. package/dist/common/ingredient/filter.js.map +1 -0
  7. package/dist/common/ingredient/index.d.ts +74 -0
  8. package/dist/common/ingredient/index.js +112 -0
  9. package/dist/common/ingredient/index.js.map +1 -0
  10. package/dist/common/ingredient/input.d.ts +3 -0
  11. package/dist/common/ingredient/input.js +1 -0
  12. package/dist/common/ingredient/input.js.map +1 -0
  13. package/dist/common/ingredient/serializer.d.ts +17 -0
  14. package/dist/common/ingredient/serializer.js +112 -0
  15. package/dist/common/ingredient/serializer.js.map +1 -0
  16. package/dist/common/predicates.d.ts +2 -1
  17. package/dist/common/predicates.js.map +1 -1
  18. package/dist/common/result/filter.d.ts +6 -0
  19. package/dist/common/result/filter.js +68 -0
  20. package/dist/common/result/filter.js.map +1 -0
  21. package/dist/common/result/index.d.ts +41 -0
  22. package/dist/common/result/index.js +59 -0
  23. package/dist/common/result/index.js.map +1 -0
  24. package/dist/common/result/input.d.ts +3 -0
  25. package/dist/common/result/input.js +1 -0
  26. package/dist/common/result/input.js.map +1 -0
  27. package/dist/common/result/serializer.d.ts +15 -0
  28. package/dist/common/result/serializer.js +81 -0
  29. package/dist/common/result/serializer.js.map +1 -0
  30. package/dist/common/serializable.d.ts +6 -0
  31. package/dist/common/serializable.js +1 -0
  32. package/dist/common/serializable.js.map +1 -0
  33. package/dist/common/units.d.ts +1 -0
  34. package/dist/common/units.js +2 -0
  35. package/dist/common/units.js.map +1 -0
  36. package/dist/emit/blacklist.d.ts +4 -6
  37. package/dist/emit/blacklist.js +19 -21
  38. package/dist/emit/blacklist.js.map +1 -1
  39. package/dist/emit/data/loot.d.ts +6 -8
  40. package/dist/emit/data/loot.js +11 -13
  41. package/dist/emit/data/loot.js.map +1 -1
  42. package/dist/emit/data/recipe.d.ts +20 -18
  43. package/dist/emit/data/recipe.js +40 -29
  44. package/dist/emit/data/recipe.js.map +1 -1
  45. package/dist/emit/data/tags.d.ts +1 -1
  46. package/dist/emit/data/tags.js.map +1 -1
  47. package/dist/emit/polytoneTabs.d.ts +1 -1
  48. package/dist/emit/polytoneTabs.js +1 -2
  49. package/dist/emit/polytoneTabs.js.map +1 -1
  50. package/dist/emit/rule/lootTable.d.ts +2 -1
  51. package/dist/emit/rule/lootTable.js +4 -2
  52. package/dist/emit/rule/lootTable.js.map +1 -1
  53. package/dist/emit/rule/recipe.d.ts +7 -5
  54. package/dist/emit/rule/recipe.js.map +1 -1
  55. package/dist/emit/ruled.d.ts +2 -1
  56. package/dist/emit/ruled.js +5 -2
  57. package/dist/emit/ruled.js.map +1 -1
  58. package/dist/index.d.ts +0 -4
  59. package/dist/index.js +0 -2
  60. package/dist/index.js.map +1 -1
  61. package/dist/loader/context.d.ts +12 -0
  62. package/dist/loader/context.js +1 -0
  63. package/dist/loader/context.js.map +1 -0
  64. package/dist/loader/pack.d.ts +13 -7
  65. package/dist/loader/pack.js +43 -25
  66. package/dist/loader/pack.js.map +1 -1
  67. package/dist/loader/recipe.d.ts +9 -5
  68. package/dist/loader/recipe.js +39 -48
  69. package/dist/loader/recipe.js.map +1 -1
  70. package/dist/loader/registry/dump.d.ts +0 -2
  71. package/dist/loader/registry/dump.js +0 -11
  72. package/dist/loader/registry/dump.js.map +1 -1
  73. package/dist/loader/registry/index.d.ts +0 -2
  74. package/dist/loader/registry/wrapped.d.ts +13 -0
  75. package/dist/loader/registry/wrapped.js +26 -0
  76. package/dist/loader/registry/wrapped.js.map +1 -0
  77. package/dist/loader/tags.d.ts +1 -1
  78. package/dist/loader/tags.js.map +1 -1
  79. package/dist/parser/adAstra.d.ts +5 -11
  80. package/dist/parser/adAstra.js +5 -5
  81. package/dist/parser/adAstra.js.map +1 -1
  82. package/dist/parser/botania.d.ts +10 -20
  83. package/dist/parser/botania.js +10 -10
  84. package/dist/parser/botania.js.map +1 -1
  85. package/dist/parser/create.d.ts +2 -4
  86. package/dist/parser/create.js +2 -2
  87. package/dist/parser/create.js.map +1 -1
  88. package/dist/parser/index.d.ts +7 -13
  89. package/dist/parser/index.js +7 -7
  90. package/dist/parser/index.js.map +1 -1
  91. package/dist/parser/lootTable.d.ts +7 -6
  92. package/dist/parser/lootTable.js +25 -23
  93. package/dist/parser/lootTable.js.map +1 -1
  94. package/dist/parser/recipe/adAstra/conversion.d.ts +15 -14
  95. package/dist/parser/recipe/adAstra/conversion.js +27 -20
  96. package/dist/parser/recipe/adAstra/conversion.js.map +1 -1
  97. package/dist/parser/recipe/adAstra/hammering.d.ts +3 -17
  98. package/dist/parser/recipe/adAstra/hammering.js +2 -25
  99. package/dist/parser/recipe/adAstra/hammering.js.map +1 -1
  100. package/dist/parser/recipe/adAstra/inputOutput.d.ts +16 -19
  101. package/dist/parser/recipe/adAstra/inputOutput.js +37 -29
  102. package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -1
  103. package/dist/parser/recipe/adAstra/nasaWorkbench.d.ts +3 -19
  104. package/dist/parser/recipe/adAstra/nasaWorkbench.js +2 -28
  105. package/dist/parser/recipe/adAstra/nasaWorkbench.js.map +1 -1
  106. package/dist/parser/recipe/adAstra/spaceStation.d.ts +15 -14
  107. package/dist/parser/recipe/adAstra/spaceStation.js +33 -14
  108. package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -1
  109. package/dist/parser/recipe/botania/apothecary.d.ts +17 -14
  110. package/dist/parser/recipe/botania/apothecary.js +26 -17
  111. package/dist/parser/recipe/botania/apothecary.js.map +1 -1
  112. package/dist/parser/recipe/botania/blocks.d.ts +21 -0
  113. package/dist/parser/recipe/botania/blocks.js +77 -0
  114. package/dist/parser/recipe/botania/blocks.js.map +1 -0
  115. package/dist/parser/recipe/botania/brew.d.ts +13 -12
  116. package/dist/parser/recipe/botania/brew.js +16 -11
  117. package/dist/parser/recipe/botania/brew.js.map +1 -1
  118. package/dist/parser/recipe/botania/elvenTrade.d.ts +8 -13
  119. package/dist/parser/recipe/botania/elvenTrade.js +11 -22
  120. package/dist/parser/recipe/botania/elvenTrade.js.map +1 -1
  121. package/dist/parser/recipe/botania/gogWrapper.d.ts +12 -12
  122. package/dist/parser/recipe/botania/gogWrapper.js +14 -15
  123. package/dist/parser/recipe/botania/gogWrapper.js.map +1 -1
  124. package/dist/parser/recipe/botania/manaInfusion.d.ts +18 -15
  125. package/dist/parser/recipe/botania/manaInfusion.js +29 -21
  126. package/dist/parser/recipe/botania/manaInfusion.js.map +1 -1
  127. package/dist/parser/recipe/botania/nbtWrapper.d.ts +12 -12
  128. package/dist/parser/recipe/botania/nbtWrapper.js +12 -13
  129. package/dist/parser/recipe/botania/nbtWrapper.js.map +1 -1
  130. package/dist/parser/recipe/botania/orechid.d.ts +3 -30
  131. package/dist/parser/recipe/botania/orechid.js +2 -72
  132. package/dist/parser/recipe/botania/orechid.js.map +1 -1
  133. package/dist/parser/recipe/botania/pureDaisy.d.ts +3 -18
  134. package/dist/parser/recipe/botania/pureDaisy.js +2 -28
  135. package/dist/parser/recipe/botania/pureDaisy.js.map +1 -1
  136. package/dist/parser/recipe/botania/runicAltar.d.ts +8 -13
  137. package/dist/parser/recipe/botania/runicAltar.js +11 -22
  138. package/dist/parser/recipe/botania/runicAltar.js.map +1 -1
  139. package/dist/parser/recipe/botania/terraPlate.d.ts +4 -16
  140. package/dist/parser/recipe/botania/terraPlate.js +2 -25
  141. package/dist/parser/recipe/botania/terraPlate.js.map +1 -1
  142. package/dist/parser/recipe/create/assembly.d.ts +18 -17
  143. package/dist/parser/recipe/create/assembly.js +28 -28
  144. package/dist/parser/recipe/create/assembly.js.map +1 -1
  145. package/dist/parser/recipe/create/processing.d.ts +4 -16
  146. package/dist/parser/recipe/create/processing.js +2 -25
  147. package/dist/parser/recipe/create/processing.js.map +1 -1
  148. package/dist/parser/recipe/farmersdelight/cooking.d.ts +16 -12
  149. package/dist/parser/recipe/farmersdelight/cooking.js +27 -15
  150. package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -1
  151. package/dist/parser/recipe/farmersdelight/cutting.d.ts +14 -15
  152. package/dist/parser/recipe/farmersdelight/cutting.js +32 -29
  153. package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -1
  154. package/dist/parser/recipe/forge/conditional.d.ts +11 -11
  155. package/dist/parser/recipe/forge/conditional.js +17 -21
  156. package/dist/parser/recipe/forge/conditional.js.map +1 -1
  157. package/dist/parser/recipe/index.d.ts +36 -13
  158. package/dist/parser/recipe/index.js +38 -5
  159. package/dist/parser/recipe/index.js.map +1 -1
  160. package/dist/parser/recipe/ingredientMap.d.ts +12 -0
  161. package/dist/parser/recipe/ingredientMap.js +17 -0
  162. package/dist/parser/recipe/ingredientMap.js.map +1 -0
  163. package/dist/parser/recipe/manyToMany.d.ts +20 -0
  164. package/dist/parser/recipe/manyToMany.js +33 -0
  165. package/dist/parser/recipe/manyToMany.js.map +1 -0
  166. package/dist/parser/recipe/manyToOne.d.ts +20 -0
  167. package/dist/parser/recipe/manyToOne.js +33 -0
  168. package/dist/parser/recipe/manyToOne.js.map +1 -0
  169. package/dist/parser/recipe/oneToOne.d.ts +20 -0
  170. package/dist/parser/recipe/oneToOne.js +33 -0
  171. package/dist/parser/recipe/oneToOne.js.map +1 -0
  172. package/dist/parser/recipe/roots/component.d.ts +13 -12
  173. package/dist/parser/recipe/roots/component.js +16 -11
  174. package/dist/parser/recipe/roots/component.js.map +1 -1
  175. package/dist/parser/recipe/roots/ritual.d.ts +14 -16
  176. package/dist/parser/recipe/roots/ritual.js +18 -25
  177. package/dist/parser/recipe/roots/ritual.js.map +1 -1
  178. package/dist/parser/recipe/sullys/polishing.d.ts +4 -16
  179. package/dist/parser/recipe/sullys/polishing.js +2 -25
  180. package/dist/parser/recipe/sullys/polishing.js.map +1 -1
  181. package/dist/parser/recipe/thermal/catalyst.d.ts +13 -12
  182. package/dist/parser/recipe/thermal/catalyst.js +16 -11
  183. package/dist/parser/recipe/thermal/catalyst.js.map +1 -1
  184. package/dist/parser/recipe/thermal/fuel.d.ts +13 -12
  185. package/dist/parser/recipe/thermal/fuel.js +17 -11
  186. package/dist/parser/recipe/thermal/fuel.js.map +1 -1
  187. package/dist/parser/recipe/thermal/index.d.ts +16 -14
  188. package/dist/parser/recipe/thermal/index.js +35 -24
  189. package/dist/parser/recipe/thermal/index.js.map +1 -1
  190. package/dist/parser/recipe/thermal/ingredient.d.ts +4 -21
  191. package/dist/parser/recipe/thermal/ingredient.js +40 -33
  192. package/dist/parser/recipe/thermal/ingredient.js.map +1 -1
  193. package/dist/parser/recipe/thermal/treeExtraction.d.ts +17 -17
  194. package/dist/parser/recipe/thermal/treeExtraction.js +30 -31
  195. package/dist/parser/recipe/thermal/treeExtraction.js.map +1 -1
  196. package/dist/parser/recipe/vanilla/shaped.d.ts +17 -13
  197. package/dist/parser/recipe/vanilla/shaped.js +21 -16
  198. package/dist/parser/recipe/vanilla/shaped.js.map +1 -1
  199. package/dist/parser/recipe/vanilla/shapeless.d.ts +3 -17
  200. package/dist/parser/recipe/vanilla/shapeless.js +2 -25
  201. package/dist/parser/recipe/vanilla/shapeless.js.map +1 -1
  202. package/dist/parser/recipe/vanilla/smelting.d.ts +16 -13
  203. package/dist/parser/recipe/vanilla/smelting.js +21 -15
  204. package/dist/parser/recipe/vanilla/smelting.js.map +1 -1
  205. package/dist/parser/recipe/vanilla/smithing.d.ts +18 -14
  206. package/dist/parser/recipe/vanilla/smithing.js +25 -16
  207. package/dist/parser/recipe/vanilla/smithing.js.map +1 -1
  208. package/dist/parser/recipe/vanilla/stonecutting.d.ts +15 -13
  209. package/dist/parser/recipe/vanilla/stonecutting.js +22 -24
  210. package/dist/parser/recipe/vanilla/stonecutting.js.map +1 -1
  211. package/dist/parser/roots.d.ts +2 -4
  212. package/dist/parser/roots.js +2 -2
  213. package/dist/parser/roots.js.map +1 -1
  214. package/dist/parser/thermal.d.ts +4 -10
  215. package/dist/parser/thermal.js +4 -5
  216. package/dist/parser/thermal.js.map +1 -1
  217. package/dist/schema/data/recipe.d.ts +2 -1
  218. package/package.json +2 -1
  219. package/dist/common/ingredient.d.ts +0 -49
  220. package/dist/common/ingredient.js +0 -108
  221. package/dist/common/ingredient.js.map +0 -1
  222. package/dist/common/result.d.ts +0 -48
  223. package/dist/common/result.js +0 -37
  224. package/dist/common/result.js.map +0 -1
  225. package/dist/parser/recipe/adAstra/index.d.ts +0 -5
  226. package/dist/parser/recipe/adAstra/index.js +0 -1
  227. package/dist/parser/recipe/adAstra/index.js.map +0 -1
  228. package/dist/parser/recipe/ignored.d.ts +0 -10
  229. package/dist/parser/recipe/ignored.js +0 -16
  230. package/dist/parser/recipe/ignored.js.map +0 -1
  231. package/dist/parser/recipe/quark/exclusion.d.ts +0 -20
  232. package/dist/parser/recipe/quark/exclusion.js +0 -32
  233. package/dist/parser/recipe/quark/exclusion.js.map +0 -1
@@ -1,28 +1,37 @@
1
- import RecipeParser, { Recipe } from "../index.js";
1
+ import RecipeParser, { Recipe, } from "../index.js";
2
2
  export class ApothecaryRecipe extends Recipe {
3
+ ingredients;
4
+ result;
5
+ reagent;
6
+ constructor(ingredients, result, reagent) {
7
+ super();
8
+ this.ingredients = ingredients;
9
+ this.result = result;
10
+ this.reagent = reagent;
11
+ }
3
12
  getIngredients() {
4
- return [...this.definition.ingredients, this.definition.reagent];
13
+ return [...this.ingredients, this.reagent];
5
14
  }
6
15
  getResults() {
7
- return [this.definition.output];
16
+ return [this.result];
8
17
  }
9
- replaceIngredient(replace) {
10
- return new ApothecaryRecipe({
11
- ...this.definition,
12
- reagent: replace(this.definition.reagent),
13
- ingredients: this.definition.ingredients.map(replace),
14
- });
18
+ replace(ingredientReplacer, resultReplacer) {
19
+ return new ApothecaryRecipe(this.ingredients.map(ingredientReplacer), resultReplacer(this.result), ingredientReplacer(this.reagent));
15
20
  }
16
- replaceResult(replace) {
17
- return new ApothecaryRecipe({
18
- ...this.definition,
19
- output: replace(this.definition.output),
20
- });
21
+ serialize(context) {
22
+ return {
23
+ ingredients: context.ingredients.serializeList(this.ingredients),
24
+ output: context.results.serialize(this.result),
25
+ reagent: context.ingredients.serialize(this.reagent),
26
+ };
21
27
  }
22
28
  }
23
- export default class ApothecaryRecipeParser extends RecipeParser {
24
- create(definition) {
25
- return new ApothecaryRecipe(definition);
29
+ export class ApothecaryRecipeParser extends RecipeParser {
30
+ deserialize(definition, context) {
31
+ const ingredients = context.ingredients.createList(definition.ingredients);
32
+ const result = context.results.create(definition.output);
33
+ const reagent = context.ingredients.create(definition.ingredients);
34
+ return new ApothecaryRecipe(ingredients, result, reagent);
26
35
  }
27
36
  }
28
37
  //# sourceMappingURL=apothecary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apothecary.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/apothecary.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAenD,MAAM,OAAO,gBAAiB,SAAQ,MAAkC;IACtE,cAAc;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,gBAAgB,CAAC;YAC1B,GAAG,IAAI,CAAC,UAAU;YAClB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;YACzC,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,OAAyB;QACr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AAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9C,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;SACrD,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAG3C;IACC,WAAW,CACT,UAAsC,EACtC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACnE,OAAO,IAAI,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import type { BlockLikeIngredient, Ingredient } from "../../../common/ingredient/index.js";
2
+ import type IngredientSerializer from "../../../common/ingredient/serializer.js";
3
+ import type { Result } from "../../../common/result/index.js";
4
+ import type ResultSerializer from "../../../common/result/serializer.js";
5
+ import type { RecipeDefinition } from "../../../schema/data/recipe.js";
6
+ import RecipeParser, { type RecipeParseContext } from "../index.js";
7
+ import { OneToOneRecipe } from "../oneToOne.js";
8
+ export declare function serializeBlockInput(ingredient: Ingredient): unknown;
9
+ export declare function serializeBlockOutput(result: Result | Ingredient): unknown;
10
+ export declare function deserializeBlockInput(ingredients: IngredientSerializer, input: unknown): BlockLikeIngredient;
11
+ export declare function deserializeBlockOutput(results: ResultSerializer, output: unknown): Result;
12
+ export type BotaniaBlockRecipeDefinition = RecipeDefinition & Readonly<{
13
+ input: unknown;
14
+ output: unknown;
15
+ }>;
16
+ export declare class BotaniaBlockRecipe extends OneToOneRecipe {
17
+ serialize(): Partial<BotaniaBlockRecipeDefinition>;
18
+ }
19
+ export default class BotaniaBlockRecipeParser<TDefinition extends BotaniaBlockRecipeDefinition> extends RecipeParser<TDefinition, BotaniaBlockRecipe> {
20
+ deserialize(definition: TDefinition, context: RecipeParseContext): BotaniaBlockRecipe;
21
+ }
@@ -0,0 +1,77 @@
1
+ import z from "zod";
2
+ import { encodeId, IdSchema } from "../../../common/id.js";
3
+ import { BlockIngredient, BlockTagIngredient, } from "../../../common/ingredient/index.js";
4
+ import { BlockResult } from "../../../common/result/index.js";
5
+ import { IllegalShapeError } from "../../../error.js";
6
+ import RecipeParser, {} from "../index.js";
7
+ import { OneToOneRecipe } from "../oneToOne.js";
8
+ const BlockOutputSchema = z
9
+ .object({
10
+ name: IdSchema,
11
+ })
12
+ .or(IdSchema);
13
+ const BlockInputSchema = z
14
+ .object({
15
+ type: z.literal("block"),
16
+ block: IdSchema,
17
+ })
18
+ .or(z.object({
19
+ type: z.literal("tag"),
20
+ tag: IdSchema,
21
+ }));
22
+ export function serializeBlockInput(ingredient) {
23
+ if (ingredient instanceof BlockIngredient)
24
+ return {
25
+ type: "block",
26
+ block: encodeId(ingredient.id),
27
+ };
28
+ if (ingredient instanceof BlockTagIngredient)
29
+ return {
30
+ type: "tag",
31
+ tag: encodeId(ingredient.tag),
32
+ };
33
+ throw new IllegalShapeError("invalid botania block input ingredient", ingredient);
34
+ }
35
+ export function serializeBlockOutput(result) {
36
+ if (result instanceof BlockResult)
37
+ return {
38
+ name: encodeId(result.id),
39
+ };
40
+ if (result instanceof BlockIngredient)
41
+ return {
42
+ name: encodeId(result.id),
43
+ };
44
+ throw new IllegalShapeError("invalid botania block output result", result);
45
+ }
46
+ export function deserializeBlockInput(ingredients, input) {
47
+ const parsed = BlockInputSchema.parse(input);
48
+ switch (parsed.type) {
49
+ case "block":
50
+ return ingredients.validated(new BlockIngredient(parsed.block));
51
+ case "tag":
52
+ return ingredients.validated(new BlockTagIngredient(parsed.tag));
53
+ default:
54
+ throw new IllegalShapeError(`invalid block input type`, input);
55
+ }
56
+ }
57
+ export function deserializeBlockOutput(results, output) {
58
+ const parsed = BlockOutputSchema.parse(output);
59
+ const id = typeof parsed === "string" ? parsed : parsed.name;
60
+ return results.create(new BlockResult(id));
61
+ }
62
+ export class BotaniaBlockRecipe extends OneToOneRecipe {
63
+ serialize() {
64
+ return {
65
+ output: serializeBlockOutput(this.result),
66
+ input: serializeBlockOutput(this.ingredient),
67
+ };
68
+ }
69
+ }
70
+ export default class BotaniaBlockRecipeParser extends RecipeParser {
71
+ deserialize(definition, context) {
72
+ const ingredient = deserializeBlockInput(context.ingredients, definition.input);
73
+ const result = deserializeBlockOutput(context.results, definition.output);
74
+ return new BotaniaBlockRecipe(ingredient, result);
75
+ }
76
+ }
77
+ //# sourceMappingURL=blocks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,EACL,eAAe,EACf,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,YAAY,EAAE,EAA2B,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,iBAAiB,GAAG,CAAC;KACxB,MAAM,CAAC;IACN,IAAI,EAAE,QAAQ;CACf,CAAC;KACD,EAAE,CAAC,QAAQ,CAAC,CAAC;AAEhB,MAAM,gBAAgB,GAAG,CAAC;KACvB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,EAAE,QAAQ;CAChB,CAAC;KACD,EAAE,C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AC;QACnE;YACE,MAAM,IAAI,iBAAiB,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAyB,EACzB,MAAe;IAEf,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IAC7D,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7C,CAAC;AAQD,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAC3C,SAAS;QAChB,OAAO;YACL,MAAM,EAAE,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC;YACzC,KAAK,EAAE,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC;SAC7C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,wBAEnB,SAAQ,YAA6C;IACrD,WAAW,CACT,UAAuB,EACvB,OAA2B;QAE3B,MAAM,UAAU,GAAG,qBAAqB,CACtC,OAAO,CAAC,WAAW,EACnB,UAAU,CAAC,KAAK,CACjB,CAAC;QACF,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1E,OAAO,IAAI,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -1,18 +1,19 @@
1
- import type { Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
1
+ import type { Ingredient } from "../../../common/ingredient/index.js";
4
2
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { ResultInput } from "../../../common/result.js";
3
+ import type { RecipeParseContext, Replacer } from "../index.js";
4
+ import RecipeParser, { Recipe } from "../index.js";
6
5
  export type BrewRecipeDefinition = RecipeDefinition & Readonly<{
7
- ingredients: Ingredient[];
6
+ ingredients: unknown[];
8
7
  brew: string;
9
8
  }>;
10
- export declare class BrewRecipe extends Recipe<BrewRecipeDefinition> {
11
- getIngredients(): IngredientInput[];
12
- getResults(): ResultInput[];
13
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
14
- replaceResult(): BrewRecipe;
9
+ export declare class BrewRecipe extends Recipe {
10
+ private readonly ingredients;
11
+ constructor(ingredients: Ingredient[]);
12
+ getIngredients(): Ingredient[];
13
+ getResults(): never[];
14
+ replace(ingredientReplacer: Replacer<Ingredient>): BrewRecipe;
15
+ serialize(context: RecipeParseContext): Partial<BrewRecipeDefinition>;
15
16
  }
16
- export default class BrewRecipeParser extends RecipeParser<BrewRecipeDefinition, BrewRecipe> {
17
- create(definition: BrewRecipeDefinition): BrewRecipe;
17
+ export declare class BrewRecipeParser extends RecipeParser<BrewRecipeDefinition, BrewRecipe> {
18
+ deserialize(definition: BrewRecipeDefinition, context: RecipeParseContext): BrewRecipe;
18
19
  }
@@ -1,24 +1,29 @@
1
1
  import RecipeParser, { Recipe } from "../index.js";
2
2
  export class BrewRecipe extends Recipe {
3
+ ingredients;
4
+ constructor(ingredients) {
5
+ super();
6
+ this.ingredients = ingredients;
7
+ }
3
8
  getIngredients() {
4
- return this.definition.ingredients;
9
+ return this.ingredients;
5
10
  }
6
11
  getResults() {
7
12
  return [];
8
13
  }
9
- replaceIngredient(replace) {
10
- return new BrewRecipe({
11
- ...this.definition,
12
- ingredients: this.definition.ingredients.map(replace),
13
- });
14
+ replace(ingredientReplacer) {
15
+ return new BrewRecipe(this.ingredients.map(ingredientReplacer));
14
16
  }
15
- replaceResult() {
16
- return new BrewRecipe(this.definition);
17
+ serialize(context) {
18
+ return {
19
+ ingredients: context.ingredients.serializeList(this.ingredients),
20
+ };
17
21
  }
18
22
  }
19
- export default class BrewRecipeParser extends RecipeParser {
20
- create(definition) {
21
- return new BrewRecipe(definition);
23
+ export class BrewRecipeParser extends RecipeParser {
24
+ deserialize(definition, context) {
25
+ const ingredients = context.ingredients.createList(definition.ingredients);
26
+ return new BrewRecipe(ingredients);
22
27
  }
23
28
  }
24
29
  //# sourceMappingURL=brew.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"brew.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/brew.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcnD,MAAM,OAAO,UAAW,SAAQ,MAA4B;IAC1D,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,UAAU;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,UAAU,CAAC;YACpB,GAAG,IAAI,CAAC,UAAU;YAClB,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED,aAAa;QACX,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,YAG7C;IACC,MAAM,CAAC,UAAgC;QACrC,OAAO,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;CACF"}
1
+ {"version":3,"file":"brew.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/brew.ts"],"names":[],"mappings":"AAGA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQnD,MAAM,OAAO,UAAW,SAAQ,MAAM;IACP;IAA7B,YAA6B,WAAyB;QACpD,KAAK,EAAE,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAc;IAEtD,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;IAEQ,OAAO,CAAC,kBAAwC;QACvD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAClE,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;SACjE,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAGrC;IACC,WAAW,CACT,UAAgC,EAChC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;CACF"}
@@ -1,19 +1,14 @@
1
- import type { Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
4
1
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { Result, ResultInput } from "../../../common/result.js";
2
+ import RecipeParser, { type RecipeParseContext } from "../index.js";
3
+ import { ManyToManyRecipe } from "../manyToMany.js";
6
4
  export type ElvenTradeRecipeDefinition = RecipeDefinition & Readonly<{
7
- ingredients: Ingredient[];
8
- output: Result[];
5
+ ingredients: unknown[];
6
+ output: unknown[];
9
7
  mana?: number;
10
8
  }>;
11
- export declare class ElvenTradeRecipe extends Recipe<ElvenTradeRecipeDefinition> {
12
- getIngredients(): IngredientInput[];
13
- getResults(): ResultInput[];
14
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
15
- replaceResult(replace: Replacer<Result>): Recipe;
9
+ export declare class ElvenTradeRecipe extends ManyToManyRecipe {
10
+ serialize(context: RecipeParseContext): Partial<ElvenTradeRecipeDefinition>;
16
11
  }
17
- export default class ElvenTradeRecipeParser extends RecipeParser<ElvenTradeRecipeDefinition, ElvenTradeRecipe> {
18
- create(definition: ElvenTradeRecipeDefinition): ElvenTradeRecipe;
12
+ export declare class ElvenTradeRecipeParser extends RecipeParser<ElvenTradeRecipeDefinition, ElvenTradeRecipe> {
13
+ deserialize(definition: ElvenTradeRecipeDefinition, context: RecipeParseContext): ElvenTradeRecipe;
19
14
  }
@@ -1,27 +1,16 @@
1
- import RecipeParser, { Recipe } from "../index.js";
2
- export class ElvenTradeRecipe extends Recipe {
3
- getIngredients() {
4
- return this.definition.ingredients;
5
- }
6
- getResults() {
7
- return this.definition.output;
8
- }
9
- replaceIngredient(replace) {
10
- return new ElvenTradeRecipe({
11
- ...this.definition,
12
- ingredients: this.definition.ingredients.map(replace),
13
- });
14
- }
15
- replaceResult(replace) {
16
- return new ElvenTradeRecipe({
17
- ...this.definition,
18
- output: this.definition.output.map(replace),
19
- });
1
+ import RecipeParser, {} from "../index.js";
2
+ import { ManyToManyRecipe } from "../manyToMany.js";
3
+ export class ElvenTradeRecipe extends ManyToManyRecipe {
4
+ serialize(context) {
5
+ const { results, ...rest } = super.serialize(context);
6
+ return { ...rest, output: results };
20
7
  }
21
8
  }
22
- export default class ElvenTradeRecipeParser extends RecipeParser {
23
- create(definition) {
24
- return new ElvenTradeRecipe(definition);
9
+ export class ElvenTradeRecipeParser extends RecipeParser {
10
+ deserialize(definition, context) {
11
+ const ingredients = context.ingredients.createList(definition.ingredients);
12
+ const results = context.results.createList(definition.output);
13
+ return new ElvenTradeRecipe(ingredients, results);
25
14
  }
26
15
  }
27
16
  //# sourceMappingURL=elvenTrade.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"elvenTrade.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/elvenTrade.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAenD,MAAM,OAAO,gBAAiB,SAAQ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,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC9D,OAAO,IAAI,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF"}
@@ -1,22 +1,22 @@
1
- import type { InlineRecipeParser, Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
1
+ import type { Ingredient } from "../../../common/ingredient/index.js";
2
+ import type { Result } from "../../../common/result/index.js";
4
3
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeHolder, RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
6
6
  export type GogWrapperRecipeDefinition = RecipeDefinition & Readonly<{
7
7
  nbt: string;
8
8
  base: RecipeDefinition;
9
9
  gog: RecipeDefinition;
10
10
  }>;
11
- export declare class GogWrapperRecipe extends Recipe<GogWrapperRecipeDefinition> {
11
+ export declare class GogWrapperRecipe extends Recipe {
12
12
  private readonly base;
13
13
  private readonly gog;
14
- constructor(definition: Omit<GogWrapperRecipeDefinition, "base" | "gog">, base: Recipe, gog: Recipe);
15
- getIngredients(): IngredientInput[];
16
- getResults(): ResultInput[];
17
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
18
- replaceResult(replace: Replacer<Result>): Recipe;
14
+ constructor(base: RecipeHolder, gog: RecipeHolder);
15
+ getIngredients(): Ingredient[];
16
+ getResults(): Result[];
17
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): GogWrapperRecipe;
18
+ serialize(context: RecipeParseContext): Partial<GogWrapperRecipeDefinition>;
19
19
  }
20
- export default class GogWrapperRecipeParser extends RecipeParser<GogWrapperRecipeDefinition, GogWrapperRecipe> {
21
- create(definition: GogWrapperRecipeDefinition, parser: InlineRecipeParser): GogWrapperRecipe;
20
+ export declare class GogWrapperRecipeParser extends RecipeParser<GogWrapperRecipeDefinition, GogWrapperRecipe> {
21
+ deserialize(definition: GogWrapperRecipeDefinition, context: RecipeParseContext): GogWrapperRecipe;
22
22
  }
@@ -2,12 +2,8 @@ import RecipeParser, { Recipe } from "../index.js";
2
2
  export class GogWrapperRecipe extends Recipe {
3
3
  base;
4
4
  gog;
5
- constructor(definition, base, gog) {
6
- super({
7
- ...definition,
8
- base: base.toJSON(),
9
- gog: gog.toJSON(),
10
- });
5
+ constructor(base, gog) {
6
+ super();
11
7
  this.base = base;
12
8
  this.gog = gog;
13
9
  }
@@ -17,18 +13,21 @@ export class GogWrapperRecipe extends Recipe {
17
13
  getResults() {
18
14
  return [...this.base.getResults(), ...this.gog.getResults()];
19
15
  }
20
- replaceIngredient(replace) {
21
- return new GogWrapperRecipe(this.definition, this.base.replaceIngredient(replace), this.gog.replaceIngredient(replace));
16
+ replace(ingredientReplacer, resultReplacer) {
17
+ return new GogWrapperRecipe(this.base.replace(ingredientReplacer, resultReplacer), this.gog.replace(ingredientReplacer, resultReplacer));
22
18
  }
23
- replaceResult(replace) {
24
- return new GogWrapperRecipe(this.definition, this.base.replaceResult(replace), this.gog.replaceResult(replace));
19
+ serialize(context) {
20
+ return {
21
+ base: context.recipes.serialize(this.base),
22
+ gog: context.recipes.serialize(this.gog),
23
+ };
25
24
  }
26
25
  }
27
- export default class GogWrapperRecipeParser extends RecipeParser {
28
- create(definition, parser) {
29
- const base = parser(definition.base);
30
- const gog = parser(definition.gog);
31
- return new GogWrapperRecipe(definition, base, gog);
26
+ export class GogWrapperRecipeParser extends RecipeParser {
27
+ deserialize(definition, context) {
28
+ const base = context.recipes.deserialize(definition.base);
29
+ const gog = context.recipes.deserialize(definition.gog);
30
+ return new GogWrapperRecipe(base, gog);
32
31
  }
33
32
  }
34
33
  //# sourceMappingURL=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AC,IAAI,CAAC;YAC1C,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;SACzC,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,YAG3C;IACC,WAAW,CACT,UAAsC,EACtC,OAA2B;QAE3B,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACxD,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -1,21 +1,24 @@
1
- import type { Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
1
+ import type { Ingredient } from "../../../common/ingredient/index.js";
2
+ import type { Result } from "../../../common/result/index.js";
4
3
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { BlockInput } from "./orechid.js";
6
- import type { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
7
6
  export type ManaInfusionRecipeDefinition = RecipeDefinition & Readonly<{
8
- input: Ingredient;
9
- output: Result;
10
- catalyst?: BlockInput;
7
+ input: unknown;
8
+ output: unknown;
9
+ catalyst?: unknown;
11
10
  mana?: number;
12
11
  }>;
13
- export declare class ManaInfusionRecipe extends Recipe<ManaInfusionRecipeDefinition> {
14
- getIngredients(): IngredientInput[];
15
- getResults(): ResultInput[];
16
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
17
- replaceResult(replace: Replacer<Result>): Recipe;
12
+ export declare class ManaInfusionRecipe extends Recipe {
13
+ private readonly ingredient;
14
+ private readonly result;
15
+ private readonly catalyst?;
16
+ constructor(ingredient: Ingredient, result: Result, catalyst?: Ingredient | undefined);
17
+ getIngredients(): Ingredient[];
18
+ getResults(): Result[];
19
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): ManaInfusionRecipe;
20
+ serialize(context: RecipeParseContext): Partial<ManaInfusionRecipeDefinition>;
18
21
  }
19
- export default class ManaInfusionRecipeParser extends RecipeParser<ManaInfusionRecipeDefinition, ManaInfusionRecipe> {
20
- create(definition: ManaInfusionRecipeDefinition): ManaInfusionRecipe;
22
+ export declare class ManaInfusionRecipeParser extends RecipeParser<ManaInfusionRecipeDefinition, ManaInfusionRecipe> {
23
+ deserialize(definition: ManaInfusionRecipeDefinition, context: RecipeParseContext): ManaInfusionRecipe;
21
24
  }
@@ -1,33 +1,41 @@
1
+ import { exists } from "@adeficior/pack-resolver";
1
2
  import RecipeParser, { Recipe } from "../index.js";
2
- import { createBlockInput, fromBlockInput } from "./orechid.js";
3
+ import { deserializeBlockInput, serializeBlockInput } from "./blocks.js";
3
4
  export class ManaInfusionRecipe extends Recipe {
5
+ ingredient;
6
+ result;
7
+ catalyst;
8
+ constructor(ingredient, result, catalyst) {
9
+ super();
10
+ this.ingredient = ingredient;
11
+ this.result = result;
12
+ this.catalyst = catalyst;
13
+ }
4
14
  getIngredients() {
5
- if (!this.definition.catalyst)
6
- return [this.definition.input];
7
- return [fromBlockInput(this.definition.catalyst), this.definition.input];
15
+ return [this.ingredient, this.catalyst].filter(exists);
8
16
  }
9
17
  getResults() {
10
- return [this.definition.output];
18
+ return [this.result];
11
19
  }
12
- replaceIngredient(replace) {
13
- return new ManaInfusionRecipe({
14
- ...this.definition,
15
- input: replace(this.definition.input),
16
- catalyst: (this.definition.catalyst &&
17
- createBlockInput(replace(fromBlockInput(this.definition.catalyst)))) ??
18
- this.definition.catalyst,
19
- });
20
+ replace(ingredientReplacer, resultReplacer) {
21
+ return new ManaInfusionRecipe(ingredientReplacer(this.ingredient), resultReplacer(this.result), this.catalyst && ingredientReplacer(this.catalyst));
20
22
  }
21
- replaceResult(replace) {
22
- return new ManaInfusionRecipe({
23
- ...this.definition,
24
- output: replace(this.definition.output),
25
- });
23
+ serialize(context) {
24
+ return {
25
+ input: context.ingredients.serialize(this.ingredient),
26
+ output: context.results.serialize(this.result),
27
+ catalyst: this.catalyst && serializeBlockInput(this.catalyst),
28
+ };
26
29
  }
27
30
  }
28
- export default class ManaInfusionRecipeParser extends RecipeParser {
29
- create(definition) {
30
- return new ManaInfusionRecipe(definition);
31
+ export class ManaInfusionRecipeParser extends RecipeParser {
32
+ deserialize(definition, context) {
33
+ const catalyst = definition.catalyst === undefined
34
+ ? undefined
35
+ : deserializeBlockInput(context.ingredients, definition.catalyst);
36
+ const ingredient = context.ingredients.create(definition.input);
37
+ const result = context.results.create(definition.output);
38
+ return new ManaInfusionRecipe(ingredient, result, catalyst);
31
39
  }
32
40
  }
33
41
  //# sourceMappingURL=manaInfusion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manaInfusion.js","sourceRoot":"","sources":["../../../../src/parser/recipe/botania/manaInfusion.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOnD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAWhE,MAAM,OAAO,kBAAmB,SAAQ,MAAoC;IAC1E,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ;YAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,kBAAkB,CAAC;Y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ineRecipeParser, Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
1
+ import type { Ingredient } from "../../../common/ingredient/index.js";
2
+ import type { Result } from "../../../common/result/index.js";
4
3
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeHolder, RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
6
6
  export type NbtWrapperRecipeDefinition = RecipeDefinition & Readonly<{
7
7
  nbt: string;
8
8
  recipe: RecipeDefinition;
9
9
  }>;
10
- export declare class NbtWrapperRecipe extends Recipe<NbtWrapperRecipeDefinition> {
10
+ export declare class NbtWrapperRecipe extends Recipe {
11
11
  private readonly recipe;
12
- constructor(definition: Omit<NbtWrapperRecipeDefinition, "recipe">, recipe: Recipe);
13
- getIngredients(): IngredientInput[];
14
- getResults(): ResultInput[];
15
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
16
- replaceResult(replace: Replacer<Result>): Recipe;
12
+ constructor(recipe: RecipeHolder);
13
+ getIngredients(): Ingredient[];
14
+ getResults(): Result[];
15
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): Recipe;
16
+ serialize(context: RecipeParseContext): Partial<NbtWrapperRecipeDefinition>;
17
17
  }
18
- export default class NbtWrapperRecipeParser extends RecipeParser<NbtWrapperRecipeDefinition, NbtWrapperRecipe> {
19
- create(definition: NbtWrapperRecipeDefinition, parser: InlineRecipeParser): NbtWrapperRecipe;
18
+ export declare class NbtWrapperRecipeParser extends RecipeParser<NbtWrapperRecipeDefinition, NbtWrapperRecipe> {
19
+ deserialize(definition: NbtWrapperRecipeDefinition, context: RecipeParseContext): NbtWrapperRecipe;
20
20
  }
@@ -1,11 +1,8 @@
1
1
  import RecipeParser, { Recipe } from "../index.js";
2
2
  export class NbtWrapperRecipe extends Recipe {
3
3
  recipe;
4
- constructor(definition, recipe) {
5
- super({
6
- ...definition,
7
- recipe: recipe.toJSON(),
8
- });
4
+ constructor(recipe) {
5
+ super();
9
6
  this.recipe = recipe;
10
7
  }
11
8
  getIngredients() {
@@ -14,17 +11,19 @@ export class NbtWrapperRecipe extends Recipe {
14
11
  getResults() {
15
12
  return this.recipe.getResults();
16
13
  }
17
- replaceIngredient(replace) {
18
- return new NbtWrapperRecipe(this.definition, this.recipe.replaceIngredient(replace));
14
+ replace(ingredientReplacer, resultReplacer) {
15
+ return new NbtWrapperRecipe(this.recipe.replace(ingredientReplacer, resultReplacer));
19
16
  }
20
- replaceResult(replace) {
21
- return new NbtWrapperRecipe(this.definition, this.recipe.replaceResult(replace));
17
+ serialize(context) {
18
+ return {
19
+ recipe: context.recipes.serialize(this.recipe),
20
+ };
22
21
  }
23
22
  }
24
- export default class NbtWrapperRecipeParser extends RecipeParser {
25
- create(definition, parser) {
26
- const recipe = parser(definition.recipe);
27
- return new NbtWrapperRecipe(definition, recipe);
23
+ export class NbtWrapperRecipeParser extends RecipeParser {
24
+ deserialize(definition, context) {
25
+ const recipe = context.recipes.deserialize(definition.recipe);
26
+ return new NbtWrapperRecipe(recipe);
28
27
  }
29
28
  }
30
29
  //# sourceMappingURL=nbtWrapper.js.map