@adeficior/data-modifier 1.0.0-rc.36 → 1.0.0-rc.38
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/class.d.ts +4 -0
- package/dist/common/class.js +1 -0
- package/dist/common/class.js.map +1 -0
- package/dist/common/fields.d.ts +1 -1
- package/dist/common/fields.js +2 -2
- package/dist/common/fields.js.map +1 -1
- package/dist/common/id.d.ts +0 -2
- package/dist/common/id.js +2 -9
- package/dist/common/id.js.map +1 -1
- package/dist/common/ingredient/index.d.ts +8 -28
- package/dist/common/ingredient/index.js +14 -33
- package/dist/common/ingredient/index.js.map +1 -1
- package/dist/common/ingredient/serializer.d.ts +2 -10
- package/dist/common/ingredient/serializer.js +44 -105
- package/dist/common/ingredient/serializer.js.map +1 -1
- package/dist/common/{serializable.d.ts → inputOutput.d.ts} +1 -3
- package/dist/common/inputOutput.js +1 -0
- package/dist/common/inputOutput.js.map +1 -0
- package/dist/common/result/index.d.ts +2 -17
- package/dist/common/result/index.js +0 -15
- package/dist/common/result/index.js.map +1 -1
- package/dist/common/result/serializer.d.ts +2 -10
- package/dist/common/result/serializer.js +20 -75
- package/dist/common/result/serializer.js.map +1 -1
- package/dist/common/serializer.d.ts +35 -0
- package/dist/common/serializer.js +110 -0
- package/dist/common/serializer.js.map +1 -0
- package/dist/error.js +6 -17
- package/dist/error.js.map +1 -1
- package/dist/loader/recipe.d.ts +2 -2
- package/dist/loader/recipe.js +13 -40
- package/dist/loader/recipe.js.map +1 -1
- package/dist/loader/tags.js.map +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.js +1 -1
- package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -1
- package/dist/parser/recipe/botania/apothecary.js +1 -1
- package/dist/parser/recipe/botania/apothecary.js.map +1 -1
- package/dist/parser/recipe/botania/blocks.js +3 -2
- package/dist/parser/recipe/botania/blocks.js.map +1 -1
- package/dist/parser/recipe/botania/brew.js +1 -1
- package/dist/parser/recipe/botania/brew.js.map +1 -1
- package/dist/parser/recipe/botania/elvenTrade.js +2 -2
- package/dist/parser/recipe/botania/elvenTrade.js.map +1 -1
- package/dist/parser/recipe/botania/runicAltar.js +1 -1
- package/dist/parser/recipe/botania/runicAltar.js.map +1 -1
- package/dist/parser/recipe/create/assembly.js +1 -1
- package/dist/parser/recipe/create/assembly.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cooking.js +3 -6
- package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -1
- package/dist/parser/recipe/farmersdelight/cutting.js +2 -2
- package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -1
- package/dist/parser/recipe/manyToMany.js +2 -2
- package/dist/parser/recipe/manyToMany.js.map +1 -1
- package/dist/parser/recipe/manyToOne.js +1 -1
- package/dist/parser/recipe/manyToOne.js.map +1 -1
- package/dist/parser/recipe/roots/component.js +1 -1
- package/dist/parser/recipe/roots/component.js.map +1 -1
- package/dist/parser/recipe/roots/ritual.js +2 -2
- package/dist/parser/recipe/roots/ritual.js.map +1 -1
- package/dist/parser/recipe/thermal/index.js +7 -5
- package/dist/parser/recipe/thermal/index.js.map +1 -1
- package/dist/parser/recipe/thermal/ingredient.js +4 -3
- package/dist/parser/recipe/thermal/ingredient.js.map +1 -1
- package/dist/parser/recipe/vanilla/smithing.d.ts +4 -2
- package/dist/parser/recipe/vanilla/smithing.js +12 -7
- package/dist/parser/recipe/vanilla/smithing.js.map +1 -1
- package/dist/schema/data/loot.d.ts +60 -1086
- package/package.json +2 -2
- package/dist/common/serializable.js +0 -1
- package/dist/common/serializable.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../src/common/class.ts"],"names":[],"mappings":""}
|
package/dist/common/fields.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export declare const CountSchema: z.
|
|
2
|
+
export declare const CountSchema: z.ZodCodec<z.ZodOptional<z.ZodNumber>, z.ZodNumber>;
|
|
3
3
|
export declare const AmountSchema: z.ZodNumber;
|
|
4
4
|
export declare const ChanceSchema: z.ZodOptional<z.ZodNumber>;
|
package/dist/common/fields.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import z from "zod";
|
|
2
|
-
export const CountSchema = z.number().int().positive().
|
|
2
|
+
export const CountSchema = z.codec(z.number().int().positive().optional(), z.number(), { decode: (it) => it ?? 1, encode: (it) => (it === 1 ? undefined : it) });
|
|
3
3
|
export const AmountSchema = z.number().positive();
|
|
4
|
-
export const ChanceSchema = z.number().
|
|
4
|
+
export const ChanceSchema = z.number().positive().optional();
|
|
5
5
|
//# sourceMappingURL=fields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/common/fields.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"fields.js","sourceRoot":"","sources":["../../src/common/fields.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAChC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,EACtC,CAAC,CAAC,MAAM,EAAE,EACV,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CACzE,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC"}
|
package/dist/common/id.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ export type NormalizedId<T extends string = string> = T extends `${string}:${str
|
|
|
9
9
|
export type TagId = NormalizedId<`#${string}`>;
|
|
10
10
|
export type TagInput = IdInput<`#${string}`>;
|
|
11
11
|
export declare const IdSchema: zod.ZodString;
|
|
12
|
-
export declare const TagSchema: zod.ZodType<`#${string}`>;
|
|
13
|
-
export declare const IdOrTagSchema: zod.ZodString;
|
|
14
12
|
export declare function createId(from: IdInput): Id;
|
|
15
13
|
export declare function encodeId<T extends string>(from: IdInput<T>): NormalizedId<T>;
|
|
16
14
|
export declare function toTag(from: IdInput): TagId;
|
package/dist/common/id.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import zod from "zod";
|
|
2
2
|
export const IdSchema = zod
|
|
3
3
|
.string()
|
|
4
|
-
.regex(
|
|
4
|
+
.regex(/^#?([a-z0-9_.-]+:)?[a-z0-9_.-/]+$/i, "ID may only include letters, numbers, dashes and underscores")
|
|
5
|
+
.refine((val) => !val.startsWith("#"), "IDs may not start with a hashtag")
|
|
5
6
|
.describe("Valid ID");
|
|
6
|
-
export const TagSchema = zod
|
|
7
|
-
.string()
|
|
8
|
-
.regex(/^#([a-z0-9_.-]+:)?[a-z0-9/._-]+$/i)
|
|
9
|
-
.describe("Valid Tag-ID");
|
|
10
|
-
export const IdOrTagSchema = zod
|
|
11
|
-
.string()
|
|
12
|
-
.regex(/^#?([a-z0-9_.-]+:)?[a-z0-9/._-]+$/i)
|
|
13
|
-
.describe("Valid ID or Tag-ID");
|
|
14
7
|
export function createId(from) {
|
|
15
8
|
if (typeof from !== "string")
|
|
16
9
|
return from;
|
package/dist/common/id.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/common/id.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG;KACxB,MAAM,EAAE;KACR,KAAK,
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/common/id.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAqBtB,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG;KACxB,MAAM,EAAE;KACR,KAAK,CACJ,oCAAoC,EACpC,8DAA8D,CAC/D;KACA,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,kCAAkC,CAAC;KACzE,QAAQ,CAAC,UAAU,CAAC,CAAC;AAExB,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,OAAO,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAEzD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAErB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACvE,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC9D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAmB,IAAgB;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G,MAAM,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { BlockId, FluidId, ItemId, RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type RegistryLookup from "../../loader/registry";
|
|
3
|
-
import type { SemVerInput } from "../../packFormat";
|
|
4
3
|
import { type IdInput, type NormalizedId, type TagId } from "../id";
|
|
4
|
+
import type { InputOutput } from "../inputOutput";
|
|
5
5
|
import { BlockResult, FluidResult, ItemResult, type Result } from "../result";
|
|
6
|
-
|
|
7
|
-
export declare abstract class Ingredient implements Serializable {
|
|
6
|
+
export declare abstract class Ingredient implements InputOutput {
|
|
8
7
|
validate(_: RegistryLookup): void;
|
|
9
|
-
abstract serialize(packFormat: SemVerInput): unknown;
|
|
10
8
|
abstract idsFor(registry: NormalizedId<RegistryId>): NormalizedId<RegistryId>[];
|
|
11
9
|
abstract asResult(): Result;
|
|
12
10
|
}
|
|
@@ -20,24 +18,13 @@ export declare abstract class TagIngredient extends Ingredient {
|
|
|
20
18
|
export declare class ItemTagIngredient extends TagIngredient {
|
|
21
19
|
readonly count: number;
|
|
22
20
|
constructor(tag: IdInput, count?: number);
|
|
23
|
-
serialize(_packFormat: SemVerInput): {
|
|
24
|
-
tag: `${string}:${string}`;
|
|
25
|
-
count: number | undefined;
|
|
26
|
-
};
|
|
27
21
|
}
|
|
28
22
|
export declare class FluidTagIngredient extends TagIngredient {
|
|
29
23
|
readonly amount: number;
|
|
30
24
|
constructor(tag: IdInput, amount?: number);
|
|
31
|
-
serialize(_packFormat: SemVerInput): {
|
|
32
|
-
fluidTag: `${string}:${string}`;
|
|
33
|
-
amount: number;
|
|
34
|
-
};
|
|
35
25
|
}
|
|
36
26
|
export declare class BlockTagIngredient extends TagIngredient {
|
|
37
27
|
constructor(tag: IdInput);
|
|
38
|
-
serialize(_packFormat: SemVerInput): {
|
|
39
|
-
blockTag: `${string}:${string}`;
|
|
40
|
-
};
|
|
41
28
|
}
|
|
42
29
|
export declare abstract class RegistryEntryIngredient<T extends string> extends Ingredient {
|
|
43
30
|
readonly registry: NormalizedId<RegistryId>;
|
|
@@ -48,10 +35,6 @@ export declare abstract class RegistryEntryIngredient<T extends string> extends
|
|
|
48
35
|
export declare class ItemIngredient extends RegistryEntryIngredient<ItemId> {
|
|
49
36
|
readonly count: number;
|
|
50
37
|
constructor(id: IdInput<ItemId>, count?: number);
|
|
51
|
-
serialize(_packFormat: SemVerInput): {
|
|
52
|
-
item: `${string}:${string}`;
|
|
53
|
-
count: number | undefined;
|
|
54
|
-
};
|
|
55
38
|
validate(lookup: RegistryLookup): void;
|
|
56
39
|
asResult(): ItemResult;
|
|
57
40
|
}
|
|
@@ -59,27 +42,18 @@ export declare class FluidIngredient extends RegistryEntryIngredient<FluidId> {
|
|
|
59
42
|
readonly amount: number;
|
|
60
43
|
readonly chance?: number | undefined;
|
|
61
44
|
constructor(id: IdInput<FluidId>, amount?: number, chance?: number | undefined);
|
|
62
|
-
serialize(_packFormat: SemVerInput): {
|
|
63
|
-
fluid: `${string}:${string}`;
|
|
64
|
-
amount: number;
|
|
65
|
-
};
|
|
66
45
|
validate(lookup: RegistryLookup): void;
|
|
67
46
|
asResult(): FluidResult;
|
|
68
47
|
}
|
|
69
48
|
export declare class BlockIngredient extends RegistryEntryIngredient<BlockId> {
|
|
70
49
|
readonly weight?: number | undefined;
|
|
71
50
|
constructor(id: IdInput<BlockId>, weight?: number | undefined);
|
|
72
|
-
serialize(_packFormat: SemVerInput): {
|
|
73
|
-
block: `${string}:${string}`;
|
|
74
|
-
weight: number | undefined;
|
|
75
|
-
};
|
|
76
51
|
validate(lookup: RegistryLookup): void;
|
|
77
52
|
asResult(): BlockResult;
|
|
78
53
|
}
|
|
79
54
|
export declare class ListIngredient extends Ingredient {
|
|
80
55
|
readonly entries: Ingredient[];
|
|
81
56
|
constructor(entries: Ingredient[]);
|
|
82
|
-
serialize(packFormat: SemVerInput): unknown[];
|
|
83
57
|
validate(lookup: RegistryLookup): void;
|
|
84
58
|
idsFor(registry: NormalizedId<RegistryId>): `${string}:${string}`[];
|
|
85
59
|
asResult(): Result;
|
|
@@ -87,3 +61,9 @@ export declare class ListIngredient extends Ingredient {
|
|
|
87
61
|
export type ItemLikeIngredient = ItemTagIngredient | ItemIngredient;
|
|
88
62
|
export type FluidLikeIngredient = FluidTagIngredient | FluidIngredient;
|
|
89
63
|
export type BlockLikeIngredient = BlockTagIngredient | BlockIngredient;
|
|
64
|
+
export declare class ToolActionIngredient extends Ingredient {
|
|
65
|
+
readonly action: string;
|
|
66
|
+
constructor(action: string);
|
|
67
|
+
asResult(): Result;
|
|
68
|
+
idsFor(): never[];
|
|
69
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeId,
|
|
1
|
+
import { encodeId, toTag, } from "../id";
|
|
2
2
|
import { BlockResult, FluidResult, ItemResult } from "../result";
|
|
3
3
|
import { BUCKET } from "../units";
|
|
4
4
|
export class Ingredient {
|
|
@@ -28,11 +28,6 @@ export class ItemTagIngredient extends TagIngredient {
|
|
|
28
28
|
super(tag, "minecraft:item");
|
|
29
29
|
this.count = count;
|
|
30
30
|
}
|
|
31
|
-
serialize(_packFormat) {
|
|
32
|
-
const count = this.count === 1 ? undefined : this.count;
|
|
33
|
-
const tag = stripTag(this.tag);
|
|
34
|
-
return { tag, count };
|
|
35
|
-
}
|
|
36
31
|
}
|
|
37
32
|
export class FluidTagIngredient extends TagIngredient {
|
|
38
33
|
amount;
|
|
@@ -40,20 +35,11 @@ export class FluidTagIngredient extends TagIngredient {
|
|
|
40
35
|
super(tag, "minecraft:fluid");
|
|
41
36
|
this.amount = amount;
|
|
42
37
|
}
|
|
43
|
-
serialize(_packFormat) {
|
|
44
|
-
const { amount } = this;
|
|
45
|
-
const tag = stripTag(this.tag);
|
|
46
|
-
return { fluidTag: tag, amount };
|
|
47
|
-
}
|
|
48
38
|
}
|
|
49
39
|
export class BlockTagIngredient extends TagIngredient {
|
|
50
40
|
constructor(tag) {
|
|
51
41
|
super(tag, "minecraft:block");
|
|
52
42
|
}
|
|
53
|
-
serialize(_packFormat) {
|
|
54
|
-
const tag = stripTag(this.tag);
|
|
55
|
-
return { blockTag: tag };
|
|
56
|
-
}
|
|
57
43
|
}
|
|
58
44
|
export class RegistryEntryIngredient extends Ingredient {
|
|
59
45
|
registry;
|
|
@@ -75,11 +61,6 @@ export class ItemIngredient extends RegistryEntryIngredient {
|
|
|
75
61
|
super(id, "minecraft:item");
|
|
76
62
|
this.count = count;
|
|
77
63
|
}
|
|
78
|
-
serialize(_packFormat) {
|
|
79
|
-
const count = this.count === 1 ? undefined : this.count;
|
|
80
|
-
const id = encodeId(this.id);
|
|
81
|
-
return { item: id, count };
|
|
82
|
-
}
|
|
83
64
|
validate(lookup) {
|
|
84
65
|
lookup.validateEntry("minecraft:item", this.id);
|
|
85
66
|
}
|
|
@@ -95,11 +76,6 @@ export class FluidIngredient extends RegistryEntryIngredient {
|
|
|
95
76
|
this.amount = amount;
|
|
96
77
|
this.chance = chance;
|
|
97
78
|
}
|
|
98
|
-
serialize(_packFormat) {
|
|
99
|
-
const { amount } = this;
|
|
100
|
-
const id = encodeId(this.id);
|
|
101
|
-
return { fluid: id, amount };
|
|
102
|
-
}
|
|
103
79
|
validate(lookup) {
|
|
104
80
|
lookup.validateEntry("minecraft:fluid", this.id);
|
|
105
81
|
}
|
|
@@ -113,11 +89,6 @@ export class BlockIngredient extends RegistryEntryIngredient {
|
|
|
113
89
|
super(id, "minecraft:block");
|
|
114
90
|
this.weight = weight;
|
|
115
91
|
}
|
|
116
|
-
serialize(_packFormat) {
|
|
117
|
-
const { weight } = this;
|
|
118
|
-
const id = encodeId(this.id);
|
|
119
|
-
return { block: id, weight };
|
|
120
|
-
}
|
|
121
92
|
validate(lookup) {
|
|
122
93
|
lookup.validateEntry("minecraft:block", this.id);
|
|
123
94
|
}
|
|
@@ -131,9 +102,6 @@ export class ListIngredient extends Ingredient {
|
|
|
131
102
|
super();
|
|
132
103
|
this.entries = entries;
|
|
133
104
|
}
|
|
134
|
-
serialize(packFormat) {
|
|
135
|
-
return this.entries.map((it) => it.serialize(packFormat));
|
|
136
|
-
}
|
|
137
105
|
validate(lookup) {
|
|
138
106
|
this.entries.forEach((it) => it.validate(lookup));
|
|
139
107
|
}
|
|
@@ -144,4 +112,17 @@ export class ListIngredient extends Ingredient {
|
|
|
144
112
|
throw new Error("union ingredients cannot be transformed into a result");
|
|
145
113
|
}
|
|
146
114
|
}
|
|
115
|
+
export class ToolActionIngredient extends Ingredient {
|
|
116
|
+
action;
|
|
117
|
+
constructor(action) {
|
|
118
|
+
super();
|
|
119
|
+
this.action = action;
|
|
120
|
+
}
|
|
121
|
+
asResult() {
|
|
122
|
+
throw new Error("tool action ingredient cannot be transformed into a result");
|
|
123
|
+
}
|
|
124
|
+
idsFor() {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
147
128
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/ingredient/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/ingredient/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,QAAQ,EACR,KAAK,GAIN,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAe,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAgB,UAAU;IAC9B,QAAQ,CAAC,CAAiB,IAAS,CAAC;CAKrC;AAED,MAAM,OAAgB,aAAc,SAAQ,UAAU;IAKlC;IAJF,GAAG,CAAQ;IAE3B,YACE,KAAc,EACE,QAAkC;QAElD,KAAK,EAAE,CAAC;QAFQ,aAAQ,GAAR,QAAQ,CAA0B;QAGlD,2CAA2C;QAC3C,IAAI,CAAC,GAAG,GAA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AC/C,KAAK,EAAE,CAAC;QADkB,YAAO,GAAP,OAAO,CAAc;IAEjD,CAAC;IAEQ,QAAQ,CAAC,MAAsB;QACtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,CAAC;IAEQ,MAAM,CAAC,QAAkC;QAChD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEQ,QAAQ;QACf,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;CACF;AAMD,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IACtB;IAA5B,YAA4B,MAAc;QACxC,KAAK,EAAE,CAAC;QADkB,WAAM,GAAN,MAAM,CAAQ;IAE1C,CAAC;IAEQ,QAAQ;QACf,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -2,16 +2,8 @@ import { Ingredient } from ".";
|
|
|
2
2
|
import type RegistryLookup from "../../loader/registry";
|
|
3
3
|
import type { SemVerInput } from "../../packFormat";
|
|
4
4
|
import { IngredientMap, type IngredientMapInput } from "../../parser/recipe/ingredientMap";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
private readonly lookup;
|
|
8
|
-
private readonly deserializer;
|
|
5
|
+
import { VersionedSerializer } from "../serializer";
|
|
6
|
+
export default class IngredientSerializer extends VersionedSerializer<Ingredient> {
|
|
9
7
|
constructor(packFormat: SemVerInput, lookup: RegistryLookup);
|
|
10
|
-
serialize(ingredient: Ingredient): unknown;
|
|
11
|
-
serializeList(ingredients: Ingredient[]): unknown[];
|
|
12
|
-
private deserializeUnvalidated;
|
|
13
|
-
deserialize(input: unknown): Ingredient;
|
|
14
|
-
validated<T extends Ingredient>(ingredient: T): T;
|
|
15
|
-
createList(input: unknown[]): Ingredient[];
|
|
16
8
|
ingredientMap(input: IngredientMapInput): IngredientMap;
|
|
17
9
|
}
|
|
@@ -1,115 +1,54 @@
|
|
|
1
1
|
import { mapValues } from "lodash-es";
|
|
2
2
|
import z from "zod";
|
|
3
|
-
import { BlockIngredient, BlockTagIngredient, FluidIngredient, FluidTagIngredient, Ingredient, ItemIngredient, ItemTagIngredient, ListIngredient, } from ".";
|
|
4
|
-
import { IllegalShapeError, transformErrors } from "../../error";
|
|
3
|
+
import { BlockIngredient, BlockTagIngredient, FluidIngredient, FluidTagIngredient, Ingredient, ItemIngredient, ItemTagIngredient, ListIngredient, ToolActionIngredient, } from ".";
|
|
5
4
|
import { IngredientMap, } from "../../parser/recipe/ingredientMap";
|
|
6
5
|
import { AmountSchema, CountSchema } from "../fields";
|
|
7
|
-
import { IdSchema } from "../id";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const parsed = this.schemas.block.parse(input);
|
|
49
|
-
return new BlockIngredient(parsed.block);
|
|
50
|
-
}
|
|
51
|
-
if ("item" in input) {
|
|
52
|
-
const parsed = this.schemas.itemStack.parse(input);
|
|
53
|
-
return new ItemIngredient(parsed.item, parsed.count);
|
|
54
|
-
}
|
|
55
|
-
if ("fluid" in input) {
|
|
56
|
-
const parsed = this.schemas.fluidStack.parse(input);
|
|
57
|
-
return new FluidIngredient(parsed.fluid, parsed.amount);
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
export default class IngredientSerializer {
|
|
63
|
-
packFormat;
|
|
64
|
-
lookup;
|
|
65
|
-
deserializer;
|
|
6
|
+
import { IdSchema, stripTag } from "../id";
|
|
7
|
+
import { createSerializer, hasType, isObjectWith, VersionedSerializer, } from "../serializer";
|
|
8
|
+
const serializer15 = createSerializer((builder) => {
|
|
9
|
+
builder.deserializer((it) => typeof it === "string", (input) => {
|
|
10
|
+
if (input.startsWith("#")) {
|
|
11
|
+
return new ItemTagIngredient(input);
|
|
12
|
+
}
|
|
13
|
+
return new ItemIngredient(input);
|
|
14
|
+
});
|
|
15
|
+
builder.serializer(ListIngredient, (it, serialize) => it.entries.flatMap(serialize));
|
|
16
|
+
builder.deserializer(Array.isArray, (it, deserialize) => new ListIngredient(it.map(deserialize)));
|
|
17
|
+
const toolActionType = "farmersdelight:tool_action";
|
|
18
|
+
builder.register(ToolActionIngredient, hasType(toolActionType), z.object({
|
|
19
|
+
type: z.literal(toolActionType),
|
|
20
|
+
action: z.string().nonempty(),
|
|
21
|
+
}), (it) => new ToolActionIngredient(it.action), ({ action }) => ({ action, type: toolActionType }));
|
|
22
|
+
builder.register(ItemTagIngredient, isObjectWith("tag"), z.object({
|
|
23
|
+
tag: IdSchema,
|
|
24
|
+
count: CountSchema,
|
|
25
|
+
}), (it) => new ItemTagIngredient(it.tag, it.count), ({ count, tag }) => ({ tag: stripTag(tag), count }));
|
|
26
|
+
builder.register(FluidTagIngredient, isObjectWith("fluidTag"), z.object({
|
|
27
|
+
fluidTag: IdSchema,
|
|
28
|
+
amount: AmountSchema,
|
|
29
|
+
}), (it) => new FluidTagIngredient(it.fluidTag, it.amount), ({ amount, tag }) => ({ fluidTag: stripTag(tag), amount }));
|
|
30
|
+
builder.register(BlockTagIngredient, isObjectWith("blockTag"), z.object({
|
|
31
|
+
blockTag: IdSchema,
|
|
32
|
+
weight: z.number().optional(),
|
|
33
|
+
}), (it) => new BlockTagIngredient(it.blockTag), ({ tag }) => ({ blockTag: stripTag(tag) }));
|
|
34
|
+
builder.register(ItemIngredient, isObjectWith("item"), z.object({
|
|
35
|
+
item: IdSchema,
|
|
36
|
+
count: CountSchema,
|
|
37
|
+
}), (it) => new ItemIngredient(it.item, it.count), ({ id, ...rest }) => ({ item: id, ...rest }));
|
|
38
|
+
builder.register(FluidIngredient, isObjectWith("fluid"), z.object({
|
|
39
|
+
fluid: IdSchema,
|
|
40
|
+
amount: AmountSchema,
|
|
41
|
+
}), (it) => new FluidIngredient(it.fluid, it.amount), ({ id, ...rest }) => ({ fluid: id, ...rest }));
|
|
42
|
+
builder.register(BlockIngredient, isObjectWith("block"), z.object({
|
|
43
|
+
block: IdSchema,
|
|
44
|
+
}), (it) => new BlockIngredient(it.block), ({ id }) => ({ block: id }));
|
|
45
|
+
});
|
|
46
|
+
export default class IngredientSerializer extends VersionedSerializer {
|
|
66
47
|
constructor(packFormat, lookup) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.deserializer = new OldDeserializer();
|
|
70
|
-
}
|
|
71
|
-
serialize(ingredient) {
|
|
72
|
-
return ingredient.serialize(this.packFormat);
|
|
73
|
-
}
|
|
74
|
-
serializeList(ingredients) {
|
|
75
|
-
return ingredients.map((it) => this.serialize(it));
|
|
76
|
-
}
|
|
77
|
-
deserializeUnvalidated(input) {
|
|
78
|
-
if (input instanceof Ingredient)
|
|
79
|
-
return input;
|
|
80
|
-
if (!input)
|
|
81
|
-
throw new IllegalShapeError("ingredient input may not be null");
|
|
82
|
-
if (typeof input === "string") {
|
|
83
|
-
if (input.startsWith("#")) {
|
|
84
|
-
return this.deserializeUnvalidated(new ItemTagIngredient(input));
|
|
85
|
-
}
|
|
86
|
-
this.lookup.validateEntry("minecraft:item", input);
|
|
87
|
-
return new ItemIngredient(input);
|
|
88
|
-
}
|
|
89
|
-
if (Array.isArray(input)) {
|
|
90
|
-
return new ListIngredient(input.map((it) => this.deserializeUnvalidated(it)));
|
|
91
|
-
}
|
|
92
|
-
if (typeof input === "object") {
|
|
93
|
-
const deserialized = this.deserializer.deserialize(input);
|
|
94
|
-
if (deserialized)
|
|
95
|
-
return deserialized;
|
|
96
|
-
}
|
|
97
|
-
throw new IllegalShapeError(`unknown ingredient shape`, input);
|
|
98
|
-
}
|
|
99
|
-
deserialize(input) {
|
|
100
|
-
return transformErrors(() => {
|
|
101
|
-
const deserialized = this.deserializeUnvalidated(input);
|
|
102
|
-
deserialized.validate(this.lookup);
|
|
103
|
-
return deserialized;
|
|
48
|
+
super(packFormat, lookup, Ingredient, {
|
|
49
|
+
15: serializer15,
|
|
104
50
|
});
|
|
105
51
|
}
|
|
106
|
-
validated(ingredient) {
|
|
107
|
-
ingredient.validate(this.lookup);
|
|
108
|
-
return ingredient;
|
|
109
|
-
}
|
|
110
|
-
createList(input) {
|
|
111
|
-
return input.map((it) => this.deserialize(it));
|
|
112
|
-
}
|
|
113
52
|
ingredientMap(input) {
|
|
114
53
|
return new IngredientMap(mapValues(input, (it) => this.deserialize(it)));
|
|
115
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/common/ingredient/serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../src/common/ingredient/serializer.ts"],"names":[],"mappings":"AAAA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AY,CAAC,OAAO,CAAC,EACrB,CAAC,CAAC,MAAM,CAAC;QACP,KAAK,EAAE,QAAQ;KAChB,CAAC,EACF,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,CAAC,KAAK,CAAC,EACrC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,mBAA+B;IAC/E,YAAY,UAAuB,EAAE,MAAsB;QACzD,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE;YACpC,EAAE,EAAE,YAAY;SACjB,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,KAAyB;QACrC,OAAO,IAAI,aAAa,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type RegistryLookup from "../loader/registry";
|
|
3
|
-
import type { SemVerInput } from "../packFormat";
|
|
4
3
|
import type { NormalizedId } from "./id";
|
|
5
|
-
export interface
|
|
6
|
-
serialize(packFormat: SemVerInput): unknown;
|
|
4
|
+
export interface InputOutput {
|
|
7
5
|
validate(lookup: RegistryLookup): void;
|
|
8
6
|
idsFor(registry: NormalizedId<RegistryId>): NormalizedId<RegistryId>[];
|
|
9
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=inputOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputOutput.js","sourceRoot":"","sources":["../../src/common/inputOutput.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { BlockId, FluidId, ItemId, RegistryId } from "@adeficior/data-modifier/generated";
|
|
2
2
|
import type RegistryLookup from "../../loader/registry";
|
|
3
|
-
import type { SemVerInput } from "../../packFormat";
|
|
4
3
|
import { type IdInput, type NormalizedId } from "../id";
|
|
5
4
|
import { BlockIngredient, FluidIngredient, ItemIngredient, type Ingredient } from "../ingredient";
|
|
6
|
-
import type {
|
|
7
|
-
export declare abstract class Result implements
|
|
5
|
+
import type { InputOutput } from "../inputOutput";
|
|
6
|
+
export declare abstract class Result implements InputOutput {
|
|
8
7
|
validate(_: RegistryLookup): void;
|
|
9
|
-
abstract serialize(packFormat: SemVerInput): Record<string, unknown>;
|
|
10
8
|
abstract idsFor(registry: NormalizedId<RegistryId>): NormalizedId<RegistryId>[];
|
|
11
9
|
abstract asIngredient(): Ingredient;
|
|
12
10
|
}
|
|
@@ -20,11 +18,6 @@ export declare class ItemResult extends RegistryEntryResult<ItemId> {
|
|
|
20
18
|
readonly count: number;
|
|
21
19
|
readonly chance?: number | undefined;
|
|
22
20
|
constructor(id: IdInput<ItemId>, count?: number, chance?: number | undefined);
|
|
23
|
-
serialize(_packFormat: SemVerInput): {
|
|
24
|
-
item: `${string}:${string}`;
|
|
25
|
-
count: number | undefined;
|
|
26
|
-
chance: number | undefined;
|
|
27
|
-
};
|
|
28
21
|
validate(lookup: RegistryLookup): void;
|
|
29
22
|
asIngredient(): ItemIngredient;
|
|
30
23
|
}
|
|
@@ -32,19 +25,11 @@ export declare class FluidResult extends RegistryEntryResult<FluidId> {
|
|
|
32
25
|
readonly amount: number;
|
|
33
26
|
readonly chance?: number | undefined;
|
|
34
27
|
constructor(id: IdInput<FluidId>, amount?: number, chance?: number | undefined);
|
|
35
|
-
serialize(_packFormat: SemVerInput): {
|
|
36
|
-
fluid: `${string}:${string}`;
|
|
37
|
-
amount: number;
|
|
38
|
-
chance: number | undefined;
|
|
39
|
-
};
|
|
40
28
|
validate(lookup: RegistryLookup): void;
|
|
41
29
|
asIngredient(): FluidIngredient;
|
|
42
30
|
}
|
|
43
31
|
export declare class BlockResult extends RegistryEntryResult<BlockId> {
|
|
44
32
|
constructor(id: IdInput<BlockId>);
|
|
45
|
-
serialize(_packFormat: SemVerInput): {
|
|
46
|
-
block: `${string}:${string}`;
|
|
47
|
-
};
|
|
48
33
|
validate(lookup: RegistryLookup): void;
|
|
49
34
|
asIngredient(): BlockIngredient;
|
|
50
35
|
}
|
|
@@ -26,12 +26,6 @@ export class ItemResult extends RegistryEntryResult {
|
|
|
26
26
|
this.count = count;
|
|
27
27
|
this.chance = chance;
|
|
28
28
|
}
|
|
29
|
-
serialize(_packFormat) {
|
|
30
|
-
const { chance } = this;
|
|
31
|
-
const count = this.count === 1 ? undefined : this.count;
|
|
32
|
-
const id = encodeId(this.id);
|
|
33
|
-
return { item: id, count, chance };
|
|
34
|
-
}
|
|
35
29
|
validate(lookup) {
|
|
36
30
|
lookup.validateEntry("minecraft:item", this.id);
|
|
37
31
|
}
|
|
@@ -47,11 +41,6 @@ export class FluidResult extends RegistryEntryResult {
|
|
|
47
41
|
this.amount = amount;
|
|
48
42
|
this.chance = chance;
|
|
49
43
|
}
|
|
50
|
-
serialize(_packFormat) {
|
|
51
|
-
const { amount, chance } = this;
|
|
52
|
-
const id = encodeId(this.id);
|
|
53
|
-
return { fluid: id, amount, chance };
|
|
54
|
-
}
|
|
55
44
|
validate(lookup) {
|
|
56
45
|
lookup.validateEntry("minecraft:fluid", this.id);
|
|
57
46
|
}
|
|
@@ -63,10 +52,6 @@ export class BlockResult extends RegistryEntryResult {
|
|
|
63
52
|
constructor(id) {
|
|
64
53
|
super(id, "minecraft:block");
|
|
65
54
|
}
|
|
66
|
-
serialize(_packFormat) {
|
|
67
|
-
const id = encodeId(this.id);
|
|
68
|
-
return { block: id };
|
|
69
|
-
}
|
|
70
55
|
validate(lookup) {
|
|
71
56
|
lookup.validateEntry("minecraft:block", this.id);
|
|
72
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/result/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/result/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAmC,MAAM,OAAO,CAAC;AAClE,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,GAEf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,OAAgB,MAAM;IAC1B,QAAQ,CAAC,CAAiB,IAAS,CAAC;CAKrC;AAED,MAAM,OAAgB,mBAAsC,SAAQ,MAAM;IAKrD;IAJH,EAAE,CAAkB;IAEpC,YACE,KAAiB,EACA,QAAkC;QAEnD,KAAK,EAAE,CAAC;QAFS,aAAQ,GAAR,QAAQ,CAA0B;QAGnD,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAEQ,MAAM,CAAC,QAAkC;QAChD,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,MAAM,OAAO,UAAW,SAAQ,mBAA2B;IAGvC;IACA;IAHlB,YACE,EAAmB,EACH,QAAQ,CAAC,EACT,MAAe;QAE/B,KAAK,CAAC,EAAE,EAAE,gBAAgB,CAAC,CAAC;QAHZ,UAAK,GAAL,KAAK,CAAI;QACT,WAAM,GAAN,MAAM,CAAS;IAGjC,CAAC;IAEQ,QAAQ,CAAC,MAAsB;QACtC,MAAM,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IAEQ,YAAY;QACnB,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAED,MAAM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