@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,43 +1,50 @@
1
- import { omit } from "lodash-es";
2
- import zod from "zod";
3
- import { createIngredient, ItemTagSchema } from "../../../common/ingredient.js";
4
- import { ItemStackSchema } from "../../../common/result.js";
1
+ import z from "zod";
2
+ import { encodeId, IdSchema } from "../../../common/id.js";
3
+ import { FluidTagIngredient, ItemIngredient, ItemTagIngredient, } from "../../../common/ingredient/index.js";
5
4
  import { IllegalShapeError } from "../../../error.js";
6
- const ThermalFluidTagSchema = zod.object({
7
- fluid_tag: zod.string(),
8
- amount: zod.number(),
5
+ const ThermalFluidTagSchema = z.object({
6
+ fluid_tag: z.string(),
7
+ amount: z.number(),
9
8
  });
10
- function fromThermalList(input) {
11
- return input.value.map((it) => {
12
- if (it && typeof it === "object") {
13
- if ("item" in it)
14
- return { ...ItemStackSchema.parse(it), count: input.count };
15
- if ("tag" in it)
16
- return { ...ItemTagSchema.parse(it), count: input.count };
17
- }
18
- throw new IllegalShapeError("thermal array ingredients may only be of type item/itemtag", it);
19
- });
20
- }
21
- export function fromThermalIngredient(input) {
9
+ const ThermalItemEntry = z.object({
10
+ item: IdSchema,
11
+ });
12
+ const ThermalTagEntry = z.object({
13
+ tag: IdSchema,
14
+ });
15
+ const ThermalIngredientEntry = ThermalItemEntry.or(ThermalTagEntry);
16
+ const ThermalIngredientList = z.object({
17
+ value: z.array(ThermalIngredientEntry),
18
+ count: z.number(),
19
+ });
20
+ // TODO serialize this?
21
+ // type ThermalItemList = z.infer<typeof ThermalIngredientList>;
22
+ export function createThermalIngredients(ingredients, input) {
22
23
  if (input && typeof input === "object") {
23
- if ("value" in input)
24
- return fromThermalList(input);
24
+ if ("value" in input) {
25
+ const parsed = ThermalIngredientList.parse(input);
26
+ return parsed.value.map((it) => {
27
+ if ("item" in it)
28
+ return new ItemIngredient(it.item, parsed.count);
29
+ if ("tag" in it)
30
+ return new ItemTagIngredient(it.tag, parsed.count);
31
+ throw new IllegalShapeError("unknown ingredient list entry shape", it);
32
+ });
33
+ }
25
34
  if ("fluid_tag" in input) {
26
- return { ...omit(input, "fluid_tag"), fluidTag: input.fluid_tag };
35
+ const parsed = ThermalFluidTagSchema.parse(input);
36
+ return [new FluidTagIngredient(parsed.fluid_tag, parsed.amount)];
27
37
  }
28
38
  }
29
- return createIngredient(input);
39
+ return [ingredients.create(input)];
30
40
  }
31
- export function toThermalIngredient(input) {
32
- const resolved = createIngredient(input);
33
- if (typeof resolved === "object") {
34
- if ("fluidTag" in resolved) {
35
- return ThermalFluidTagSchema.parse({
36
- ...omit(resolved, "fluidTag"),
37
- fluid_tag: resolved.fluidTag,
38
- });
39
- }
41
+ export function serializeThermalIngredient(ingredients, ingredient) {
42
+ if (ingredient instanceof FluidTagIngredient) {
43
+ return {
44
+ fluid_tag: encodeId(ingredient.tag),
45
+ amount: ingredient.amount,
46
+ };
40
47
  }
41
- return resolved;
48
+ return ingredients.serialize(ingredient);
42
49
  }
43
50
  //# sourceMappingURL=ingredient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingredient.js","sourceRoot":"","sources":["../../../../src/parser/recipe/thermal/ingredient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,GAAG,MAAM,KAAK,CAAC;AAMtB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,qBAAqB,GAAG,GAAG,CAAC,MAAM,CAAC;IACvC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;IACvB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC;AAcH,SAAS,eAAe,CAAC,KAAsB;IAC7C,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QAC5B,IAAI,EAAE,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,MAAM,IAAI,EAAE;gBACd,OAAO,EAAE,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC9D,IAAI,KAAK,IAAI,EAAE;gBACb,OAAO,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9D,CAAC;QACD,MAAM,IAAI,iBAAiB,CACzB,4DAA4D,EAC5D,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAA6B;IAE7B,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACvC,IAAI,OAAO,IAAI,KAAK;YAAE,OAAO,eAA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AC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,WAAiC,EACjC,UAAsB;IAEtB,IAAI,UAAU,YAAY,kBAAkB,EAAE,CAAC;QAC7C,OAAO;YACL,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;YACnC,MAAM,EAAE,UAAU,CAAC,MAAM;SACA,CAAC;IAC9B,CAAC;IAED,OAAO,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC"}
@@ -1,24 +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 { BlockId } from "@adeficior/data-modifier/generated";
2
+ import { type Ingredient } from "../../../common/ingredient/index.js";
3
+ import type { Result } from "../../../common/result/index.js";
4
4
  import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { ResultInput } from "../../../common/result.js";
6
- type ExtractionBlockInput = string;
5
+ import RecipeParser, { Recipe, type RecipeParseContext, type Replacer } from "../index.js";
7
6
  export type TreeExtractionRecipeDefinition = RecipeDefinition & Readonly<{
8
- leaves: ExtractionBlockInput;
9
- trunk: ExtractionBlockInput;
10
- result: ResultInput;
7
+ leaves: BlockId;
8
+ trunk: BlockId;
9
+ result: unknown;
11
10
  }>;
12
- export declare class TreeExtractionRecipe extends Recipe<TreeExtractionRecipeDefinition> {
11
+ export declare class TreeExtractionRecipe extends Recipe {
13
12
  private readonly trunk;
14
13
  private readonly leaves;
15
- constructor(definition: TreeExtractionRecipeDefinition);
16
- getIngredients(): IngredientInput[];
17
- getResults(): ResultInput[];
18
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
19
- replaceResult(): TreeExtractionRecipe;
14
+ private readonly result;
15
+ constructor(trunk: Ingredient, leaves: Ingredient, result: Result);
16
+ getIngredients(): Ingredient[];
17
+ getResults(): Result[];
18
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): TreeExtractionRecipe;
19
+ private serializeBlockIngredient;
20
+ serialize(context: RecipeParseContext): Partial<TreeExtractionRecipeDefinition>;
20
21
  }
21
- export default class TreeExtractionRecipeParser extends RecipeParser<TreeExtractionRecipeDefinition, TreeExtractionRecipe> {
22
- create(definition: TreeExtractionRecipeDefinition): TreeExtractionRecipe;
22
+ export declare class TreeExtractionRecipeParser extends RecipeParser<TreeExtractionRecipeDefinition, TreeExtractionRecipe> {
23
+ deserialize(definition: TreeExtractionRecipeDefinition, context: RecipeParseContext): TreeExtractionRecipe;
23
24
  }
24
- export {};
@@ -1,47 +1,46 @@
1
- import RecipeParser, { Recipe } from "../index.js";
1
+ import { encodeId } from "../../../common/id.js";
2
+ import { BlockIngredient, } from "../../../common/ingredient/index.js";
2
3
  import { IllegalShapeError } from "../../../error.js";
3
- function blockToIngredient(input) {
4
- if (typeof input !== "string")
5
- throw new IllegalShapeError("unknown block input shape", input);
6
- return {
7
- block: input,
8
- };
9
- }
10
- function ingredientToBlock(input) {
11
- if (input && typeof input === "object") {
12
- if ("block" in input)
13
- return input.block;
14
- }
15
- throw new IllegalShapeError("unknown block input shape", input);
16
- }
4
+ import RecipeParser, { Recipe, } from "../index.js";
17
5
  export class TreeExtractionRecipe extends Recipe {
18
6
  trunk;
19
7
  leaves;
20
- constructor(definition) {
21
- super(definition);
22
- this.trunk = blockToIngredient(definition.trunk);
23
- this.leaves = blockToIngredient(definition.leaves);
8
+ result;
9
+ constructor(trunk, leaves, result) {
10
+ super();
11
+ this.trunk = trunk;
12
+ this.leaves = leaves;
13
+ this.result = result;
24
14
  }
25
15
  getIngredients() {
26
16
  return [this.trunk, this.leaves];
27
17
  }
28
18
  getResults() {
29
- return [];
19
+ return [this.result];
20
+ }
21
+ replace(ingredientReplacer, resultReplacer) {
22
+ return new TreeExtractionRecipe(ingredientReplacer(this.trunk), ingredientReplacer(this.leaves), resultReplacer(this.result));
30
23
  }
31
- replaceIngredient(replace) {
32
- return new TreeExtractionRecipe({
33
- ...this.definition,
34
- leaves: ingredientToBlock(replace(this.leaves)),
35
- trunk: ingredientToBlock(replace(this.trunk)),
36
- });
24
+ serializeBlockIngredient(ingredient) {
25
+ if (ingredient instanceof BlockIngredient) {
26
+ return encodeId(ingredient.id);
27
+ }
28
+ throw new IllegalShapeError("tree extraction recipes ingredients need to be blocks", ingredient);
37
29
  }
38
- replaceResult() {
39
- return new TreeExtractionRecipe(this.definition);
30
+ serialize(context) {
31
+ return {
32
+ result: context.results.serialize(this.result),
33
+ trunk: this.serializeBlockIngredient(this.trunk),
34
+ leaves: this.serializeBlockIngredient(this.leaves),
35
+ };
40
36
  }
41
37
  }
42
- export default class TreeExtractionRecipeParser extends RecipeParser {
43
- create(definition) {
44
- return new TreeExtractionRecipe(definition);
38
+ export class TreeExtractionRecipeParser extends RecipeParser {
39
+ deserialize(definition, context) {
40
+ const trunk = context.ingredients.create(new BlockIngredient(definition.trunk));
41
+ const leaves = context.ingredients.create(new BlockIngredient(definition.leaves));
42
+ const result = context.results.create(definition.result);
43
+ return new TreeExtractionRecipe(trunk, leaves, result);
45
44
  }
46
45
  }
47
46
  //# sourceMappingURL=treeExtraction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeExtraction.js","sourceRoot":"","sources":["../../../../src/parser/recipe/thermal/treeExtraction.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD,SAAS,iBAAiB,CAAC,KAA2B;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAC3B,MAAM,IAAI,iBAAiB,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IAClE,OAAO;QACL,KAAK,EAAE,KAAK;KACb,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAsB;IAC/C,IAAI,KAAK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K,CAAC;YAChD,MAAM,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC;SACnD,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,0BAA2B,SAAQ,YAG/C;IACC,WAAW,CACT,UAA0C,EAC1C,OAA2B;QAE3B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CACtC,IAAI,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,CACtC,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CACvC,IAAI,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CACvC,CAAC;QACF,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,IAAI,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,CAAC;CACF"}
@@ -1,19 +1,23 @@
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 { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
6
+ import type { IngredientMap, IngredientMapInput } from "../ingredientMap.js";
6
7
  export type ShapedRecipeDefinition = RecipeDefinition & Readonly<{
7
- key: Record<string, Ingredient>;
8
+ key: IngredientMapInput;
8
9
  pattern: string[];
9
- result: Result;
10
+ result: unknown;
10
11
  }>;
11
- export declare class ShapedRecipe extends Recipe<ShapedRecipeDefinition> {
12
- getIngredients(): IngredientInput[];
13
- getResults(): ResultInput[];
14
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
15
- replaceResult(replace: Replacer<Result>): Recipe;
12
+ export declare class ShapedRecipe extends Recipe {
13
+ private readonly ingredients;
14
+ private readonly result;
15
+ constructor(ingredients: IngredientMap, result: Result);
16
+ getIngredients(): Ingredient[];
17
+ getResults(): Result[];
18
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): ShapedRecipe;
19
+ serialize(context: RecipeParseContext): Partial<ShapedRecipeDefinition>;
16
20
  }
17
- export default class ShapedParser extends RecipeParser<ShapedRecipeDefinition, ShapedRecipe> {
18
- create(definition: ShapedRecipeDefinition): ShapedRecipe;
21
+ export declare class ShapedParser extends RecipeParser<ShapedRecipeDefinition, ShapedRecipe> {
22
+ deserialize(definition: ShapedRecipeDefinition, context: RecipeParseContext): ShapedRecipe;
19
23
  }
@@ -1,28 +1,33 @@
1
1
  import RecipeParser, { Recipe } from "../index.js";
2
- import { mapValues } from "lodash-es";
3
2
  export class ShapedRecipe extends Recipe {
3
+ ingredients;
4
+ result;
5
+ constructor(ingredients, result) {
6
+ super();
7
+ this.ingredients = ingredients;
8
+ this.result = result;
9
+ }
4
10
  getIngredients() {
5
- return Object.values(this.definition.key);
11
+ return this.ingredients.list();
6
12
  }
7
13
  getResults() {
8
- return [this.definition.result];
14
+ return [this.result];
9
15
  }
10
- replaceIngredient(replace) {
11
- return new ShapedRecipe({
12
- ...this.definition,
13
- key: mapValues(this.definition.key, replace),
14
- });
16
+ replace(ingredientReplacer, resultReplacer) {
17
+ return new ShapedRecipe(this.ingredients.replace(ingredientReplacer), resultReplacer(this.result));
15
18
  }
16
- replaceResult(replace) {
17
- return new ShapedRecipe({
18
- ...this.definition,
19
- result: replace(this.definition.result),
20
- });
19
+ serialize(context) {
20
+ return {
21
+ key: this.ingredients.serialize(context),
22
+ result: context.results.serialize(this.result),
23
+ };
21
24
  }
22
25
  }
23
- export default class ShapedParser extends RecipeParser {
24
- create(definition) {
25
- return new ShapedRecipe(definition);
26
+ export class ShapedParser extends RecipeParser {
27
+ deserialize(definition, context) {
28
+ const ingredients = context.ingredients.ingredientMap(definition.key);
29
+ const result = context.results.create(definition.result);
30
+ return new ShapedRecipe(ingredients, result);
26
31
  }
27
32
  }
28
33
  //# sourceMappingURL=shaped.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shaped.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/shaped.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAUtC,MAAM,OAAO,YAAa,SAAQ,MAA8B;IAC9D,cAAc;QACZ,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,YAAY,CAAC;YACtB,GAAG,IAAI,CAAC,UAAU;YAClB,GAAG,EAAE,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,OAAyB;QACrC,OAAO,IAAI,YAAY,CAAC;YACtB,GAAG,IAAI,CAAC,UAAU;YAClB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,YAGzC;IACC,MAAM,CAAC,UAAkC;QACvC,OAAO,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;CACF"}
1
+ {"version":3,"file":"shaped.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/shaped.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUnD,MAAM,OAAO,YAAa,SAAQ,MAAM;IAEnB;IACA;IAFnB,YACmB,WAA0B,EAC1B,MAAc;QAE/B,KAAK,EAAE,CAAC;QAHS,gBAAW,GAAX,WAAW,CAAe;QAC1B,WAAM,GAAN,MAAM,CAAQ;IAGjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CACL,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,YAAY,CACrB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAC5C,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAC5B,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC;YACxC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SAC/C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,YAGjC;IACC,WAAW,CACT,UAAkC,EAClC,OAA2B;QAE3B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;CACF"}
@@ -1,18 +1,4 @@
1
- import type { Replacer } from "../index.js";
2
- import RecipeParser, { Recipe } from "../index.js";
3
- import type { Ingredient, IngredientInput } from "../../../common/ingredient.js";
4
- import type { RecipeDefinition } from "../../../schema/data/recipe.js";
5
- import type { Result, ResultInput } from "../../../common/result.js";
6
- export type ShapelessRecipeDefinition = RecipeDefinition & Readonly<{
7
- ingredients: Ingredient[];
8
- result: Result;
9
- }>;
10
- export declare class ShapelessRecipe extends Recipe<ShapelessRecipeDefinition> {
11
- getIngredients(): IngredientInput[];
12
- getResults(): ResultInput[];
13
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
14
- replaceResult(replace: Replacer<Result>): Recipe;
15
- }
16
- export default class ShapelessParser extends RecipeParser<ShapelessRecipeDefinition, ShapelessRecipe> {
17
- create(definition: ShapelessRecipeDefinition): ShapelessRecipe;
1
+ import { ManyToOneRecipeParser, type ManyToOneRecipeDefinition } from "../manyToOne.js";
2
+ export type ShapelessRecipeDefinition = ManyToOneRecipeDefinition;
3
+ export declare class ShapelessParser extends ManyToOneRecipeParser<ShapelessRecipeDefinition> {
18
4
  }
@@ -1,27 +1,4 @@
1
- import RecipeParser, { Recipe } from "../index.js";
2
- export class ShapelessRecipe extends Recipe {
3
- getIngredients() {
4
- return this.definition.ingredients;
5
- }
6
- getResults() {
7
- return [this.definition.result];
8
- }
9
- replaceIngredient(replace) {
10
- return new ShapelessRecipe({
11
- ...this.definition,
12
- ingredients: this.definition.ingredients.map(replace),
13
- });
14
- }
15
- replaceResult(replace) {
16
- return new ShapelessRecipe({
17
- ...this.definition,
18
- result: replace(this.definition.result),
19
- });
20
- }
21
- }
22
- export default class ShapelessParser extends RecipeParser {
23
- create(definition) {
24
- return new ShapelessRecipe(definition);
25
- }
1
+ import { ManyToOneRecipeParser, } from "../manyToOne.js";
2
+ export class ShapelessParser extends ManyToOneRecipeParser {
26
3
  }
27
4
  //# sourceMappingURL=shapeless.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shapeless.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/shapeless.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAcnD,MAAM,OAAO,eAAgB,SAAQ,MAAiC;IACpE,cAAc;QACZ,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;IACrC,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,eAAe,CAAC;YACzB,GAAG,IAAI,CAAC,UAAU;YAClB,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,OAAyB;QACrC,OAAO,IAAI,eAAe,CAAC;YACzB,GAAG,IAAI,CAAC,UAAU;YAClB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,YAG5C;IACC,MAAM,CAAC,UAAqC;QAC1C,OAAO,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;CACF"}
1
+ {"version":3,"file":"shapeless.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/shapeless.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,GAEtB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,OAAO,eAAgB,SAAQ,qBAAgD;CAAG"}
@@ -1,19 +1,22 @@
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 { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
6
6
  export type SmeltingRecipeDefinition = RecipeDefinition & Readonly<{
7
- ingredient: Ingredient;
8
- result: Result;
7
+ ingredient: unknown;
8
+ result: unknown;
9
9
  experience?: number;
10
10
  }>;
11
- export declare class SmeltingRecipe extends Recipe<SmeltingRecipeDefinition> {
12
- getIngredients(): IngredientInput[];
13
- getResults(): ResultInput[];
14
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
15
- replaceResult(replace: Replacer<Result>): Recipe;
11
+ export declare class SmeltingRecipe extends Recipe {
12
+ private readonly ingredient;
13
+ private readonly result;
14
+ constructor(ingredient: Ingredient, result: Result);
15
+ getIngredients(): Ingredient[];
16
+ getResults(): Result[];
17
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): SmeltingRecipe;
18
+ serialize(context: RecipeParseContext): Partial<SmeltingRecipeDefinition>;
16
19
  }
17
- export default class SmeltingParser extends RecipeParser<SmeltingRecipeDefinition, SmeltingRecipe> {
18
- create(definition: SmeltingRecipeDefinition): SmeltingRecipe;
20
+ export declare class SmeltingParser extends RecipeParser<SmeltingRecipeDefinition, SmeltingRecipe> {
21
+ deserialize(definition: SmeltingRecipeDefinition, context: RecipeParseContext): SmeltingRecipe;
19
22
  }
@@ -1,27 +1,33 @@
1
1
  import RecipeParser, { Recipe } from "../index.js";
2
2
  export class SmeltingRecipe extends Recipe {
3
+ ingredient;
4
+ result;
5
+ constructor(ingredient, result) {
6
+ super();
7
+ this.ingredient = ingredient;
8
+ this.result = result;
9
+ }
3
10
  getIngredients() {
4
- return [this.definition.ingredient];
11
+ return [this.ingredient];
5
12
  }
6
13
  getResults() {
7
- return [this.definition.result];
14
+ return [this.result];
8
15
  }
9
- replaceIngredient(replace) {
10
- return new SmeltingRecipe({
11
- ...this.definition,
12
- ingredient: replace(this.definition.ingredient),
13
- });
16
+ replace(ingredientReplacer, resultReplacer) {
17
+ return new SmeltingRecipe(ingredientReplacer(this.ingredient), resultReplacer(this.result));
14
18
  }
15
- replaceResult(replace) {
16
- return new SmeltingRecipe({
17
- ...this.definition,
18
- result: replace(this.definition.result),
19
- });
19
+ serialize(context) {
20
+ return {
21
+ ingredient: context.ingredients.serialize(this.ingredient),
22
+ result: context.results.serialize(this.result),
23
+ };
20
24
  }
21
25
  }
22
- export default class SmeltingParser extends RecipeParser {
23
- create(definition) {
24
- return new SmeltingRecipe(definition);
26
+ export class SmeltingParser extends RecipeParser {
27
+ deserialize(definition, context) {
28
+ const ingredient = context.ingredients.create(definition.ingredient);
29
+ const result = context.results.create(definition.result);
30
+ return new SmeltingRecipe(ingredient, result);
25
31
  }
26
32
  }
27
33
  //# sourceMappingURL=smelting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smelting.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/smelting.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAenD,MAAM,OAAO,cAAe,SAAQ,MAAgC;IAClE,cAAc;QACZ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,cAAc,CAAC;YACxB,GAAG,IAAI,CAAC,UAAU;YAClB,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;SAChD,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,OAAyB;QACrC,OAAO,IAAI,cAAc,CAAC;YACxB,GAAG,IAAI,CAAC,UAAU;YAClB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;SACxC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,YAG3C;IACC,MAAM,CAAC,UAAoC;QACzC,OAAO,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;CACF"}
1
+ {"version":3,"file":"smelting.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/smelting.ts"],"names":[],"mappings":"AAIA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AASnD,MAAM,OAAO,cAAe,SAAQ,MAAM;IAErB;IACA;IAFnB,YACmB,UAAsB,EACtB,MAAc;QAE/B,KAAK,EAAE,CAAC;QAHS,eAAU,GAAV,UAAU,CAAY;QACtB,WAAM,GAAN,MAAM,CAAQ;IAGjC,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;IAEQ,OAAO,CACd,kBAAwC,EACxC,cAAgC;QAEhC,OAAO,IAAI,cAAc,CACvB,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EACnC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAC5B,CAAC;IACJ,CAAC;IAEQ,SAAS,CAChB,OAA2B;QAE3B,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC;YAC1D,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;SAC/C,CAAC;IACJ,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,YAGnC;IACC,WAAW,CACT,UAAoC,EACpC,OAA2B;QAE3B,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzD,OAAO,IAAI,cAAc,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -1,19 +1,23 @@
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 { Result, ResultInput } from "../../../common/result.js";
4
+ import type { RecipeParseContext, Replacer } from "../index.js";
5
+ import RecipeParser, { Recipe } from "../index.js";
6
6
  export type SmithingRecipeDefinition = RecipeDefinition & Readonly<{
7
- base: Ingredient;
8
- addition: Ingredient;
9
- result: Result;
7
+ base: unknown;
8
+ addition: unknown;
9
+ result: unknown;
10
10
  }>;
11
- export declare class SmithingRecipe extends Recipe<SmithingRecipeDefinition> {
12
- getIngredients(): IngredientInput[];
13
- getResults(): ResultInput[];
14
- replaceIngredient(replace: Replacer<Ingredient>): Recipe;
15
- replaceResult(replace: Replacer<Result>): Recipe;
11
+ export declare class SmithingRecipe extends Recipe {
12
+ private readonly base;
13
+ private readonly addition;
14
+ private readonly result;
15
+ constructor(base: Ingredient, addition: Ingredient, result: Result);
16
+ getIngredients(): Ingredient[];
17
+ getResults(): Result[];
18
+ replace(ingredientReplacer: Replacer<Ingredient>, resultReplacer: Replacer<Result>): SmithingRecipe;
19
+ serialize(context: RecipeParseContext): Partial<SmithingRecipeDefinition>;
16
20
  }
17
- export default class SmithingParser extends RecipeParser<SmithingRecipeDefinition, SmithingRecipe> {
18
- create(definition: SmithingRecipeDefinition): SmithingRecipe;
21
+ export declare class SmithingParser extends RecipeParser<SmithingRecipeDefinition, SmithingRecipe> {
22
+ deserialize(definition: SmithingRecipeDefinition, context: RecipeParseContext): SmithingRecipe;
19
23
  }
@@ -1,28 +1,37 @@
1
1
  import RecipeParser, { Recipe } from "../index.js";
2
2
  export class SmithingRecipe extends Recipe {
3
+ base;
4
+ addition;
5
+ result;
6
+ constructor(base, addition, result) {
7
+ super();
8
+ this.base = base;
9
+ this.addition = addition;
10
+ this.result = result;
11
+ }
3
12
  getIngredients() {
4
- return [this.definition.base, this.definition.addition];
13
+ return [this.base, this.addition];
5
14
  }
6
15
  getResults() {
7
- return [this.definition.result];
16
+ return [this.result];
8
17
  }
9
- replaceIngredient(replace) {
10
- return new SmithingRecipe({
11
- ...this.definition,
12
- base: replace(this.definition.base),
13
- addition: replace(this.definition.addition),
14
- });
18
+ replace(ingredientReplacer, resultReplacer) {
19
+ return new SmithingRecipe(ingredientReplacer(this.base), ingredientReplacer(this.addition), resultReplacer(this.result));
15
20
  }
16
- replaceResult(replace) {
17
- return new SmithingRecipe({
18
- ...this.definition,
19
- result: replace(this.definition.result),
20
- });
21
+ serialize(context) {
22
+ return {
23
+ base: context.ingredients.serialize(this.base),
24
+ addition: context.ingredients.serialize(this.addition),
25
+ result: context.results.serialize(this.result),
26
+ };
21
27
  }
22
28
  }
23
- export default class SmithingParser extends RecipeParser {
24
- create(definition) {
25
- return new SmithingRecipe(definition);
29
+ export class SmithingParser extends RecipeParser {
30
+ deserialize(definition, context) {
31
+ const base = context.ingredients.create(definition.base);
32
+ const addition = context.ingredients.create(definition.addition);
33
+ const result = context.results.create(definition.result);
34
+ return new SmithingRecipe(base, addition, result);
26
35
  }
27
36
  }
28
37
  //# sourceMappingURL=smithing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"smithing.js","sourceRoot":"","sources":["../../../../src/parser/recipe/vanilla/smithing.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAenD,MAAM,OAAO,cAAe,SAAQ,MAAgC;IAClE,cAAc;QACZ,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAED,UAAU;QACR,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,OAA6B;QAC7C,OAAO,IAAI,cA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