@adeficior/data-modifier 1.0.0-rc.9
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/cli/codegen/registry.d.ts +3 -0
- package/dist/cli/codegen/registry.js +81 -0
- package/dist/cli/codegen/registry.js.map +1 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.js +60 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +34 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/common/id.d.ts +15 -0
- package/dist/common/id.js +42 -0
- package/dist/common/id.js.map +1 -0
- package/dist/common/ingredient.d.ts +49 -0
- package/dist/common/ingredient.js +108 -0
- package/dist/common/ingredient.js.map +1 -0
- package/dist/common/predicates.d.ts +7 -0
- package/dist/common/predicates.js +32 -0
- package/dist/common/predicates.js.map +1 -0
- package/dist/common/registry.d.ts +12 -0
- package/dist/common/registry.js +36 -0
- package/dist/common/registry.js.map +1 -0
- package/dist/common/result.d.ts +48 -0
- package/dist/common/result.js +37 -0
- package/dist/common/result.js.map +1 -0
- package/dist/emit/assets/blockstates.d.ts +18 -0
- package/dist/emit/assets/blockstates.js +46 -0
- package/dist/emit/assets/blockstates.js.map +1 -0
- package/dist/emit/assets/lang.d.ts +33 -0
- package/dist/emit/assets/lang.js +103 -0
- package/dist/emit/assets/lang.js.map +1 -0
- package/dist/emit/assets/models.d.ts +24 -0
- package/dist/emit/assets/models.js +59 -0
- package/dist/emit/assets/models.js.map +1 -0
- package/dist/emit/blacklist.d.ts +32 -0
- package/dist/emit/blacklist.js +99 -0
- package/dist/emit/blacklist.js.map +1 -0
- package/dist/emit/content/blockDefinition.d.ts +58 -0
- package/dist/emit/content/blockDefinition.js +58 -0
- package/dist/emit/content/blockDefinition.js.map +1 -0
- package/dist/emit/content/innerBlockDefinition.d.ts +12 -0
- package/dist/emit/content/innerBlockDefinition.js +32 -0
- package/dist/emit/content/innerBlockDefinition.js.map +1 -0
- package/dist/emit/content/itemDefinition.d.ts +58 -0
- package/dist/emit/content/itemDefinition.js +54 -0
- package/dist/emit/content/itemDefinition.js.map +1 -0
- package/dist/emit/custom.d.ts +15 -0
- package/dist/emit/custom.js +42 -0
- package/dist/emit/custom.js.map +1 -0
- package/dist/emit/data/loot.d.ts +48 -0
- package/dist/emit/data/loot.js +108 -0
- package/dist/emit/data/loot.js.map +1 -0
- package/dist/emit/data/recipe.d.ts +46 -0
- package/dist/emit/data/recipe.js +106 -0
- package/dist/emit/data/recipe.js.map +1 -0
- package/dist/emit/data/tags.d.ts +38 -0
- package/dist/emit/data/tags.js +115 -0
- package/dist/emit/data/tags.js.map +1 -0
- package/dist/emit/index.d.ts +11 -0
- package/dist/emit/index.js +1 -0
- package/dist/emit/index.js.map +1 -0
- package/dist/emit/polytoneTabs.d.ts +65 -0
- package/dist/emit/polytoneTabs.js +101 -0
- package/dist/emit/polytoneTabs.js.map +1 -0
- package/dist/emit/rule/index.d.ts +10 -0
- package/dist/emit/rule/index.js +10 -0
- package/dist/emit/rule/index.js.map +1 -0
- package/dist/emit/rule/lootTable.d.ts +14 -0
- package/dist/emit/rule/lootTable.js +47 -0
- package/dist/emit/rule/lootTable.js.map +1 -0
- package/dist/emit/rule/recipe.d.ts +16 -0
- package/dist/emit/rule/recipe.js +29 -0
- package/dist/emit/rule/recipe.js.map +1 -0
- package/dist/emit/ruled.d.ts +18 -0
- package/dist/emit/ruled.js +47 -0
- package/dist/emit/ruled.js.map +1 -0
- package/dist/error.d.ts +12 -0
- package/dist/error.js +45 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/index.d.ts +16 -0
- package/dist/loader/index.js +40 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/loader/lang.d.ts +7 -0
- package/dist/loader/lang.js +12 -0
- package/dist/loader/lang.js.map +1 -0
- package/dist/loader/loot.d.ts +7 -0
- package/dist/loader/loot.js +12 -0
- package/dist/loader/loot.js.map +1 -0
- package/dist/loader/pack.d.ts +62 -0
- package/dist/loader/pack.js +131 -0
- package/dist/loader/pack.js.map +1 -0
- package/dist/loader/recipe.d.ts +25 -0
- package/dist/loader/recipe.js +207 -0
- package/dist/loader/recipe.js.map +1 -0
- package/dist/loader/registry/dump.d.ts +19 -0
- package/dist/loader/registry/dump.js +74 -0
- package/dist/loader/registry/dump.js.map +1 -0
- package/dist/loader/registry/empty.d.ts +11 -0
- package/dist/loader/registry/empty.js +22 -0
- package/dist/loader/registry/empty.js.map +1 -0
- package/dist/loader/registry/index.d.ts +11 -0
- package/dist/loader/registry/index.js +1 -0
- package/dist/loader/registry/index.js.map +1 -0
- package/dist/loader/tags.d.ts +26 -0
- package/dist/loader/tags.js +131 -0
- package/dist/loader/tags.js.map +1 -0
- package/dist/parser/adAstra.d.ts +11 -0
- package/dist/parser/adAstra.js +6 -0
- package/dist/parser/adAstra.js.map +1 -0
- package/dist/parser/botania.d.ts +20 -0
- package/dist/parser/botania.js +11 -0
- package/dist/parser/botania.js.map +1 -0
- package/dist/parser/create.d.ts +4 -0
- package/dist/parser/create.js +3 -0
- package/dist/parser/create.js.map +1 -0
- package/dist/parser/farmersdelight.d.ts +4 -0
- package/dist/parser/farmersdelight.js +3 -0
- package/dist/parser/farmersdelight.js.map +1 -0
- package/dist/parser/index.d.ts +13 -0
- package/dist/parser/index.js +8 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/lootTable.d.ts +7 -0
- package/dist/parser/lootTable.js +70 -0
- package/dist/parser/lootTable.js.map +1 -0
- package/dist/parser/recipe/adAstra/conversion.d.ts +20 -0
- package/dist/parser/recipe/adAstra/conversion.js +33 -0
- package/dist/parser/recipe/adAstra/conversion.js.map +1 -0
- package/dist/parser/recipe/adAstra/hammering.d.ts +18 -0
- package/dist/parser/recipe/adAstra/hammering.js +27 -0
- package/dist/parser/recipe/adAstra/hammering.js.map +1 -0
- package/dist/parser/recipe/adAstra/index.d.ts +5 -0
- package/dist/parser/recipe/adAstra/index.js +1 -0
- package/dist/parser/recipe/adAstra/index.js.map +1 -0
- package/dist/parser/recipe/adAstra/inputOutput.d.ts +24 -0
- package/dist/parser/recipe/adAstra/inputOutput.js +42 -0
- package/dist/parser/recipe/adAstra/inputOutput.js.map +1 -0
- package/dist/parser/recipe/adAstra/nasaWorkbench.d.ts +20 -0
- package/dist/parser/recipe/adAstra/nasaWorkbench.js +30 -0
- package/dist/parser/recipe/adAstra/nasaWorkbench.js.map +1 -0
- package/dist/parser/recipe/adAstra/spaceStation.d.ts +19 -0
- package/dist/parser/recipe/adAstra/spaceStation.js +27 -0
- package/dist/parser/recipe/adAstra/spaceStation.js.map +1 -0
- package/dist/parser/recipe/botania/apothecary.d.ts +19 -0
- package/dist/parser/recipe/botania/apothecary.js +28 -0
- package/dist/parser/recipe/botania/apothecary.js.map +1 -0
- package/dist/parser/recipe/botania/brew.d.ts +18 -0
- package/dist/parser/recipe/botania/brew.js +24 -0
- package/dist/parser/recipe/botania/brew.js.map +1 -0
- package/dist/parser/recipe/botania/elvenTrade.d.ts +19 -0
- package/dist/parser/recipe/botania/elvenTrade.js +27 -0
- package/dist/parser/recipe/botania/elvenTrade.js.map +1 -0
- package/dist/parser/recipe/botania/gogWrapper.d.ts +22 -0
- package/dist/parser/recipe/botania/gogWrapper.js +34 -0
- package/dist/parser/recipe/botania/gogWrapper.js.map +1 -0
- package/dist/parser/recipe/botania/manaInfusion.d.ts +21 -0
- package/dist/parser/recipe/botania/manaInfusion.js +33 -0
- package/dist/parser/recipe/botania/manaInfusion.js.map +1 -0
- package/dist/parser/recipe/botania/nbtWrapper.d.ts +20 -0
- package/dist/parser/recipe/botania/nbtWrapper.js +30 -0
- package/dist/parser/recipe/botania/nbtWrapper.js.map +1 -0
- package/dist/parser/recipe/botania/orechid.d.ts +35 -0
- package/dist/parser/recipe/botania/orechid.js +74 -0
- package/dist/parser/recipe/botania/orechid.js.map +1 -0
- package/dist/parser/recipe/botania/pureDaisy.d.ts +19 -0
- package/dist/parser/recipe/botania/pureDaisy.js +30 -0
- package/dist/parser/recipe/botania/pureDaisy.js.map +1 -0
- package/dist/parser/recipe/botania/runicAltar.d.ts +19 -0
- package/dist/parser/recipe/botania/runicAltar.js +27 -0
- package/dist/parser/recipe/botania/runicAltar.js.map +1 -0
- package/dist/parser/recipe/botania/terraPlate.d.ts +19 -0
- package/dist/parser/recipe/botania/terraPlate.js +27 -0
- package/dist/parser/recipe/botania/terraPlate.js.map +1 -0
- package/dist/parser/recipe/create/assembly.d.ts +25 -0
- package/dist/parser/recipe/create/assembly.js +45 -0
- package/dist/parser/recipe/create/assembly.js.map +1 -0
- package/dist/parser/recipe/create/processing.d.ts +21 -0
- package/dist/parser/recipe/create/processing.js +27 -0
- package/dist/parser/recipe/create/processing.js.map +1 -0
- package/dist/parser/recipe/farmersdelight/cooking.d.ts +22 -0
- package/dist/parser/recipe/farmersdelight/cooking.js +29 -0
- package/dist/parser/recipe/farmersdelight/cooking.js.map +1 -0
- package/dist/parser/recipe/farmersdelight/cutting.d.ts +23 -0
- package/dist/parser/recipe/farmersdelight/cutting.js +38 -0
- package/dist/parser/recipe/farmersdelight/cutting.js.map +1 -0
- package/dist/parser/recipe/forge/conditional.d.ts +25 -0
- package/dist/parser/recipe/forge/conditional.js +45 -0
- package/dist/parser/recipe/forge/conditional.js.map +1 -0
- package/dist/parser/recipe/ignored.d.ts +10 -0
- package/dist/parser/recipe/ignored.js +16 -0
- package/dist/parser/recipe/ignored.js.map +1 -0
- package/dist/parser/recipe/index.d.ts +19 -0
- package/dist/parser/recipe/index.js +22 -0
- package/dist/parser/recipe/index.js.map +1 -0
- package/dist/parser/recipe/quark/exclusion.d.ts +20 -0
- package/dist/parser/recipe/quark/exclusion.js +32 -0
- package/dist/parser/recipe/quark/exclusion.js.map +1 -0
- package/dist/parser/recipe/roots/component.d.ts +18 -0
- package/dist/parser/recipe/roots/component.js +24 -0
- package/dist/parser/recipe/roots/component.js.map +1 -0
- package/dist/parser/recipe/roots/ritual.d.ts +22 -0
- package/dist/parser/recipe/roots/ritual.js +32 -0
- package/dist/parser/recipe/roots/ritual.js.map +1 -0
- package/dist/parser/recipe/sullys/polishing.d.ts +19 -0
- package/dist/parser/recipe/sullys/polishing.js +27 -0
- package/dist/parser/recipe/sullys/polishing.js.map +1 -0
- package/dist/parser/recipe/thermal/catalyst.d.ts +22 -0
- package/dist/parser/recipe/thermal/catalyst.js +24 -0
- package/dist/parser/recipe/thermal/catalyst.js.map +1 -0
- package/dist/parser/recipe/thermal/fuel.d.ts +18 -0
- package/dist/parser/recipe/thermal/fuel.js +24 -0
- package/dist/parser/recipe/thermal/fuel.js.map +1 -0
- package/dist/parser/recipe/thermal/index.d.ts +22 -0
- package/dist/parser/recipe/thermal/index.js +36 -0
- package/dist/parser/recipe/thermal/index.js.map +1 -0
- package/dist/parser/recipe/thermal/ingredient.d.ts +21 -0
- package/dist/parser/recipe/thermal/ingredient.js +43 -0
- package/dist/parser/recipe/thermal/ingredient.js.map +1 -0
- package/dist/parser/recipe/thermal/treeExtraction.d.ts +24 -0
- package/dist/parser/recipe/thermal/treeExtraction.js +47 -0
- package/dist/parser/recipe/thermal/treeExtraction.js.map +1 -0
- package/dist/parser/recipe/vanilla/shaped.d.ts +19 -0
- package/dist/parser/recipe/vanilla/shaped.js +28 -0
- package/dist/parser/recipe/vanilla/shaped.js.map +1 -0
- package/dist/parser/recipe/vanilla/shapeless.d.ts +18 -0
- package/dist/parser/recipe/vanilla/shapeless.js +27 -0
- package/dist/parser/recipe/vanilla/shapeless.js.map +1 -0
- package/dist/parser/recipe/vanilla/smelting.d.ts +19 -0
- package/dist/parser/recipe/vanilla/smelting.js +27 -0
- package/dist/parser/recipe/vanilla/smelting.js.map +1 -0
- package/dist/parser/recipe/vanilla/smithing.d.ts +19 -0
- package/dist/parser/recipe/vanilla/smithing.js +28 -0
- package/dist/parser/recipe/vanilla/smithing.js.map +1 -0
- package/dist/parser/recipe/vanilla/stonecutting.d.ts +20 -0
- package/dist/parser/recipe/vanilla/stonecutting.js +36 -0
- package/dist/parser/recipe/vanilla/stonecutting.js.map +1 -0
- package/dist/parser/roots.d.ts +4 -0
- package/dist/parser/roots.js +3 -0
- package/dist/parser/roots.js.map +1 -0
- package/dist/parser/thermal.d.ts +10 -0
- package/dist/parser/thermal.js +6 -0
- package/dist/parser/thermal.js.map +1 -0
- package/dist/schema/assets/blockstate.d.ts +10 -0
- package/dist/schema/assets/blockstate.js +1 -0
- package/dist/schema/assets/blockstate.js.map +1 -0
- package/dist/schema/assets/lang.d.ts +3 -0
- package/dist/schema/assets/lang.js +3 -0
- package/dist/schema/assets/lang.js.map +1 -0
- package/dist/schema/assets/model.d.ts +27 -0
- package/dist/schema/assets/model.js +1 -0
- package/dist/schema/assets/model.js.map +1 -0
- package/dist/schema/content/blockDefinition.d.ts +11 -0
- package/dist/schema/content/blockDefinition.js +1 -0
- package/dist/schema/content/blockDefinition.js.map +1 -0
- package/dist/schema/content/itemDefinition.d.ts +14 -0
- package/dist/schema/content/itemDefinition.js +1 -0
- package/dist/schema/content/itemDefinition.js.map +1 -0
- package/dist/schema/data/loot.d.ts +1151 -0
- package/dist/schema/data/loot.js +76 -0
- package/dist/schema/data/loot.js.map +1 -0
- package/dist/schema/data/recipe.d.ts +13 -0
- package/dist/schema/data/recipe.js +1 -0
- package/dist/schema/data/recipe.js.map +1 -0
- package/dist/schema/data/tag.d.ts +11 -0
- package/dist/schema/data/tag.js +6 -0
- package/dist/schema/data/tag.js.map +1 -0
- package/dist/stubTypes.d.ts +7 -0
- package/dist/stubTypes.js +1 -0
- package/dist/stubTypes.js.map +1 -0
- package/dist/textHelper.d.ts +3 -0
- package/dist/textHelper.js +20 -0
- package/dist/textHelper.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Acceptor } from "@adeficior/pack-resolver";
|
|
2
|
+
import type { IdInput } from "../../common/id.js";
|
|
3
|
+
import type { BlockDefinition } from "../../schema/content/blockDefinition.js";
|
|
4
|
+
import type { ItemDefinition, ItemProperties } from "../../schema/content/itemDefinition.js";
|
|
5
|
+
import type { BlockstateRules } from "../assets/blockstates.js";
|
|
6
|
+
import type { ModelRulesGroup } from "../assets/models.js";
|
|
7
|
+
import type { LootRules } from "../data/loot.js";
|
|
8
|
+
import type { ClearableEmitter } from "../index.js";
|
|
9
|
+
import type { BlockDefinitionRulesWithoutId } from "./innerBlockDefinition.js";
|
|
10
|
+
export type ItemDefinitionOptions = Readonly<{
|
|
11
|
+
model?: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
type ExtendedItemProperties = ItemProperties & {
|
|
14
|
+
type?: string;
|
|
15
|
+
};
|
|
16
|
+
type BlockDefinitionInput = BlockDefinition | ((rules: BlockDefinitionRulesWithoutId) => BlockDefinition);
|
|
17
|
+
export interface ItemDefinitionRules {
|
|
18
|
+
add<T extends ItemDefinition>(id: IdInput, definition: T): T;
|
|
19
|
+
basic(id: IdInput, properties?: ExtendedItemProperties, options?: ItemDefinitionOptions): ItemDefinition;
|
|
20
|
+
blockItem(id: IdInput, properties?: ExtendedItemProperties & {
|
|
21
|
+
block: BlockDefinitionInput;
|
|
22
|
+
}, options?: ItemDefinitionOptions): ItemDefinition;
|
|
23
|
+
}
|
|
24
|
+
export default class ItemDefinitionEmitter implements ItemDefinitionRules, ClearableEmitter {
|
|
25
|
+
private readonly models;
|
|
26
|
+
private readonly blockstates;
|
|
27
|
+
private readonly loot;
|
|
28
|
+
private readonly custom;
|
|
29
|
+
constructor(models: ModelRulesGroup, blockstates: BlockstateRules, loot: LootRules);
|
|
30
|
+
private filePath;
|
|
31
|
+
add<T extends ItemDefinition>(id: IdInput, definition: T): T;
|
|
32
|
+
clear(): void;
|
|
33
|
+
emit(acceptor: Acceptor): Promise<void>;
|
|
34
|
+
basic(id: IdInput, { type, ...properties }?: ExtendedItemProperties, options?: ItemDefinitionOptions): {
|
|
35
|
+
type: string;
|
|
36
|
+
properties: {
|
|
37
|
+
rarity?: import("../../index.js").Rarity;
|
|
38
|
+
stack_size?: number;
|
|
39
|
+
creative_tab?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
private createBlockDefinition;
|
|
43
|
+
blockItem(id: IdInput, { block, type, ...properties }: ExtendedItemProperties & {
|
|
44
|
+
block: BlockDefinitionInput;
|
|
45
|
+
}, options?: ItemDefinitionOptions): {
|
|
46
|
+
type: string;
|
|
47
|
+
block: Readonly<{
|
|
48
|
+
type: string;
|
|
49
|
+
properties: import("../../index.js").BlockProperties | string;
|
|
50
|
+
}>;
|
|
51
|
+
properties: {
|
|
52
|
+
rarity?: import("../../index.js").Rarity;
|
|
53
|
+
stack_size?: number;
|
|
54
|
+
creative_tab?: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { prefix } from "../../common/id.js";
|
|
2
|
+
import CustomEmitter from "../custom.js";
|
|
3
|
+
import createInnerBlockDefinitionBuilder from "./innerBlockDefinition.js";
|
|
4
|
+
export default class ItemDefinitionEmitter {
|
|
5
|
+
models;
|
|
6
|
+
blockstates;
|
|
7
|
+
loot;
|
|
8
|
+
custom = new CustomEmitter(this.filePath);
|
|
9
|
+
constructor(models, blockstates, loot) {
|
|
10
|
+
this.models = models;
|
|
11
|
+
this.blockstates = blockstates;
|
|
12
|
+
this.loot = loot;
|
|
13
|
+
}
|
|
14
|
+
filePath(id) {
|
|
15
|
+
return `content/${id.namespace}/item/${id.path}.json`;
|
|
16
|
+
}
|
|
17
|
+
add(id, definition) {
|
|
18
|
+
this.custom.add(id, definition);
|
|
19
|
+
return definition;
|
|
20
|
+
}
|
|
21
|
+
clear() {
|
|
22
|
+
this.custom.clear();
|
|
23
|
+
}
|
|
24
|
+
emit(acceptor) {
|
|
25
|
+
return this.custom.emit(acceptor);
|
|
26
|
+
}
|
|
27
|
+
basic(id, { type, ...properties } = {}, options) {
|
|
28
|
+
if (options?.model !== false)
|
|
29
|
+
this.models.items.flat(id);
|
|
30
|
+
return this.add(id, {
|
|
31
|
+
type: type ?? "basic",
|
|
32
|
+
properties,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
createBlockDefinition(id, input) {
|
|
36
|
+
if (typeof input !== "function")
|
|
37
|
+
return input;
|
|
38
|
+
const blockBuilder = createInnerBlockDefinitionBuilder(id, this.models.blocks, this.blockstates, this.loot);
|
|
39
|
+
return input(blockBuilder);
|
|
40
|
+
}
|
|
41
|
+
blockItem(id, { block, type, ...properties }, options) {
|
|
42
|
+
if (options?.model !== false) {
|
|
43
|
+
const parent = prefix(id, "block/");
|
|
44
|
+
this.models.items.add(id, { parent });
|
|
45
|
+
}
|
|
46
|
+
const blockDefinition = this.createBlockDefinition(id, block);
|
|
47
|
+
return this.add(id, {
|
|
48
|
+
type: type ?? "block_item",
|
|
49
|
+
block: blockDefinition,
|
|
50
|
+
properties,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=itemDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemDefinition.js","sourceRoot":"","sources":["../../../src/emit/content/itemDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAQ5C,OAAO,aAAa,MAAM,cAAc,CAAC;AAIzC,OAAO,iCAAiC,MAAM,2BAA2B,CAAC;AAgC1E,MAAM,CAAC,OAAO,OAAO,qBAAqB;IAMrB;IACA;IACA;IALF,MAAM,GAAG,IAAI,aAAa,CAAiB,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE3E,YACmB,MAAuB,EACvB,WAA4B,EAC5B,IAAe;QAFf,WAAM,GAAN,MAAM,CAAiB;QACvB,gBAAW,GAAX,WAAW,CAAiB;QAC5B,SAAI,GAAJ,IAAI,CAAW;IAC/B,CAAC;IAEI,QAAQ,CAAC,EAA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pC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACxC,CAAC;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAE9D,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;YAClB,IAAI,EAAE,IAAI,IAAI,YAAY;YAC1B,KAAK,EAAE,eAAe;YACtB,UAAU;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Acceptor } from "@adeficior/pack-resolver";
|
|
2
|
+
import type { IdInput } from "../common/id.js";
|
|
3
|
+
import type { PathProvider } from "./index.js";
|
|
4
|
+
export default class CustomEmitter<TEntry> {
|
|
5
|
+
private readonly pathProvider;
|
|
6
|
+
private readonly encoder;
|
|
7
|
+
constructor(pathProvider: PathProvider, encoder?: (value: TEntry) => string | Promise<string>);
|
|
8
|
+
private readonly customEntries;
|
|
9
|
+
clear(): void;
|
|
10
|
+
add(id: IdInput, value: TEntry): void;
|
|
11
|
+
merge(id: IdInput, entry: TEntry, merger: (a: TEntry, b: TEntry) => TEntry): void;
|
|
12
|
+
modify(id: IdInput, factory: (existing?: TEntry) => TEntry): void;
|
|
13
|
+
emit(acceptor: Acceptor): Promise<void>;
|
|
14
|
+
has(id: IdInput): boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createId } from "../common/id.js";
|
|
2
|
+
import Registry from "../common/registry.js";
|
|
3
|
+
import { toJson } from "../textHelper.js";
|
|
4
|
+
export default class CustomEmitter {
|
|
5
|
+
pathProvider;
|
|
6
|
+
encoder;
|
|
7
|
+
constructor(pathProvider, encoder = toJson) {
|
|
8
|
+
this.pathProvider = pathProvider;
|
|
9
|
+
this.encoder = encoder;
|
|
10
|
+
}
|
|
11
|
+
customEntries = new Registry();
|
|
12
|
+
clear() {
|
|
13
|
+
this.customEntries.clear();
|
|
14
|
+
}
|
|
15
|
+
add(id, value) {
|
|
16
|
+
this.customEntries.set(createId(id), value);
|
|
17
|
+
}
|
|
18
|
+
merge(id, entry, merger) {
|
|
19
|
+
this.modify(id, (existing) => {
|
|
20
|
+
if (existing)
|
|
21
|
+
return merger(existing, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
modify(id, factory) {
|
|
26
|
+
const existing = this.customEntries.get(id);
|
|
27
|
+
if (existing)
|
|
28
|
+
this.add(id, factory(existing));
|
|
29
|
+
else
|
|
30
|
+
this.add(id, factory());
|
|
31
|
+
}
|
|
32
|
+
async emit(acceptor) {
|
|
33
|
+
await this.customEntries.forEachAsync(async (entry, id) => {
|
|
34
|
+
const path = this.pathProvider(id);
|
|
35
|
+
acceptor(path, await this.encoder(entry));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
has(id) {
|
|
39
|
+
return this.customEntries.has(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/emit/custom.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,MAAM,CAAC,OAAO,OAAO,aAAa;IAEb;IACA;IAFnB,YACmB,YAA0B,EAC1B,UAEe,MAAM;QAHrB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,YAAO,GAAP,OAAO,CAEc;IACrC,CAAC;IAEa,aAAa,GAAG,IAAI,QAAQ,EAAU,CAAC;IAExD,KAAK;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,GAAG,CAAC,EAAW,EAAE,KAAa;QAC5B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,EAAW,EAAE,KAAa,EAAE,MAAwC;QACxE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC3B,IAAI,QAAQ;gBAAE,OAAO,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC7C,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,EAAW,EAAE,OAAsC;QACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,QAAQ;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;;YACzC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAkB;QAC3B,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YACxD,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAED,GAAG,CAAC,EAAW;QACb,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
2
|
+
import type { IdInput, NormalizedId } from "../../common/id.js";
|
|
3
|
+
import type { CommonTest, IngredientInput, IngredientTest, Predicate } from "../../common/ingredient.js";
|
|
4
|
+
import type RegistryLookup from "../../loader/registry/index.js";
|
|
5
|
+
import type { TagRegistryHolder } from "../../loader/tags.js";
|
|
6
|
+
import type { LootItemInput } from "../../parser/lootTable.js";
|
|
7
|
+
import type { LootModifier, LootTable } from "../../schema/data/loot.js";
|
|
8
|
+
import type { ClearableEmitter, RegistryProvider } from "../index.js";
|
|
9
|
+
export declare const EMPTY_LOOT_TABLE: LootTable;
|
|
10
|
+
export declare const EMPTY_LOOT_MODIFIER: LootModifier;
|
|
11
|
+
type LootTableTest = Readonly<{
|
|
12
|
+
id?: CommonTest<NormalizedId>;
|
|
13
|
+
output?: IngredientTest;
|
|
14
|
+
}>;
|
|
15
|
+
export interface LootRules {
|
|
16
|
+
replaceOutput(from: IngredientTest, to: LootItemInput, additionalTests?: LootTableTest): void;
|
|
17
|
+
removeOutput(from: IngredientTest, additionalTests?: LootTableTest): void;
|
|
18
|
+
add(id: IdInput, value: LootTable): void;
|
|
19
|
+
disable(test: LootTableTest): void;
|
|
20
|
+
block(id: IdInput): void;
|
|
21
|
+
addModifier<T extends LootModifier>(id: IdInput, value: T): void;
|
|
22
|
+
disabledModifier(id: IdInput): void;
|
|
23
|
+
}
|
|
24
|
+
export default class LootTableEmitter implements LootRules, ClearableEmitter {
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly lootTables;
|
|
27
|
+
private readonly tags;
|
|
28
|
+
private readonly lookup;
|
|
29
|
+
private readonly packFormat;
|
|
30
|
+
private readonly customTables;
|
|
31
|
+
private readonly customModifiers;
|
|
32
|
+
private readonly ruled;
|
|
33
|
+
constructor(logger: Logger, lootTables: RegistryProvider<LootTable>, tags: TagRegistryHolder, lookup: () => RegistryLookup, packFormat: number);
|
|
34
|
+
private tablePath;
|
|
35
|
+
private modifierPath;
|
|
36
|
+
clear(): void;
|
|
37
|
+
emit(acceptor: Acceptor): Promise<void>;
|
|
38
|
+
resolveIngredientTest(test: IngredientTest): Predicate<IngredientInput>;
|
|
39
|
+
private resolveLootTableTest;
|
|
40
|
+
add(id: IdInput, value: LootTable): void;
|
|
41
|
+
disable(test: LootTableTest): void;
|
|
42
|
+
replaceOutput(from: IngredientTest, to: LootItemInput, additionalTests?: LootTableTest): void;
|
|
43
|
+
removeOutput(from: IngredientTest, additionalTests?: LootTableTest): void;
|
|
44
|
+
block(id: IdInput): void;
|
|
45
|
+
disabledModifier(id: IdInput): void;
|
|
46
|
+
addModifier<T extends LootModifier>(id: IdInput, value: T): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { encodeId, prefix } from "../../common/id.js";
|
|
2
|
+
import { resolveIngredientTest } from "../../common/ingredient.js";
|
|
3
|
+
import { resolveIDTest } from "../../common/predicates.js";
|
|
4
|
+
import { createLootEntry, replaceItemInTable } from "../../parser/lootTable.js";
|
|
5
|
+
import { EmptyLootEntry, LootTableSchema } from "../../schema/data/loot.js";
|
|
6
|
+
import CustomEmitter from "../custom.js";
|
|
7
|
+
import LootTableRule from "../rule/lootTable.js";
|
|
8
|
+
import RuledEmitter from "../ruled.js";
|
|
9
|
+
export const EMPTY_LOOT_TABLE = {
|
|
10
|
+
type: "minecraft:empty",
|
|
11
|
+
pools: [],
|
|
12
|
+
};
|
|
13
|
+
export const EMPTY_LOOT_MODIFIER = {
|
|
14
|
+
type: "noop",
|
|
15
|
+
};
|
|
16
|
+
export default class LootTableEmitter {
|
|
17
|
+
logger;
|
|
18
|
+
lootTables;
|
|
19
|
+
tags;
|
|
20
|
+
lookup;
|
|
21
|
+
packFormat;
|
|
22
|
+
customTables = new CustomEmitter((it) => this.tablePath(it));
|
|
23
|
+
customModifiers = new CustomEmitter((it) => this.modifierPath(it));
|
|
24
|
+
ruled;
|
|
25
|
+
constructor(logger, lootTables, tags, lookup, packFormat) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.lootTables = lootTables;
|
|
28
|
+
this.tags = tags;
|
|
29
|
+
this.lookup = lookup;
|
|
30
|
+
this.packFormat = packFormat;
|
|
31
|
+
this.ruled = new RuledEmitter(this.logger, this.lootTables, (id) => this.tablePath(id), EMPTY_LOOT_TABLE, (id) => this.customTables.has(id));
|
|
32
|
+
}
|
|
33
|
+
tablePath(id) {
|
|
34
|
+
const folder = this.packFormat > 44 ? "loot_table" : "loot_tables";
|
|
35
|
+
return `data/${id.namespace}/${folder}/${id.path}.json`;
|
|
36
|
+
}
|
|
37
|
+
modifierPath(id) {
|
|
38
|
+
return `data/${id.namespace}/loot_modifiers/${id.path}.json`;
|
|
39
|
+
}
|
|
40
|
+
clear() {
|
|
41
|
+
this.customTables.clear();
|
|
42
|
+
this.customModifiers.clear();
|
|
43
|
+
this.ruled.clear();
|
|
44
|
+
}
|
|
45
|
+
async emit(acceptor) {
|
|
46
|
+
await Promise.all([
|
|
47
|
+
this.ruled.emit(acceptor),
|
|
48
|
+
this.customTables.emit(acceptor),
|
|
49
|
+
this.customModifiers.emit(acceptor),
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
resolveIngredientTest(test) {
|
|
53
|
+
return resolveIngredientTest(test, this.tags, this.lookup());
|
|
54
|
+
}
|
|
55
|
+
resolveLootTableTest(test) {
|
|
56
|
+
const id = [];
|
|
57
|
+
const output = [];
|
|
58
|
+
if (test.id)
|
|
59
|
+
id.push(resolveIDTest(test.id));
|
|
60
|
+
if (test.output)
|
|
61
|
+
output.push(this.resolveIngredientTest(test.output));
|
|
62
|
+
return { id, output };
|
|
63
|
+
}
|
|
64
|
+
add(id, value) {
|
|
65
|
+
this.customTables.add(id, LootTableSchema.parse(value));
|
|
66
|
+
}
|
|
67
|
+
disable(test) {
|
|
68
|
+
const predicates = this.resolveLootTableTest(test);
|
|
69
|
+
this.ruled.addRule(new LootTableRule(["remove output", test], predicates.id, predicates.output, () => null));
|
|
70
|
+
}
|
|
71
|
+
replaceOutput(from, to, additionalTests = {}) {
|
|
72
|
+
const predicates = this.resolveLootTableTest(additionalTests);
|
|
73
|
+
const outputPredicate = this.resolveIngredientTest(from);
|
|
74
|
+
const replacer = replaceItemInTable(outputPredicate, createLootEntry(to, this.lookup()));
|
|
75
|
+
this.ruled.addRule(new LootTableRule(["replace output", from, "with", to, additionalTests], predicates.id, [outputPredicate, ...predicates.output], replacer));
|
|
76
|
+
}
|
|
77
|
+
removeOutput(from, additionalTests) {
|
|
78
|
+
this.replaceOutput(from, EmptyLootEntry, additionalTests);
|
|
79
|
+
}
|
|
80
|
+
block(id) {
|
|
81
|
+
this.add(prefix(id, "blocks/"), {
|
|
82
|
+
type: "minecraft:block",
|
|
83
|
+
pools: [
|
|
84
|
+
{
|
|
85
|
+
rolls: 1,
|
|
86
|
+
entries: [
|
|
87
|
+
{
|
|
88
|
+
type: "minecraft:item",
|
|
89
|
+
name: encodeId(id),
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
conditions: [
|
|
93
|
+
{
|
|
94
|
+
condition: "minecraft:survives_explosion",
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
disabledModifier(id) {
|
|
102
|
+
this.addModifier(id, EMPTY_LOOT_MODIFIER);
|
|
103
|
+
}
|
|
104
|
+
addModifier(id, value) {
|
|
105
|
+
this.customModifiers.add(id, value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=loot.js.map
|
|
@@ -0,0 +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;AAOtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;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,SAAS,CAAC,EAAE;YAC9B,IAAI,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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { RecipeSerializerId } from "@adeficior/data-modifier/generated";
|
|
2
|
+
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
3
|
+
import type { IdInput, NormalizedId } from "../../common/id.js";
|
|
4
|
+
import type { CommonTest, Ingredient, IngredientInput, IngredientTest, Predicate } from "../../common/ingredient.js";
|
|
5
|
+
import type { Result, ResultInput } from "../../common/result.js";
|
|
6
|
+
import type RegistryLookup from "../../loader/registry/index.js";
|
|
7
|
+
import type { TagRegistryHolder } from "../../loader/tags.js";
|
|
8
|
+
import { Recipe } from "../../parser/recipe/index.js";
|
|
9
|
+
import type { RecipeDefinition } from "../../schema/data/recipe.js";
|
|
10
|
+
import type { ClearableEmitter, RegistryProvider } from "../index.js";
|
|
11
|
+
export type RecipeTest = Readonly<{
|
|
12
|
+
id?: CommonTest<NormalizedId>;
|
|
13
|
+
type?: CommonTest<NormalizedId<RecipeSerializerId>>;
|
|
14
|
+
namespace?: string;
|
|
15
|
+
output?: IngredientTest;
|
|
16
|
+
input?: IngredientTest;
|
|
17
|
+
optional?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export interface RecipeRules {
|
|
20
|
+
resolveIngredientTest(test?: IngredientTest): Predicate<IngredientInput>;
|
|
21
|
+
replaceResult(test: IngredientTest, value: Result, additionalTests?: RecipeTest): void;
|
|
22
|
+
replaceIngredient(test: IngredientTest, value: Ingredient, additionalTests?: RecipeTest): void;
|
|
23
|
+
add<TDefinition extends RecipeDefinition, TRecipe extends Recipe<TDefinition>>(id: IdInput, value: TDefinition | TRecipe): void;
|
|
24
|
+
remove(test: RecipeTest): void;
|
|
25
|
+
}
|
|
26
|
+
export declare const EMPTY_RECIPE: RecipeDefinition;
|
|
27
|
+
export default class RecipeEmitter implements RecipeRules, ClearableEmitter {
|
|
28
|
+
private readonly logger;
|
|
29
|
+
private readonly registry;
|
|
30
|
+
private readonly tags;
|
|
31
|
+
private readonly lookup;
|
|
32
|
+
private readonly packFormat;
|
|
33
|
+
private readonly custom;
|
|
34
|
+
private readonly ruled;
|
|
35
|
+
constructor(logger: Logger, registry: RegistryProvider<Recipe>, tags: TagRegistryHolder, lookup: () => RegistryLookup, packFormat: number);
|
|
36
|
+
private recipePath;
|
|
37
|
+
emit(acceptor: Acceptor): Promise<void>;
|
|
38
|
+
resolveIngredientTest(test?: IngredientTest): Predicate<IngredientInput>;
|
|
39
|
+
private resolveRecipeTest;
|
|
40
|
+
add<TDefinition extends RecipeDefinition, TRecipe extends Recipe<TDefinition>>(id: IdInput, value: TDefinition | TRecipe): void;
|
|
41
|
+
private addRule;
|
|
42
|
+
remove(test: RecipeTest): void;
|
|
43
|
+
replaceResult(test: IngredientTest, value: ResultInput, additionalTest?: RecipeTest): void;
|
|
44
|
+
replaceIngredient(test: IngredientTest, value: IngredientInput, additionalTest?: RecipeTest): void;
|
|
45
|
+
clear(): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { exists } from "@adeficior/pack-resolver";
|
|
2
|
+
import { encodeId } from "../../common/id.js";
|
|
3
|
+
import { createIngredient, resolveIngredientTest, } from "../../common/ingredient.js";
|
|
4
|
+
import { resolveIDTest } from "../../common/predicates.js";
|
|
5
|
+
import { createResult } from "../../common/result.js";
|
|
6
|
+
import { createReplacer, Recipe } from "../../parser/recipe/index.js";
|
|
7
|
+
import CustomEmitter from "../custom.js";
|
|
8
|
+
import RecipeRule from "../rule/recipe.js";
|
|
9
|
+
import RuledEmitter from "../ruled.js";
|
|
10
|
+
export const EMPTY_RECIPE = {
|
|
11
|
+
type: "noop",
|
|
12
|
+
conditions: [
|
|
13
|
+
{
|
|
14
|
+
type: "forge:false",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
"fabric:load_conditions": [
|
|
18
|
+
{
|
|
19
|
+
condition: "fabric:not",
|
|
20
|
+
value: {
|
|
21
|
+
condition: "fabric:all_mods_loaded",
|
|
22
|
+
values: ["minecraft"],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
export default class RecipeEmitter {
|
|
28
|
+
logger;
|
|
29
|
+
registry;
|
|
30
|
+
tags;
|
|
31
|
+
lookup;
|
|
32
|
+
packFormat;
|
|
33
|
+
custom = new CustomEmitter((it) => this.recipePath(it));
|
|
34
|
+
ruled;
|
|
35
|
+
constructor(logger, registry, tags, lookup, packFormat) {
|
|
36
|
+
this.logger = logger;
|
|
37
|
+
this.registry = registry;
|
|
38
|
+
this.tags = tags;
|
|
39
|
+
this.lookup = lookup;
|
|
40
|
+
this.packFormat = packFormat;
|
|
41
|
+
this.ruled = new RuledEmitter(this.logger, this.registry, (id) => this.recipePath(id), EMPTY_RECIPE, (id) => this.custom.has(id));
|
|
42
|
+
}
|
|
43
|
+
recipePath(id) {
|
|
44
|
+
const folder = this.packFormat > 44 ? "recipe" : "recipes";
|
|
45
|
+
return `data/${id.namespace}/${folder}/${id.path}.json`;
|
|
46
|
+
}
|
|
47
|
+
async emit(acceptor) {
|
|
48
|
+
await Promise.all([this.ruled.emit(acceptor), this.custom.emit(acceptor)]);
|
|
49
|
+
}
|
|
50
|
+
resolveIngredientTest(test) {
|
|
51
|
+
if (!test)
|
|
52
|
+
return () => true;
|
|
53
|
+
return resolveIngredientTest(test, this.tags, this.lookup());
|
|
54
|
+
}
|
|
55
|
+
resolveRecipeTest(test) {
|
|
56
|
+
const id = [];
|
|
57
|
+
const type = [];
|
|
58
|
+
const ingredient = [];
|
|
59
|
+
const result = [];
|
|
60
|
+
if (test.id)
|
|
61
|
+
id.push(resolveIDTest(test.id));
|
|
62
|
+
if (test.type)
|
|
63
|
+
type.push(resolveIDTest(test.type));
|
|
64
|
+
if (test.namespace)
|
|
65
|
+
id.push((id) => id.namespace === test.namespace);
|
|
66
|
+
if (test.output)
|
|
67
|
+
result.push(this.resolveIngredientTest(test.output));
|
|
68
|
+
if (test.input)
|
|
69
|
+
ingredient.push(this.resolveIngredientTest(test.input));
|
|
70
|
+
return { id, type, ingredient, result };
|
|
71
|
+
}
|
|
72
|
+
add(id, value) {
|
|
73
|
+
if (this.custom.has(id))
|
|
74
|
+
this.logger.error(`Overwriting custom recipe with ID ${encodeId(id)}`);
|
|
75
|
+
if (value instanceof Recipe)
|
|
76
|
+
this.custom.add(id, value.toJSON());
|
|
77
|
+
else
|
|
78
|
+
this.custom.add(id, value);
|
|
79
|
+
}
|
|
80
|
+
addRule(shape, modifier, recipeTest = {}, ingredientTests = {}) {
|
|
81
|
+
const recipePredicates = this.resolveRecipeTest(recipeTest ?? {});
|
|
82
|
+
this.ruled.addRule(new RecipeRule(shape, recipePredicates.id, recipePredicates.type, [ingredientTests.ingredient, ...recipePredicates.ingredient].filter(exists), [ingredientTests.result, ...recipePredicates.result].filter(exists), modifier), recipeTest.optional !== true);
|
|
83
|
+
}
|
|
84
|
+
remove(test) {
|
|
85
|
+
this.addRule([test], () => null, test);
|
|
86
|
+
}
|
|
87
|
+
replaceResult(test, value, additionalTest) {
|
|
88
|
+
const predicate = this.resolveIngredientTest(test);
|
|
89
|
+
createResult(value, this.lookup());
|
|
90
|
+
const replacer = createReplacer(predicate, value);
|
|
91
|
+
const replace = (it) => createResult(replacer(it));
|
|
92
|
+
this.addRule(["replace result", test, "with", value, additionalTest], (recipe) => recipe.replaceResult(replace), additionalTest, { result: predicate });
|
|
93
|
+
}
|
|
94
|
+
replaceIngredient(test, value, additionalTest) {
|
|
95
|
+
const predicate = this.resolveIngredientTest(test);
|
|
96
|
+
createIngredient(value, this.lookup());
|
|
97
|
+
const replacer = createReplacer(predicate, value);
|
|
98
|
+
const replace = (it) => createIngredient(replacer(it));
|
|
99
|
+
this.addRule(["replace ingredient", test, "with", value, additionalTest], (recipe) => recipe.replaceIngredient(replace), additionalTest, { ingredient: predicate });
|
|
100
|
+
}
|
|
101
|
+
clear() {
|
|
102
|
+
this.custom.clear();
|
|
103
|
+
this.ruled.clear();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recipe.js","sourceRoot":"","sources":["../../../src/emit/data/recipe.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAQ9C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAItD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,aAAa,MAAM,cAAc,CAAC;AAGzC,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,YAAY,MAAM,aAAa,CAAC;AAqCvC,MAAM,CAAC,MAAM,YAAY,GAAqB;IAC5C,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE;QACV;YACE,IAAI,EAAE,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2
|
+
import type { Acceptor, Logger } from "@adeficior/pack-resolver";
|
|
3
|
+
import type { NormalizedId, TagInput } from "../../common/id.js";
|
|
4
|
+
import type { CommonTest } from "../../common/ingredient.js";
|
|
5
|
+
import type TagsLoader from "../../loader/tags.js";
|
|
6
|
+
import type { TagEntry } from "../../schema/data/tag.js";
|
|
7
|
+
import type { ClearableEmitter } from "../index.js";
|
|
8
|
+
export interface TagRules {
|
|
9
|
+
add<T extends RegistryId>(registry: T, id: TagInput, value: TagEntry<InferIds<T>>): void;
|
|
10
|
+
remove<T extends RegistryId>(registry: T, id: TagInput, test: CommonTest<NormalizedId<InferIds<T>>>): void;
|
|
11
|
+
scoped<T extends RegistryId>(key: T, folder?: string): ScopedTagRules<T>;
|
|
12
|
+
blocks: ScopedTagRules<"minecraft:block">;
|
|
13
|
+
items: ScopedTagRules<"minecraft:item">;
|
|
14
|
+
fluids: ScopedTagRules<"minecraft:fluid">;
|
|
15
|
+
}
|
|
16
|
+
interface ScopedTagRules<T extends RegistryId> {
|
|
17
|
+
add(id: TagInput, value: TagEntry<InferIds<T>>): void;
|
|
18
|
+
remove(id: TagInput, test: CommonTest<NormalizedId<InferIds<T>>>): void;
|
|
19
|
+
}
|
|
20
|
+
export interface TagEmitterOptions {
|
|
21
|
+
advancedTags?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export default class TagEmitter implements TagRules, ClearableEmitter {
|
|
24
|
+
private readonly logger;
|
|
25
|
+
private readonly registry;
|
|
26
|
+
private readonly options;
|
|
27
|
+
private readonly emitters;
|
|
28
|
+
readonly blocks: ScopedTagRules<"minecraft:block">;
|
|
29
|
+
readonly items: ScopedTagRules<"minecraft:item">;
|
|
30
|
+
readonly fluids: ScopedTagRules<"minecraft:fluid">;
|
|
31
|
+
constructor(logger: Logger, registry: TagsLoader, options: TagEmitterOptions);
|
|
32
|
+
clear(): void;
|
|
33
|
+
emit(acceptor: Acceptor): Promise<void>;
|
|
34
|
+
add<T extends RegistryId>(registry: T, id: TagInput, value: TagEntry<InferIds<T>>): void;
|
|
35
|
+
remove<T extends RegistryId>(registry: T, id: TagInput, test: CommonTest<NormalizedId<InferIds<T>>>): void;
|
|
36
|
+
scoped<T extends RegistryId>(registry: T, folder?: string): ScopedTagRules<T>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|