@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.
- package/dist/common/id.d.ts +1 -0
- package/dist/common/id.js +4 -0
- package/dist/common/id.js.map +1 -1
- package/dist/common/ingredient/filter.d.ts +6 -0
- package/dist/common/ingredient/filter.js +97 -0
- package/dist/common/ingredient/filter.js.map +1 -0
- package/dist/common/ingredient/index.d.ts +74 -0
- package/dist/common/ingredient/index.js +112 -0
- package/dist/common/ingredient/index.js.map +1 -0
- package/dist/common/ingredient/input.d.ts +3 -0
- package/dist/common/ingredient/input.js +1 -0
- package/dist/common/ingredient/input.js.map +1 -0
- package/dist/common/ingredient/serializer.d.ts +17 -0
- package/dist/common/ingredient/serializer.js +112 -0
- package/dist/common/ingredient/serializer.js.map +1 -0
- package/dist/common/predicates.d.ts +2 -1
- package/dist/common/predicates.js.map +1 -1
- package/dist/common/result/filter.d.ts +6 -0
- package/dist/common/result/filter.js +68 -0
- package/dist/common/result/filter.js.map +1 -0
- package/dist/common/result/index.d.ts +41 -0
- package/dist/common/result/index.js +59 -0
- package/dist/common/result/index.js.map +1 -0
- package/dist/common/result/input.d.ts +3 -0
- package/dist/common/result/input.js +1 -0
- package/dist/common/result/input.js.map +1 -0
- package/dist/common/result/serializer.d.ts +15 -0
- package/dist/common/result/serializer.js +81 -0
- package/dist/common/result/serializer.js.map +1 -0
- package/dist/common/serializable.d.ts +6 -0
- package/dist/common/serializable.js +1 -0
- package/dist/common/serializable.js.map +1 -0
- package/dist/common/units.d.ts +1 -0
- package/dist/common/units.js +2 -0
- package/dist/common/units.js.map +1 -0
- package/dist/emit/blacklist.d.ts +4 -6
- package/dist/emit/blacklist.js +19 -21
- package/dist/emit/blacklist.js.map +1 -1
- package/dist/emit/data/loot.d.ts +6 -8
- package/dist/emit/data/loot.js +11 -13
- package/dist/emit/data/loot.js.map +1 -1
- package/dist/emit/data/recipe.d.ts +20 -18
- package/dist/emit/data/recipe.js +40 -29
- package/dist/emit/data/recipe.js.map +1 -1
- package/dist/emit/data/tags.d.ts +1 -1
- package/dist/emit/data/tags.js.map +1 -1
- package/dist/emit/polytoneTabs.d.ts +1 -1
- package/dist/emit/polytoneTabs.js +1 -2
- package/dist/emit/polytoneTabs.js.map +1 -1
- package/dist/emit/rule/lootTable.d.ts +2 -1
- package/dist/emit/rule/lootTable.js +4 -2
- package/dist/emit/rule/lootTable.js.map +1 -1
- package/dist/emit/rule/recipe.d.ts +7 -5
- package/dist/emit/rule/recipe.js.map +1 -1
- package/dist/emit/ruled.d.ts +2 -1
- package/dist/emit/ruled.js +5 -2
- package/dist/emit/ruled.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/loader/context.d.ts +12 -0
- package/dist/loader/context.js +1 -0
- package/dist/loader/context.js.map +1 -0
- package/dist/loader/pack.d.ts +13 -7
- package/dist/loader/pack.js +43 -25
- package/dist/loader/pack.js.map +1 -1
- package/dist/loader/recipe.d.ts +9 -5
- package/dist/loader/recipe.js +39 -48
- package/dist/loader/recipe.js.map +1 -1
- package/dist/loader/registry/dump.d.ts +0 -2
- package/dist/loader/registry/dump.js +0 -11
- package/dist/loader/registry/dump.js.map +1 -1
- package/dist/loader/registry/index.d.ts +0 -2
- package/dist/loader/registry/wrapped.d.ts +13 -0
- package/dist/loader/registry/wrapped.js +26 -0
- package/dist/loader/registry/wrapped.js.map +1 -0
- package/dist/loader/tags.d.ts +1 -1
- package/dist/loader/tags.js.map +1 -1
- package/dist/parser/adAstra.d.ts +5 -11
- package/dist/parser/adAstra.js +5 -5
- package/dist/parser/adAstra.js.map +1 -1
- package/dist/parser/botania.d.ts +10 -20
- package/dist/parser/botania.js +10 -10
- package/dist/parser/botania.js.map +1 -1
- package/dist/parser/create.d.ts +2 -4
- package/dist/parser/create.js +2 -2
- package/dist/parser/create.js.map +1 -1
- package/dist/parser/index.d.ts +7 -13
- package/dist/parser/index.js +7 -7
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/lootTable.d.ts +7 -6
- package/dist/parser/lootTable.js +25 -23
- package/dist/parser/lootTable.js.map +1 -1
- package/dist/parser/recipe/adAstra/conversion.d.ts +15 -14
- package/dist/parser/recipe/adAstra/conversion.js +27 -20
- package/dist/parser/recipe/adAstra/conversion.js.map +1 -1
- package/dist/parser/recipe/adAstra/hammering.d.ts +3 -17
- package/dist/parser/recipe/adAstra/hammering.js +2 -25
- package/dist/parser/recipe/adAstra/hammering.js.map +1 -1
- package/dist/parser/recipe/adAstra/inputOutput.d.ts +16 -19
- package/dist/parser/recipe/adAstra/inputOutput.js +37 -29
- package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -1
- package/dist/parser/recipe/adAstra/nasaWorkbench.d.ts +3 -19
- package/dist/parser/recipe/adAstra/nasaWorkbench.js +2 -28
- package/dist/parser/recipe/adAstra/nasaWorkbench.js.map +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.d.ts +15 -14
- package/dist/parser/recipe/adAstra/spaceStation.js +33 -14
- package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -1
- package/dist/parser/recipe/botania/apothecary.d.ts +17 -14
- package/dist/parser/recipe/botania/apothecary.js +26 -17
- package/dist/parser/recipe/botania/apothecary.js.map +1 -1
- package/dist/parser/recipe/botania/blocks.d.ts +21 -0
- package/dist/parser/recipe/botania/blocks.js +77 -0
- package/dist/parser/recipe/botania/blocks.js.map +1 -0
- package/dist/parser/recipe/botania/brew.d.ts +13 -12
- package/dist/parser/recipe/botania/brew.js +16 -11
- package/dist/parser/recipe/botania/brew.js.map +1 -1
- package/dist/parser/recipe/botania/elvenTrade.d.ts +8 -13
- package/dist/parser/recipe/botania/elvenTrade.js +11 -22
- package/dist/parser/recipe/botania/elvenTrade.js.map +1 -1
- package/dist/parser/recipe/botania/gogWrapper.d.ts +12 -12
- package/dist/parser/recipe/botania/gogWrapper.js +14 -15
- package/dist/parser/recipe/botania/gogWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/manaInfusion.d.ts +18 -15
- package/dist/parser/recipe/botania/manaInfusion.js +29 -21
- package/dist/parser/recipe/botania/manaInfusion.js.map +1 -1
- package/dist/parser/recipe/botania/nbtWrapper.d.ts +12 -12
- package/dist/parser/recipe/botania/nbtWrapper.js +12 -13
- package/dist/parser/recipe/botania/nbtWrapper.js.map +1 -1
- package/dist/parser/recipe/botania/orechid.d.ts +3 -30
- package/dist/parser/recipe/botania/orechid.js +2 -72
- package/dist/parser/recipe/botania/orechid.js.map +1 -1
- package/dist/parser/recipe/botania/pureDaisy.d.ts +3 -18
- package/dist/parser/recipe/botania/pureDaisy.js +2 -28
- package/dist/parser/recipe/botania/pureDaisy.js.map +1 -1
- package/dist/parser/recipe/botania/runicAltar.d.ts +8 -13
- package/dist/parser/recipe/botania/runicAltar.js +11 -22
- package/dist/parser/recipe/botania/runicAltar.js.map +1 -1
- package/dist/parser/recipe/botania/terraPlate.d.ts +4 -16
- package/dist/parser/recipe/botania/terraPlate.js +2 -25
- package/dist/parser/recipe/botania/terraPlate.js.map +1 -1
- package/dist/parser/recipe/create/assembly.d.ts +18 -17
- package/dist/parser/recipe/create/assembly.js +28 -28
- package/dist/parser/recipe/create/assembly.js.map +1 -1
- package/dist/parser/recipe/create/processing.d.ts +4 -16
- package/dist/parser/recipe/create/processing.js +2 -25
- package/dist/parser/recipe/create/processing.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cooking.d.ts +16 -12
- package/dist/parser/recipe/farmersdelight/cooking.js +27 -15
- package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cutting.d.ts +14 -15
- package/dist/parser/recipe/farmersdelight/cutting.js +32 -29
- package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -1
- package/dist/parser/recipe/forge/conditional.d.ts +11 -11
- package/dist/parser/recipe/forge/conditional.js +17 -21
- package/dist/parser/recipe/forge/conditional.js.map +1 -1
- package/dist/parser/recipe/index.d.ts +36 -13
- package/dist/parser/recipe/index.js +38 -5
- package/dist/parser/recipe/index.js.map +1 -1
- package/dist/parser/recipe/ingredientMap.d.ts +12 -0
- package/dist/parser/recipe/ingredientMap.js +17 -0
- package/dist/parser/recipe/ingredientMap.js.map +1 -0
- package/dist/parser/recipe/manyToMany.d.ts +20 -0
- package/dist/parser/recipe/manyToMany.js +33 -0
- package/dist/parser/recipe/manyToMany.js.map +1 -0
- package/dist/parser/recipe/manyToOne.d.ts +20 -0
- package/dist/parser/recipe/manyToOne.js +33 -0
- package/dist/parser/recipe/manyToOne.js.map +1 -0
- package/dist/parser/recipe/oneToOne.d.ts +20 -0
- package/dist/parser/recipe/oneToOne.js +33 -0
- package/dist/parser/recipe/oneToOne.js.map +1 -0
- package/dist/parser/recipe/roots/component.d.ts +13 -12
- package/dist/parser/recipe/roots/component.js +16 -11
- package/dist/parser/recipe/roots/component.js.map +1 -1
- package/dist/parser/recipe/roots/ritual.d.ts +14 -16
- package/dist/parser/recipe/roots/ritual.js +18 -25
- package/dist/parser/recipe/roots/ritual.js.map +1 -1
- package/dist/parser/recipe/sullys/polishing.d.ts +4 -16
- package/dist/parser/recipe/sullys/polishing.js +2 -25
- package/dist/parser/recipe/sullys/polishing.js.map +1 -1
- package/dist/parser/recipe/thermal/catalyst.d.ts +13 -12
- package/dist/parser/recipe/thermal/catalyst.js +16 -11
- package/dist/parser/recipe/thermal/catalyst.js.map +1 -1
- package/dist/parser/recipe/thermal/fuel.d.ts +13 -12
- package/dist/parser/recipe/thermal/fuel.js +17 -11
- package/dist/parser/recipe/thermal/fuel.js.map +1 -1
- package/dist/parser/recipe/thermal/index.d.ts +16 -14
- package/dist/parser/recipe/thermal/index.js +35 -24
- package/dist/parser/recipe/thermal/index.js.map +1 -1
- package/dist/parser/recipe/thermal/ingredient.d.ts +4 -21
- package/dist/parser/recipe/thermal/ingredient.js +40 -33
- package/dist/parser/recipe/thermal/ingredient.js.map +1 -1
- package/dist/parser/recipe/thermal/treeExtraction.d.ts +17 -17
- package/dist/parser/recipe/thermal/treeExtraction.js +30 -31
- package/dist/parser/recipe/thermal/treeExtraction.js.map +1 -1
- package/dist/parser/recipe/vanilla/shaped.d.ts +17 -13
- package/dist/parser/recipe/vanilla/shaped.js +21 -16
- package/dist/parser/recipe/vanilla/shaped.js.map +1 -1
- package/dist/parser/recipe/vanilla/shapeless.d.ts +3 -17
- package/dist/parser/recipe/vanilla/shapeless.js +2 -25
- package/dist/parser/recipe/vanilla/shapeless.js.map +1 -1
- package/dist/parser/recipe/vanilla/smelting.d.ts +16 -13
- package/dist/parser/recipe/vanilla/smelting.js +21 -15
- package/dist/parser/recipe/vanilla/smelting.js.map +1 -1
- package/dist/parser/recipe/vanilla/smithing.d.ts +18 -14
- package/dist/parser/recipe/vanilla/smithing.js +25 -16
- package/dist/parser/recipe/vanilla/smithing.js.map +1 -1
- package/dist/parser/recipe/vanilla/stonecutting.d.ts +15 -13
- package/dist/parser/recipe/vanilla/stonecutting.js +22 -24
- package/dist/parser/recipe/vanilla/stonecutting.js.map +1 -1
- package/dist/parser/roots.d.ts +2 -4
- package/dist/parser/roots.js +2 -2
- package/dist/parser/roots.js.map +1 -1
- package/dist/parser/thermal.d.ts +4 -10
- package/dist/parser/thermal.js +4 -5
- package/dist/parser/thermal.js.map +1 -1
- package/dist/schema/data/recipe.d.ts +2 -1
- package/package.json +2 -1
- package/dist/common/ingredient.d.ts +0 -49
- package/dist/common/ingredient.js +0 -108
- package/dist/common/ingredient.js.map +0 -1
- package/dist/common/result.d.ts +0 -48
- package/dist/common/result.js +0 -37
- package/dist/common/result.js.map +0 -1
- package/dist/parser/recipe/adAstra/index.d.ts +0 -5
- package/dist/parser/recipe/adAstra/index.js +0 -1
- package/dist/parser/recipe/adAstra/index.js.map +0 -1
- package/dist/parser/recipe/ignored.d.ts +0 -10
- package/dist/parser/recipe/ignored.js +0 -16
- package/dist/parser/recipe/ignored.js.map +0 -1
- package/dist/parser/recipe/quark/exclusion.d.ts +0 -20
- package/dist/parser/recipe/quark/exclusion.js +0 -32
- package/dist/parser/recipe/quark/exclusion.js.map +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { encodeId } from "../id";
|
|
2
|
+
import { BUCKET } from "../units";
|
|
3
|
+
export class Result {
|
|
4
|
+
validate(_) { }
|
|
5
|
+
}
|
|
6
|
+
export class ItemResult extends Result {
|
|
7
|
+
id;
|
|
8
|
+
count;
|
|
9
|
+
chance;
|
|
10
|
+
constructor(id, count = 1, chance) {
|
|
11
|
+
super();
|
|
12
|
+
this.id = id;
|
|
13
|
+
this.count = count;
|
|
14
|
+
this.chance = chance;
|
|
15
|
+
}
|
|
16
|
+
toJSON(_packFormat) {
|
|
17
|
+
const { chance } = this;
|
|
18
|
+
const count = this.count === 1 ? undefined : this.count;
|
|
19
|
+
const id = encodeId(this.id);
|
|
20
|
+
return { item: id, count, chance };
|
|
21
|
+
}
|
|
22
|
+
validate(lookup) {
|
|
23
|
+
lookup?.validateEntry("minecraft:item", this.id);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class FluidResult extends Result {
|
|
27
|
+
id;
|
|
28
|
+
amount;
|
|
29
|
+
chance;
|
|
30
|
+
constructor(id, amount = BUCKET, chance) {
|
|
31
|
+
super();
|
|
32
|
+
this.id = id;
|
|
33
|
+
this.amount = amount;
|
|
34
|
+
this.chance = chance;
|
|
35
|
+
}
|
|
36
|
+
toJSON(_packFormat) {
|
|
37
|
+
const { amount, chance } = this;
|
|
38
|
+
const id = encodeId(this.id);
|
|
39
|
+
return { fluid: id, amount, chance };
|
|
40
|
+
}
|
|
41
|
+
validate(lookup) {
|
|
42
|
+
lookup?.validateEntry("minecraft:fluid", this.id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class BlockResult extends Result {
|
|
46
|
+
id;
|
|
47
|
+
constructor(id) {
|
|
48
|
+
super();
|
|
49
|
+
this.id = id;
|
|
50
|
+
}
|
|
51
|
+
toJSON(_packFormat) {
|
|
52
|
+
const id = encodeId(this.id);
|
|
53
|
+
return { block: id };
|
|
54
|
+
}
|
|
55
|
+
validate(lookup) {
|
|
56
|
+
lookup?.validateEntry("minecraft:block", this.id);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/result/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAgB,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAgB,MAAM;IAC1B,QAAQ,CAAC,CAAkB,IAAS,CAAC;CAEtC;AAED,MAAM,OAAO,UAAW,SAAQ,MAAM;IAElB;IACA;IACA;IAHlB,YACkB,EAAmB,EACnB,QAAQ,CAAC,EACT,MAAe;QAE/B,KAAK,EAAE,CAAC;QAJQ,OAAE,GAAF,EAAE,CAAiB;QACnB,UAAK,GAAL,KAAK,CAAI;QACT,WAAM,GAAN,MAAM,CAAS;IAGjC,CAAC;IAED,MAAM,CAAC,WAAwB;QAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QACxD,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC;IAEQ,QAAQ,CAAC,MAAuB;QACvC,MAAM,EAAE,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,MAAM;IAEnB;IACA;IACA;IAHlB,YACkB,EAAoB,EACpB,SAAiB,MAAM,EACvB,MAAe;QAE/B,KAAK,EAAE,CAAC;QAJQ,OAAE,GAAF,EAAE,CAAkB;QACpB,WAAM,GAAN,MAAM,CAAiB;QACvB,WAAM,GAAN,MAAM,CAAS;IAGjC,CAAC;IAED,MAAM,CAAC,WAAwB;QAC7B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAChC,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACvC,CAAC;IAEQ,QAAQ,CAAC,MAAuB;QACvC,MAAM,EAAE,aAAa,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,MAAM;IACT;IAA5B,YAA4B,EAAoB;QAC9C,KAAK,EAAE,CAAC;QADkB,OAAE,GAAF,EAAE,CAAkB;IAEhD,CAAC;IAED,MAAM,CAAC,WAAwB;QAC7B,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7B,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IACvB,CAAC;IAEQ,QAAQ,CAAC,MAAuB;QACvC,MAAM,EAAE,aAAa,CAAC,iBAAiB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/common/result/input.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from ".";
|
|
2
|
+
import type RegistryLookup from "../../loader/registry";
|
|
3
|
+
import type { SemVerInput } from "../../packFormat";
|
|
4
|
+
export default class ResultSerializer {
|
|
5
|
+
private readonly packFormat;
|
|
6
|
+
private readonly lookup;
|
|
7
|
+
private readonly deserializer;
|
|
8
|
+
constructor(packFormat: SemVerInput, lookup: RegistryLookup);
|
|
9
|
+
serialize(result: Result): Record<string, unknown>;
|
|
10
|
+
serializeList(results: Result[]): Record<string, unknown>[];
|
|
11
|
+
private deserialize;
|
|
12
|
+
create(input: unknown): Result;
|
|
13
|
+
validated<T extends Result>(result: T): T;
|
|
14
|
+
createList(input: unknown[]): Result[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
import { BlockResult, FluidResult, ItemResult, Result } from ".";
|
|
3
|
+
import { IllegalShapeError } from "../../error";
|
|
4
|
+
import { IdSchema } from "../id";
|
|
5
|
+
class OldDeserializer {
|
|
6
|
+
schemas = {
|
|
7
|
+
itemStack: z.object({
|
|
8
|
+
item: IdSchema,
|
|
9
|
+
count: z.number().int().optional(),
|
|
10
|
+
chance: z.number().optional(),
|
|
11
|
+
}),
|
|
12
|
+
fluidStack: z.object({
|
|
13
|
+
fluid: IdSchema,
|
|
14
|
+
amount: z.number(),
|
|
15
|
+
chance: z.number().optional(),
|
|
16
|
+
}),
|
|
17
|
+
block: z.object({
|
|
18
|
+
block: IdSchema,
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
deserialize(input) {
|
|
22
|
+
if ("block" in input) {
|
|
23
|
+
const parsed = this.schemas.block.parse(input);
|
|
24
|
+
return new BlockResult(parsed.block);
|
|
25
|
+
}
|
|
26
|
+
if ("item" in input) {
|
|
27
|
+
const parsed = this.schemas.itemStack.parse(input);
|
|
28
|
+
return new ItemResult(parsed.item, parsed.count, parsed.chance);
|
|
29
|
+
}
|
|
30
|
+
if ("fluid" in input) {
|
|
31
|
+
const parsed = this.schemas.fluidStack.parse(input);
|
|
32
|
+
return new FluidResult(parsed.fluid, parsed.amount, parsed.chance);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export default class ResultSerializer {
|
|
38
|
+
packFormat;
|
|
39
|
+
lookup;
|
|
40
|
+
deserializer;
|
|
41
|
+
constructor(packFormat, lookup) {
|
|
42
|
+
this.packFormat = packFormat;
|
|
43
|
+
this.lookup = lookup;
|
|
44
|
+
this.deserializer = new OldDeserializer();
|
|
45
|
+
}
|
|
46
|
+
serialize(result) {
|
|
47
|
+
return result.toJSON(this.packFormat);
|
|
48
|
+
}
|
|
49
|
+
serializeList(results) {
|
|
50
|
+
return results.map((it) => this.serialize(it));
|
|
51
|
+
}
|
|
52
|
+
deserialize(input) {
|
|
53
|
+
if (input instanceof Result)
|
|
54
|
+
return input;
|
|
55
|
+
if (!input)
|
|
56
|
+
throw new IllegalShapeError("result input may not be null");
|
|
57
|
+
if (typeof input === "string") {
|
|
58
|
+
this.lookup.validateEntry("minecraft:item", input);
|
|
59
|
+
return new ItemResult(input);
|
|
60
|
+
}
|
|
61
|
+
if (typeof input === "object") {
|
|
62
|
+
const deserialized = this.deserializer.deserialize(input);
|
|
63
|
+
if (deserialized)
|
|
64
|
+
return deserialized;
|
|
65
|
+
}
|
|
66
|
+
throw new IllegalShapeError(`unknown result shape`, input);
|
|
67
|
+
}
|
|
68
|
+
create(input) {
|
|
69
|
+
const deserialized = this.deserialize(input);
|
|
70
|
+
deserialized.validate(this.lookup);
|
|
71
|
+
return deserialized;
|
|
72
|
+
}
|
|
73
|
+
validated(result) {
|
|
74
|
+
result.validate(this.lookup);
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
createList(input) {
|
|
78
|
+
return input.map((it) => this.create(it));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/common/result/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK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BAAE,OAAO,YAAY,CAAC;QACxC,CAAC;QAED,MAAM,IAAI,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC7C,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,SAAS,CAAmB,MAAS;QACnC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,KAAgB;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=serializable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializable.js","sourceRoot":"","sources":["../../src/common/serializable.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BUCKET = 1000;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.js","sourceRoot":"","sources":["../../src/common/units.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC"}
|
package/dist/emit/blacklist.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { InferIds, RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
3
|
-
import type { IngredientTest } from "../common/ingredient.js";
|
|
4
|
-
import type
|
|
5
|
-
import type { TagRegistryHolder } from "../loader/tags.js";
|
|
3
|
+
import type { IngredientTest } from "../common/ingredient/filter.js";
|
|
4
|
+
import type { PackContext } from "../loader/context.js";
|
|
6
5
|
import type { ClearableEmitter } from "./index.js";
|
|
7
6
|
export type HideMode = "jei" | "polytone";
|
|
8
7
|
export interface BlacklistOptions {
|
|
@@ -15,11 +14,10 @@ export interface BlacklistRules {
|
|
|
15
14
|
type RegistryIdInput<T extends RegistryId> = InferIds<T> | RegExp;
|
|
16
15
|
export default class BlacklistEmitter implements BlacklistRules, ClearableEmitter {
|
|
17
16
|
private readonly logger;
|
|
18
|
-
private readonly
|
|
19
|
-
private readonly lookup;
|
|
17
|
+
private readonly context;
|
|
20
18
|
private hidden;
|
|
21
19
|
private readonly hideModes;
|
|
22
|
-
constructor(logger: Logger,
|
|
20
|
+
constructor(logger: Logger, context: PackContext, options: BlacklistOptions);
|
|
23
21
|
hide(...inputs: IngredientTest[]): void;
|
|
24
22
|
hideEntry<T extends RegistryId>(type: T, ...entries: RegistryIdInput<T>[]): void;
|
|
25
23
|
private filterIds;
|
package/dist/emit/blacklist.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
import { arrayOrSelf } from "@adeficior/pack-resolver";
|
|
2
2
|
import { uniq } from "lodash-es";
|
|
3
3
|
import { encodeId } from "../common/id.js";
|
|
4
|
-
import
|
|
4
|
+
import resolveIngredientTest from "../common/ingredient/filter.js";
|
|
5
|
+
import { BlockIngredient, FluidIngredient, ItemIngredient, ListIngredient, } from "../common/ingredient/index.js";
|
|
5
6
|
import { IllegalShapeError } from "../error.js";
|
|
6
7
|
import { toJson } from "../textHelper.js";
|
|
7
8
|
export default class BlacklistEmitter {
|
|
8
9
|
logger;
|
|
9
|
-
|
|
10
|
-
lookup;
|
|
10
|
+
context;
|
|
11
11
|
hidden = [];
|
|
12
12
|
hideModes;
|
|
13
|
-
constructor(logger,
|
|
13
|
+
constructor(logger, context, options) {
|
|
14
14
|
this.logger = logger;
|
|
15
|
-
this.
|
|
16
|
-
this.lookup = lookup;
|
|
15
|
+
this.context = context;
|
|
17
16
|
this.hideModes = arrayOrSelf(options.hideFrom);
|
|
18
17
|
}
|
|
19
18
|
hide(...inputs) {
|
|
20
19
|
this.hidden.push(...inputs.flatMap((test) => this.resolveIds(test)).map(encodeId));
|
|
21
20
|
}
|
|
22
21
|
hideEntry(type, ...entries) {
|
|
23
|
-
const lookup = this.lookup();
|
|
24
22
|
const ids = entries
|
|
25
23
|
.flatMap((entry) => {
|
|
26
24
|
if (typeof entry === "string") {
|
|
27
|
-
lookup.validateEntry(type, entry);
|
|
25
|
+
this.context.lookup.validateEntry(type, entry);
|
|
28
26
|
return [entry];
|
|
29
27
|
}
|
|
30
28
|
else {
|
|
31
|
-
const keys = lookup.keys(type);
|
|
29
|
+
const keys = this.context.lookup.keys(type);
|
|
32
30
|
if (!keys)
|
|
33
31
|
throw new Error(`cannot hide using regex/predicates, registry ${encodeId(type)} not loaded`);
|
|
34
32
|
return [...keys].filter((it) => entry.test(it));
|
|
@@ -38,26 +36,26 @@ export default class BlacklistEmitter {
|
|
|
38
36
|
this.hidden.push(...ids);
|
|
39
37
|
}
|
|
40
38
|
filterIds(test) {
|
|
41
|
-
const keys = this.lookup
|
|
39
|
+
const keys = this.context.lookup.keys("minecraft:item");
|
|
42
40
|
if (!keys)
|
|
43
41
|
throw new Error("you can only use regex/predicates to blacklist items if a registry dump is loaded");
|
|
44
|
-
const predicate = resolveIngredientTest(test, this.
|
|
42
|
+
const predicate = resolveIngredientTest(test, this.context);
|
|
45
43
|
return [...keys.keys()].filter((it) => predicate(it, this.logger));
|
|
46
44
|
}
|
|
47
45
|
resolveIds(input) {
|
|
48
46
|
if (input instanceof RegExp || typeof input === "function") {
|
|
49
47
|
return this.filterIds(input);
|
|
50
48
|
}
|
|
51
|
-
const ingredient =
|
|
52
|
-
if (
|
|
53
|
-
return ingredient.flatMap((it) => this.resolveIds(it));
|
|
49
|
+
const ingredient = this.context.ingredients.create(input);
|
|
50
|
+
if (ingredient instanceof ListIngredient) {
|
|
51
|
+
return ingredient.entries.flatMap((it) => this.resolveIds(it));
|
|
52
|
+
}
|
|
53
|
+
// TODO common super class?
|
|
54
|
+
if (ingredient instanceof BlockIngredient ||
|
|
55
|
+
ingredient instanceof FluidIngredient ||
|
|
56
|
+
ingredient instanceof ItemIngredient) {
|
|
57
|
+
return [encodeId(ingredient.id)];
|
|
54
58
|
}
|
|
55
|
-
if ("item" in ingredient)
|
|
56
|
-
return [ingredient.item];
|
|
57
|
-
if ("fluid" in ingredient)
|
|
58
|
-
return [ingredient.fluid];
|
|
59
|
-
if ("block" in ingredient)
|
|
60
|
-
return [ingredient.block];
|
|
61
59
|
throw new IllegalShapeError("illegal blacklist entry", input);
|
|
62
60
|
}
|
|
63
61
|
async emit(acceptor) {
|
|
@@ -77,7 +75,7 @@ export default class BlacklistEmitter {
|
|
|
77
75
|
acceptor(path, content);
|
|
78
76
|
}
|
|
79
77
|
async emitPolytone(acceptor, hiddenIds) {
|
|
80
|
-
const tabs = this.lookup
|
|
78
|
+
const tabs = this.context.lookup.keys("minecraft:creative_mode_tab");
|
|
81
79
|
if (!tabs)
|
|
82
80
|
throw new Error("Cannot use polytone output without creative mod tab registry");
|
|
83
81
|
const content = await toJson({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blacklist.js","sourceRoot":"","sources":["../../src/emit/blacklist.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"blacklist.js","sourceRoot":"","sources":["../../src/emit/blacklist.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,qBAAq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M,OAAO,GAAG,MAAM,MAAM,CAAC;YAC3B,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC3B,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,aAAa;oBACnB,KAAK,EAAE,SAAS;iBACjB;aACF;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,8DAA8D,CAAC;QAC5E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;CACF"}
|
package/dist/emit/data/loot.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
2
2
|
import type { IdInput, NormalizedId } from "../../common/id.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import {
|
|
3
|
+
import type { IngredientTest } from "../../common/ingredient/filter.js";
|
|
4
|
+
import type { IngredientInput } from "../../common/ingredient/input.js";
|
|
5
|
+
import { type CommonTest, type Predicate } from "../../common/predicates.js";
|
|
6
|
+
import type { PackContext } from "../../loader/context.js";
|
|
7
7
|
import type { LootItemInput } from "../../parser/lootTable.js";
|
|
8
8
|
import type { LootModifier, LootTable } from "../../schema/data/loot.js";
|
|
9
9
|
import type { ClearableEmitter, RegistryProvider } from "../index.js";
|
|
@@ -25,13 +25,11 @@ export interface LootRules {
|
|
|
25
25
|
export default class LootTableEmitter implements LootRules, ClearableEmitter {
|
|
26
26
|
private readonly logger;
|
|
27
27
|
private readonly lootTables;
|
|
28
|
-
private readonly
|
|
29
|
-
private readonly lookup;
|
|
30
|
-
private readonly packFormat;
|
|
28
|
+
private readonly context;
|
|
31
29
|
private readonly customTables;
|
|
32
30
|
private readonly customModifiers;
|
|
33
31
|
private readonly ruled;
|
|
34
|
-
constructor(logger: Logger, lootTables: RegistryProvider<LootTable>,
|
|
32
|
+
constructor(logger: Logger, lootTables: RegistryProvider<LootTable>, context: PackContext);
|
|
35
33
|
private tablePath;
|
|
36
34
|
private modifierPath;
|
|
37
35
|
clear(): void;
|
package/dist/emit/data/loot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { encodeId, prefix } from "../../common/id.js";
|
|
2
|
-
import
|
|
3
|
-
import { resolveIDTest } from "../../common/predicates.js";
|
|
2
|
+
import resolveIngredientTest from "../../common/ingredient/filter.js";
|
|
3
|
+
import { resolveIDTest, } from "../../common/predicates.js";
|
|
4
4
|
import { isAtLeastVersion } from "../../packFormat.js";
|
|
5
5
|
import { createLootEntry, replaceItemInTable } from "../../parser/lootTable.js";
|
|
6
6
|
import { EmptyLootEntry, LootTableSchema } from "../../schema/data/loot.js";
|
|
@@ -17,22 +17,20 @@ export const EMPTY_LOOT_MODIFIER = {
|
|
|
17
17
|
export default class LootTableEmitter {
|
|
18
18
|
logger;
|
|
19
19
|
lootTables;
|
|
20
|
-
|
|
21
|
-
lookup;
|
|
22
|
-
packFormat;
|
|
20
|
+
context;
|
|
23
21
|
customTables = new CustomEmitter((it) => this.tablePath(it));
|
|
24
22
|
customModifiers = new CustomEmitter((it) => this.modifierPath(it));
|
|
25
23
|
ruled;
|
|
26
|
-
constructor(logger, lootTables,
|
|
24
|
+
constructor(logger, lootTables, context) {
|
|
27
25
|
this.logger = logger;
|
|
28
26
|
this.lootTables = lootTables;
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
this.context = context;
|
|
28
|
+
this.ruled = new RuledEmitter(this.logger, this.lootTables, (id) => this.tablePath(id), EMPTY_LOOT_TABLE,
|
|
29
|
+
// TODO also add value object here?
|
|
30
|
+
(it) => it, (id) => this.customTables.has(id));
|
|
33
31
|
}
|
|
34
32
|
tablePath(id) {
|
|
35
|
-
const folder = isAtLeastVersion(this.packFormat, "44")
|
|
33
|
+
const folder = isAtLeastVersion(this.context.packFormat, "44")
|
|
36
34
|
? "loot_table"
|
|
37
35
|
: "loot_tables";
|
|
38
36
|
return `data/${id.namespace}/${folder}/${id.path}.json`;
|
|
@@ -53,7 +51,7 @@ export default class LootTableEmitter {
|
|
|
53
51
|
]);
|
|
54
52
|
}
|
|
55
53
|
resolveIngredientTest(test) {
|
|
56
|
-
return resolveIngredientTest(test, this.
|
|
54
|
+
return resolveIngredientTest(test, this.context);
|
|
57
55
|
}
|
|
58
56
|
resolveLootTableTest(test) {
|
|
59
57
|
const id = [];
|
|
@@ -74,7 +72,7 @@ export default class LootTableEmitter {
|
|
|
74
72
|
replaceOutput(from, to, additionalTests = {}) {
|
|
75
73
|
const predicates = this.resolveLootTableTest(additionalTests);
|
|
76
74
|
const outputPredicate = this.resolveIngredientTest(from);
|
|
77
|
-
const replacer = replaceItemInTable(outputPredicate, createLootEntry(to, this.lookup
|
|
75
|
+
const replacer = replaceItemInTable(outputPredicate, createLootEntry(to, this.context.lookup));
|
|
78
76
|
this.ruled.addRule(new LootTableRule(["replace output", from, "with", to, additionalTests], predicates.id, [outputPredicate, ...predicates.output], replacer));
|
|
79
77
|
}
|
|
80
78
|
removeOutput(from, additionalTests) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loot.js","sourceRoot":"","sources":["../../../src/emit/data/loot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"loot.js","sourceRoot":"","sources":["../../../src/emit/data/loot.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EACL,aAAa,GAGd,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2B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I,EAAE,iBAAiB;YACvB,KAAK,EAAE;gBACL;oBACE,KAAK,EAAE,CAAC;oBACR,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,gBAAgB;4BACtB,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC;yBACnB;qBACF;oBACD,UAAU,EAAE;wBACV;4BACE,SAAS,EAAE,8BAA8B;yBAC1C;qBACF;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,EAAW;QAC1B,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,mBAAmB,CAAC,CAAC;IAC5C,CAAC;IAED,WAAW,CAAyB,EAAW,EAAE,KAAQ;QACvD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1,47 +1,49 @@
|
|
|
1
1
|
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
3
3
|
import type { IdInput, NormalizedId } from "../../common/id.js";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type
|
|
7
|
-
import type {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import type { IngredientTest } from "../../common/ingredient/filter.js";
|
|
5
|
+
import type { IngredientInput } from "../../common/ingredient/input.js";
|
|
6
|
+
import { type CommonTest, type Predicate } from "../../common/predicates.js";
|
|
7
|
+
import type { ResultTest } from "../../common/result/filter.js";
|
|
8
|
+
import type { ResultInput } from "../../common/result/input.js";
|
|
9
|
+
import type { PackContext } from "../../loader/context.js";
|
|
10
|
+
import { RecipeHolder, type Recipe, type RecipeSerializer } from "../../parser/recipe/index.js";
|
|
10
11
|
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
11
12
|
import type { ClearableEmitter, RegistryProvider } from "../index.js";
|
|
12
13
|
export type RecipeTest = Readonly<{
|
|
13
14
|
id?: CommonTest<NormalizedId>;
|
|
14
15
|
type?: CommonTest<NormalizedId<RecipeSerializerId>>;
|
|
15
16
|
namespace?: string;
|
|
16
|
-
output?:
|
|
17
|
+
output?: ResultTest;
|
|
17
18
|
input?: IngredientTest;
|
|
18
19
|
optional?: boolean;
|
|
19
20
|
}>;
|
|
20
21
|
export interface RecipeRules {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
add
|
|
22
|
+
replaceResult(test: ResultTest, value: ResultInput, additionalTests?: RecipeTest): void;
|
|
23
|
+
replaceIngredient(test: IngredientTest, value: IngredientInput, additionalTests?: RecipeTest): void;
|
|
24
|
+
add(id: IdInput, value: RecipeDefinition): void;
|
|
25
|
+
add(id: IdInput, value: RecipeHolder): void;
|
|
26
|
+
add(id: IdInput, type: NormalizedId<RecipeSerializerId>, value: Recipe): void;
|
|
25
27
|
remove(test: RecipeTest): void;
|
|
26
28
|
}
|
|
27
29
|
export declare const EMPTY_RECIPE: RecipeDefinition;
|
|
28
30
|
export default class RecipeEmitter implements RecipeRules, ClearableEmitter {
|
|
29
31
|
private readonly logger;
|
|
30
32
|
private readonly registry;
|
|
31
|
-
private readonly
|
|
32
|
-
private readonly
|
|
33
|
-
private readonly packFormat;
|
|
33
|
+
private readonly context;
|
|
34
|
+
private readonly serializer;
|
|
34
35
|
private readonly custom;
|
|
35
36
|
private readonly ruled;
|
|
36
|
-
constructor(logger: Logger, registry: RegistryProvider<
|
|
37
|
+
constructor(logger: Logger, registry: RegistryProvider<RecipeHolder>, context: PackContext, serializer: RecipeSerializer);
|
|
37
38
|
private recipePath;
|
|
38
39
|
emit(acceptor: Acceptor): Promise<void>;
|
|
39
40
|
resolveIngredientTest(test?: IngredientTest): Predicate<IngredientInput>;
|
|
41
|
+
resolveResultTest(test?: ResultTest): Predicate<ResultInput>;
|
|
40
42
|
private resolveRecipeTest;
|
|
41
|
-
add
|
|
43
|
+
add(id: IdInput, arg: RecipeDefinition | RecipeHolder | NormalizedId<RecipeSerializerId>, arg2?: Recipe): void;
|
|
42
44
|
private addRule;
|
|
43
45
|
remove(test: RecipeTest): void;
|
|
44
|
-
replaceResult(test:
|
|
45
|
-
replaceIngredient(test: IngredientTest,
|
|
46
|
+
replaceResult(test: ResultTest, input: ResultInput, additionalTest?: RecipeTest): void;
|
|
47
|
+
replaceIngredient(test: IngredientTest, input: IngredientInput, additionalTest?: RecipeTest): void;
|
|
46
48
|
clear(): void;
|
|
47
49
|
}
|