@adeficior/data-modifier-content 2.0.0-rc.20260814115618
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/emitter/blockDefinition.d.ts +55 -0
- package/dist/emitter/blockDefinition.js +65 -0
- package/dist/emitter/blockDefinition.js.map +1 -0
- package/dist/emitter/innerBlockDefinition.d.ts +11 -0
- package/dist/emitter/innerBlockDefinition.js +37 -0
- package/dist/emitter/innerBlockDefinition.js.map +1 -0
- package/dist/emitter/itemDefinition.d.ts +56 -0
- package/dist/emitter/itemDefinition.js +63 -0
- package/dist/emitter/itemDefinition.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/module.d.ts +9 -0
- package/dist/module.js +23 -0
- package/dist/module.js.map +1 -0
- package/dist/schema/blockDefinition.d.ts +11 -0
- package/dist/schema/blockDefinition.js +1 -0
- package/dist/schema/blockDefinition.js.map +1 -0
- package/dist/schema/itemDefinition.d.ts +14 -0
- package/dist/schema/itemDefinition.js +2 -0
- package/dist/schema/itemDefinition.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ClearableEmitter, type IdInput, type LoaderContext } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { type LootRules } from "@adeficior/data-modifier-loot";
|
|
3
|
+
import { type BlockstateRules, type ModelRules } from "@adeficior/data-modifier-models";
|
|
4
|
+
import { type BlockId } from "@adeficior/data-modifier/generated";
|
|
5
|
+
import { type BlockDefinition, type BlockProperties } from "../schema/blockDefinition";
|
|
6
|
+
export type BlockDefinitionOptions = Readonly<{
|
|
7
|
+
blockstate?: boolean;
|
|
8
|
+
model?: boolean;
|
|
9
|
+
loot?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
type PropertiesOrCopy = BlockProperties | {
|
|
12
|
+
copy: BlockId;
|
|
13
|
+
};
|
|
14
|
+
type ExtendedBlockProperties = PropertiesOrCopy & {
|
|
15
|
+
type?: string;
|
|
16
|
+
};
|
|
17
|
+
export interface BlockDefinitionRules {
|
|
18
|
+
add<T extends BlockDefinition>(id: IdInput, definition: T): T;
|
|
19
|
+
basic(id: IdInput, properties: ExtendedBlockProperties, options?: BlockDefinitionOptions): BlockDefinition;
|
|
20
|
+
cog(id: IdInput, properties: ExtendedBlockProperties & {
|
|
21
|
+
large?: boolean;
|
|
22
|
+
}, options?: BlockDefinitionOptions): BlockDefinition;
|
|
23
|
+
}
|
|
24
|
+
export declare abstract class AbstractBlockDefinitionRules implements BlockDefinitionRules {
|
|
25
|
+
private readonly models;
|
|
26
|
+
private readonly blockstates;
|
|
27
|
+
private readonly loot;
|
|
28
|
+
constructor(models: ModelRules, blockstates: BlockstateRules, loot: LootRules);
|
|
29
|
+
abstract add<T extends BlockDefinition>(id: IdInput, definition: T): T;
|
|
30
|
+
basic(id: IdInput, { type, ...properties }: ExtendedBlockProperties, options?: BlockDefinitionOptions): {
|
|
31
|
+
type: string;
|
|
32
|
+
properties: string | Readonly<{
|
|
33
|
+
material?: string;
|
|
34
|
+
strength?: number;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
cog(id: IdInput, { type, large, ...properties }: ExtendedBlockProperties & {
|
|
38
|
+
large?: boolean;
|
|
39
|
+
}, options?: BlockDefinitionOptions): {
|
|
40
|
+
type: string;
|
|
41
|
+
large: boolean;
|
|
42
|
+
properties: string | Readonly<{
|
|
43
|
+
material?: string;
|
|
44
|
+
strength?: number;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export declare class BlockDefinitionEmitter extends AbstractBlockDefinitionRules implements ClearableEmitter {
|
|
49
|
+
private readonly custom;
|
|
50
|
+
private filePath;
|
|
51
|
+
add<T extends BlockDefinition>(id: IdInput, definition: T): T;
|
|
52
|
+
resolver(context: LoaderContext): import("@adeficior/pack-resolver").Resolver<import("@adeficior/pack-resolver").Acceptable, import("@adeficior/pack-resolver").BaseContext>;
|
|
53
|
+
clear(): void;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {} from "@adeficior/data-modifier-core";
|
|
2
|
+
import { CustomEmitter } from "@adeficior/data-modifier-core";
|
|
3
|
+
import {} from "@adeficior/data-modifier-loot";
|
|
4
|
+
import {} from "@adeficior/data-modifier-models";
|
|
5
|
+
import {} from "@adeficior/data-modifier/generated";
|
|
6
|
+
import {} from "../schema/blockDefinition";
|
|
7
|
+
function resolveProperties(from) {
|
|
8
|
+
if ("copy" in from)
|
|
9
|
+
return from.copy;
|
|
10
|
+
return from;
|
|
11
|
+
}
|
|
12
|
+
export class AbstractBlockDefinitionRules {
|
|
13
|
+
models;
|
|
14
|
+
blockstates;
|
|
15
|
+
loot;
|
|
16
|
+
constructor(
|
|
17
|
+
// TODO inject
|
|
18
|
+
models, blockstates, loot) {
|
|
19
|
+
this.models = models;
|
|
20
|
+
this.blockstates = blockstates;
|
|
21
|
+
this.loot = loot;
|
|
22
|
+
}
|
|
23
|
+
basic(id, { type, ...properties }, options) {
|
|
24
|
+
if (options?.model !== false)
|
|
25
|
+
this.models.cubeAll(id);
|
|
26
|
+
if (options?.blockstate !== false)
|
|
27
|
+
this.blockstates.basic(id);
|
|
28
|
+
if (options?.loot !== false)
|
|
29
|
+
this.loot.block(id);
|
|
30
|
+
return this.add(id, {
|
|
31
|
+
type: type ?? "basic",
|
|
32
|
+
properties: resolveProperties(properties),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
cog(id, { type, large = false, ...properties }, options) {
|
|
36
|
+
if (options?.model !== false)
|
|
37
|
+
this.models.cog(id, large);
|
|
38
|
+
if (options?.blockstate !== false)
|
|
39
|
+
this.blockstates.cog(id);
|
|
40
|
+
if (options?.loot !== false)
|
|
41
|
+
this.loot.block(id);
|
|
42
|
+
return this.add(id, {
|
|
43
|
+
type: type ?? "create:cog",
|
|
44
|
+
large,
|
|
45
|
+
properties: resolveProperties(properties),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class BlockDefinitionEmitter extends AbstractBlockDefinitionRules {
|
|
50
|
+
custom = new CustomEmitter(this.filePath);
|
|
51
|
+
filePath(id) {
|
|
52
|
+
return `content/${id.namespace}/block/${id.path}.json`;
|
|
53
|
+
}
|
|
54
|
+
add(id, definition) {
|
|
55
|
+
this.custom.add(id, definition);
|
|
56
|
+
return definition;
|
|
57
|
+
}
|
|
58
|
+
resolver(context) {
|
|
59
|
+
return this.custom.resolver(context);
|
|
60
|
+
}
|
|
61
|
+
clear() {
|
|
62
|
+
this.custom.clear();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=blockDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockDefinition.js","sourceRoot":"","sources":["../../src/emitter/blockDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAGN,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAgB,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAGN,MAAM,2BAA2B,CAAC;AA8BnC,SAAS,iBAAiB,CAAC,IAAsB;IAC/C,IAAI,MAAM,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IACrC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,OAAgB,4BAA4B;IAG7B;IACA;IACA;IAJnB;IACE,cAAc;IACG,MAAkB,EAClB,WAA4B,EAC5B,IAAe;QAFf,WAAM,GAAN,MAAM,CAAY;QAClB,gBAAW,GAAX,WAAW,CAAiB;QAC5B,SAAI,GAAJ,IAAI,CAAW;IAC/B,CAAC;IAIJ,KAAK,CACH,EAAW,EACX,EAAE,IAAI,EAAE,GAAG,UA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OAAO,WAAW,EAAE,CAAC,SAAS,UAAU,EAAE,CAAC,IAAI,OAAO,CAAC;IACzD,CAAC;IAED,GAAG,CAA4B,EAAW,EAAE,UAAa;QACvD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;QAChC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,OAAsB;QAC7B,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IdInput } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { type LootRules } from "@adeficior/data-modifier-loot";
|
|
3
|
+
import { type BlockstateRules, type ModelRules } from "@adeficior/data-modifier-models";
|
|
4
|
+
import { type BlockDefinitionRules } from "./blockDefinition";
|
|
5
|
+
type CurriedFunction<TRest extends unknown[], TReturn> = (...args: TRest) => TReturn;
|
|
6
|
+
type InferCurriedFunction<T> = T extends (sliced: any, ...args: infer TRest) => infer TReturn ? CurriedFunction<TRest, TReturn> : never;
|
|
7
|
+
export type BlockDefinitionRulesWithoutId = {
|
|
8
|
+
[K in keyof BlockDefinitionRules]: InferCurriedFunction<BlockDefinitionRules[K]>;
|
|
9
|
+
};
|
|
10
|
+
export declare function createInnerBlockDefinitionBuilder(id: IdInput, models: ModelRules, blockstates: BlockstateRules, loot: LootRules): BlockDefinitionRulesWithoutId;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {} from "@adeficior/data-modifier-core";
|
|
2
|
+
import {} from "@adeficior/data-modifier-loot";
|
|
3
|
+
import {} from "@adeficior/data-modifier-models";
|
|
4
|
+
import {} from "../schema/blockDefinition";
|
|
5
|
+
import {} from "./blockDefinition";
|
|
6
|
+
import { AbstractBlockDefinitionRules } from "./blockDefinition";
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
class InnerBlockDefinitionRules extends AbstractBlockDefinitionRules {
|
|
9
|
+
add(id, definition) {
|
|
10
|
+
return definition ?? id;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function curry(func, dummy) {
|
|
14
|
+
return function (...args) {
|
|
15
|
+
return func.call(this, dummy, ...args);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Modifies emitter
|
|
20
|
+
*/
|
|
21
|
+
function createCurriedEmitter(id, emitter) {
|
|
22
|
+
const methods = Object.getOwnPropertyNames(AbstractBlockDefinitionRules.prototype).filter((it) => it !== "constructor");
|
|
23
|
+
const out = emitter;
|
|
24
|
+
methods.forEach((key) => {
|
|
25
|
+
const func = emitter[key];
|
|
26
|
+
if (typeof func === "function") {
|
|
27
|
+
out[key] = curry(func, id).bind(emitter);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
33
|
+
export function createInnerBlockDefinitionBuilder(id, models, blockstates, loot) {
|
|
34
|
+
const inner = new InnerBlockDefinitionRules(models, blockstates, loot);
|
|
35
|
+
return createCurriedEmitter(id, inner);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=innerBlockDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"innerBlockDefinition.js","sourceRoot":"","sources":["../../src/emitter/innerBlockDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAGN,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAwB,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAA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|
+
import { type ClearableEmitter, type IdInput, type LoaderContext } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { type LootRules } from "@adeficior/data-modifier-loot";
|
|
3
|
+
import { type BlockstateRules, type ModelRules } from "@adeficior/data-modifier-models";
|
|
4
|
+
import { type BlockDefinition } from "../schema/blockDefinition";
|
|
5
|
+
import { type ItemDefinition, type ItemProperties } from "../schema/itemDefinition";
|
|
6
|
+
import { type BlockDefinitionRulesWithoutId } from "./innerBlockDefinition";
|
|
7
|
+
export type ItemDefinitionOptions = Readonly<{
|
|
8
|
+
model?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
type ExtendedItemProperties = ItemProperties & {
|
|
11
|
+
type?: string;
|
|
12
|
+
};
|
|
13
|
+
type BlockDefinitionInput = BlockDefinition | ((rules: BlockDefinitionRulesWithoutId) => BlockDefinition);
|
|
14
|
+
export interface ItemDefinitionRules {
|
|
15
|
+
add<T extends ItemDefinition>(id: IdInput, definition: T): T;
|
|
16
|
+
basic(id: IdInput, properties?: ExtendedItemProperties, options?: ItemDefinitionOptions): ItemDefinition;
|
|
17
|
+
blockItem(id: IdInput, properties?: ExtendedItemProperties & {
|
|
18
|
+
block: BlockDefinitionInput;
|
|
19
|
+
}, options?: ItemDefinitionOptions): ItemDefinition;
|
|
20
|
+
}
|
|
21
|
+
export declare class ItemDefinitionEmitter implements ItemDefinitionRules, ClearableEmitter {
|
|
22
|
+
private readonly itemModels;
|
|
23
|
+
private readonly blockModels;
|
|
24
|
+
private readonly blockstates;
|
|
25
|
+
private readonly loot;
|
|
26
|
+
private readonly custom;
|
|
27
|
+
constructor(itemModels: ModelRules, blockModels: ModelRules, blockstates: BlockstateRules, loot: LootRules);
|
|
28
|
+
private filePath;
|
|
29
|
+
add<T extends ItemDefinition>(id: IdInput, definition: T): T;
|
|
30
|
+
clear(): void;
|
|
31
|
+
resolver(context: LoaderContext): import("@adeficior/pack-resolver").Resolver<import("@adeficior/pack-resolver").Acceptable, import("@adeficior/pack-resolver").BaseContext>;
|
|
32
|
+
basic(id: IdInput, { type, ...properties }?: ExtendedItemProperties, options?: ItemDefinitionOptions): {
|
|
33
|
+
type: string;
|
|
34
|
+
properties: {
|
|
35
|
+
rarity?: import("..").Rarity;
|
|
36
|
+
stack_size?: number;
|
|
37
|
+
creative_tab?: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
private createBlockDefinition;
|
|
41
|
+
blockItem(id: IdInput, { block, type, ...properties }: ExtendedItemProperties & {
|
|
42
|
+
block: BlockDefinitionInput;
|
|
43
|
+
}, options?: ItemDefinitionOptions): {
|
|
44
|
+
type: string;
|
|
45
|
+
block: Readonly<{
|
|
46
|
+
type: string;
|
|
47
|
+
properties: import("..").BlockProperties | string;
|
|
48
|
+
}>;
|
|
49
|
+
properties: {
|
|
50
|
+
rarity?: import("..").Rarity;
|
|
51
|
+
stack_size?: number;
|
|
52
|
+
creative_tab?: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {} from "@adeficior/data-modifier-core";
|
|
2
|
+
import { CustomEmitter, prefix } from "@adeficior/data-modifier-core";
|
|
3
|
+
import {} from "@adeficior/data-modifier-loot";
|
|
4
|
+
import {} from "@adeficior/data-modifier-models";
|
|
5
|
+
import {} from "../schema/blockDefinition";
|
|
6
|
+
import {} from "../schema/itemDefinition";
|
|
7
|
+
import {} from "./innerBlockDefinition";
|
|
8
|
+
import { createInnerBlockDefinitionBuilder } from "./innerBlockDefinition";
|
|
9
|
+
export class ItemDefinitionEmitter {
|
|
10
|
+
itemModels;
|
|
11
|
+
blockModels;
|
|
12
|
+
blockstates;
|
|
13
|
+
loot;
|
|
14
|
+
custom = new CustomEmitter(this.filePath);
|
|
15
|
+
constructor(
|
|
16
|
+
// TODO inject
|
|
17
|
+
itemModels, blockModels, blockstates, loot) {
|
|
18
|
+
this.itemModels = itemModels;
|
|
19
|
+
this.blockModels = blockModels;
|
|
20
|
+
this.blockstates = blockstates;
|
|
21
|
+
this.loot = loot;
|
|
22
|
+
}
|
|
23
|
+
filePath(id) {
|
|
24
|
+
return `content/${id.namespace}/item/${id.path}.json`;
|
|
25
|
+
}
|
|
26
|
+
add(id, definition) {
|
|
27
|
+
this.custom.add(id, definition);
|
|
28
|
+
return definition;
|
|
29
|
+
}
|
|
30
|
+
clear() {
|
|
31
|
+
this.custom.clear();
|
|
32
|
+
}
|
|
33
|
+
resolver(context) {
|
|
34
|
+
return this.custom.resolver(context);
|
|
35
|
+
}
|
|
36
|
+
basic(id, { type, ...properties } = {}, options) {
|
|
37
|
+
if (options?.model !== false)
|
|
38
|
+
this.itemModels.flat(id);
|
|
39
|
+
return this.add(id, {
|
|
40
|
+
type: type ?? "basic",
|
|
41
|
+
properties,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
createBlockDefinition(id, input) {
|
|
45
|
+
if (typeof input !== "function")
|
|
46
|
+
return input;
|
|
47
|
+
const blockBuilder = createInnerBlockDefinitionBuilder(id, this.blockModels, this.blockstates, this.loot);
|
|
48
|
+
return input(blockBuilder);
|
|
49
|
+
}
|
|
50
|
+
blockItem(id, { block, type, ...properties }, options) {
|
|
51
|
+
if (options?.model !== false) {
|
|
52
|
+
const parent = prefix(id, "block/");
|
|
53
|
+
this.itemModels.add(id, { parent });
|
|
54
|
+
}
|
|
55
|
+
const blockDefinition = this.createBlockDefinition(id, block);
|
|
56
|
+
return this.add(id, {
|
|
57
|
+
type: type ?? "block_item",
|
|
58
|
+
block: blockDefinition,
|
|
59
|
+
properties,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=itemDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemDefinition.js","sourceRoot":"","sources":["../../src/emitter/itemDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,a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CAAC;QAEvD,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;YAClB,IAAI,EAAE,IAAI,IAAI,OAAO;YACrB,UAAU;SACX,CAAC,CAAC;IACL,CAAC;IAEO,qBAAqB,CAAC,EAAW,EAAE,KAA2B;QACpE,IAAI,OAAO,KAAK,KAAK,UAAU;YAAE,OAAO,KAAK,CAAC;QAC9C,MAAM,YAAY,GAAG,iCAAiC,CACpD,EAAE,EACF,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,CACV,CAAC;QACF,OAAO,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;IAED,SAAS,CACP,EAAW,EACX,EACE,KAAK,EACL,IAAI,EACJ,GAAG,UAAU,EAGd,EACD,OAA+B;QAE/B,IAAI,OAAO,EAAE,KAAK,KAAK,KAAK,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;YACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QACtC,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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { BlockDefinitionOptions, BlockDefinitionRules, } from "./emitter/blockDefinition";
|
|
2
|
+
export type { ItemDefinitionOptions, ItemDefinitionRules, } from "./emitter/itemDefinition";
|
|
3
|
+
export { default } from "./module";
|
|
4
|
+
export type * from "./schema/blockDefinition";
|
|
5
|
+
export type * from "./schema/itemDefinition";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type BlockDefinitionRules } from "./emitter/blockDefinition";
|
|
2
|
+
import { type ItemDefinitionRules } from "./emitter/itemDefinition";
|
|
3
|
+
declare const _default: import("@adeficior/data-modifier-core").ModuleConfig<{
|
|
4
|
+
emitters: {
|
|
5
|
+
"content:blocks": BlockDefinitionRules;
|
|
6
|
+
"content:items": ItemDefinitionRules;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
9
|
+
export default _default;
|
package/dist/module.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineModule } from "@adeficior/data-modifier-core";
|
|
2
|
+
import { name } from "../package.json";
|
|
3
|
+
import { BlockDefinitionEmitter, } from "./emitter/blockDefinition";
|
|
4
|
+
import { ItemDefinitionEmitter, } from "./emitter/itemDefinition";
|
|
5
|
+
export default defineModule({
|
|
6
|
+
importModule: name,
|
|
7
|
+
dependencies: {
|
|
8
|
+
// TODO optional?
|
|
9
|
+
"@adeficior/data-modifier-loot": "required",
|
|
10
|
+
"@adeficior/data-modifier-models": "required",
|
|
11
|
+
},
|
|
12
|
+
types: {
|
|
13
|
+
emitters: {
|
|
14
|
+
"content:blocks": "BlockDefinitionRules",
|
|
15
|
+
"content:items": "ItemDefinitionRules",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
setup: (pack) => {
|
|
19
|
+
pack.emitter("content:blocks", (container) => new BlockDefinitionEmitter(container.get("emitter:models:block"), container.get("emitter:blockstates"), container.get("emitter:loot")));
|
|
20
|
+
pack.emitter("content:items", (container) => new ItemDefinitionEmitter(container.get("emitter:models:item"), container.get("emitter:models:block"), container.get("emitter:blockstates"), container.get("emitter:loot")));
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EACL,sBAAsB,GAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,GAEtB,MAAM,0BAA0B,CAAC;AAElC,eAAe,YAAY,CAKxB;IACD,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE;QACZ,iBAAiB;QACjB,+BAA+B,EAAE,UAAU;QAC3C,iCAAiC,EAAE,UAAU;KAC9C;IACD,KAAK,EAAE;QACL,QAAQ,EAAE;YACR,gBAAgB,EAAE,sBAAsB;YACxC,eAAe,EAAE,qBAAqB;SACvC;KACF;IACD,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,CAAC,OAAO,CACV,gBAAgB,EAChB,CAAC,SAAS,EAAE,EAAE,CACZ,IAAI,sBAAsB,CACxB,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC,EACrC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,EACpC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAC9B,CACJ,CAAC;QAEF,IAAI,CAAC,OAAO,CACV,eAAe,EACf,CAAC,SAAS,EAAE,EAAE,CACZ,IAAI,qBAAqB,CACvB,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,EACpC,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC,EACrC,SAAS,CAAC,GAAG,CAAC,qBAAqB,CAAC,EACpC,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAC9B,CACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type BlockProperties = Readonly<{
|
|
2
|
+
material?: string;
|
|
3
|
+
strength?: number;
|
|
4
|
+
}>;
|
|
5
|
+
export type BlockDefinition = Readonly<{
|
|
6
|
+
type: string;
|
|
7
|
+
properties: BlockProperties | string;
|
|
8
|
+
}>;
|
|
9
|
+
export type CogBlockDefinition = BlockDefinition & Readonly<{
|
|
10
|
+
large?: boolean;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=blockDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockDefinition.js","sourceRoot":"","sources":["../../src/schema/blockDefinition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BlockDefinition } from "./blockDefinition";
|
|
2
|
+
export type Rarity = "common" | "rare";
|
|
3
|
+
export type ItemProperties = Readonly<{
|
|
4
|
+
rarity?: Rarity;
|
|
5
|
+
stack_size?: number;
|
|
6
|
+
creative_tab?: string;
|
|
7
|
+
}>;
|
|
8
|
+
export type ItemDefinition = Readonly<{
|
|
9
|
+
type: string;
|
|
10
|
+
properties?: ItemProperties;
|
|
11
|
+
}>;
|
|
12
|
+
export type BlockItemDefinition = ItemDefinition & Readonly<{
|
|
13
|
+
block: BlockDefinition;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemDefinition.js","sourceRoot":"","sources":["../../src/schema/itemDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,mBAAmB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adeficior/data-modifier-content",
|
|
3
|
+
"version": "2.0.0-rc.20260814115618",
|
|
4
|
+
"exports": {
|
|
5
|
+
".": "./dist/index.js"
|
|
6
|
+
},
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc --project tsconfig.build.json",
|
|
14
|
+
"check": "tsc --noEmit",
|
|
15
|
+
"dev": "bun run build --watch",
|
|
16
|
+
"lint": "eslint {src,test}",
|
|
17
|
+
"test": "bun test --timeout 10000",
|
|
18
|
+
"prune": "bun run datamod-dev --prune",
|
|
19
|
+
"prepare": "datamod-dev --configs && datamod-dev --types",
|
|
20
|
+
"test:ci": "bun run lint && bun run check && bun run test --coverage"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@adeficior/configs": "workspace:*",
|
|
24
|
+
"@adeficior/testing": "workspace:*",
|
|
25
|
+
"@adeficior/data-modifier-models": "workspace:*",
|
|
26
|
+
"@adeficior/data-modifier-loot": "workspace:*",
|
|
27
|
+
"@types/lodash-es": "catalog:"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@adeficior/pack-resolver": "catalog:",
|
|
31
|
+
"typescript": "catalog:",
|
|
32
|
+
"lodash-es": "catalog:",
|
|
33
|
+
"@adeficior/data-modifier-core": "workspace:*",
|
|
34
|
+
"@adeficior/data-modifier-tags": "workspace:*",
|
|
35
|
+
"@adeficior/data-modifier-ingredients": "workspace:*",
|
|
36
|
+
"@adeficior/data-modifier-models": "workspace:*",
|
|
37
|
+
"@adeficior/data-modifier-loot": "workspace:*"
|
|
38
|
+
}
|
|
39
|
+
}
|