@nodecraft/rendermite 1.3.0 → 1.3.2

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.
@@ -1,2 +1,2 @@
1
- import { a as BlockStateMultipartCase, c as ParseBlockStateOptions, d as matchesCondition, f as parseBlockState, i as BlockStateError, l as collectModels, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "../blockstate-eval-CObtPWzJ.js";
1
+ import { a as BlockStateMultipartCase, c as ParseBlockStateOptions, d as matchesCondition, f as parseBlockState, i as BlockStateError, l as collectModels, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "../blockstate-eval-BzznRcVY.js";
2
2
  export { BlockModelVariant, BlockProperties, BlockStateDefinition, BlockStateError, BlockStateMultipartCase, BlockStateVariantCase, MultipartCondition, ParseBlockStateOptions, collectModels, evaluateBlockState, matchesCondition, parseBlockState, weightedVariantIndex };
@@ -1,2 +1,2 @@
1
- import { t as runBlocksCli } from "../cli-CWUKXFbx.js";
1
+ import { t as runBlocksCli } from "../cli-Dq4CFSPi.js";
2
2
  export { runBlocksCli };
@@ -1,2 +1,2 @@
1
- import { t as exportBlockPack } from "../export-DY5sGwt0.js";
1
+ import { t as exportBlockPack } from "../export-B9lH7Tek.js";
2
2
  export { exportBlockPack };
@@ -1,2 +1,2 @@
1
- import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "../pack-format-BO2FsorN.js";
2
- export { BlockPackAtlasFile, BlockPackAtlasPage, BlockPackBlockState, BlockPackBlockStatesFile, BlockPackElement, BlockPackFace, BlockPackMetaFile, BlockPackModel, BlockPackModelsFile, BlockPackRenderLayer, BlockPackSprite, BlockPackSpriteFrame, BlockPackTintsFile };
1
+ import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, m as BlockPackVariant, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "../pack-format-CfCP4kzy.js";
2
+ export { BlockPackAtlasFile, BlockPackAtlasPage, BlockPackBlockState, BlockPackBlockStatesFile, BlockPackElement, BlockPackFace, BlockPackMetaFile, BlockPackModel, BlockPackModelsFile, BlockPackRenderLayer, BlockPackSprite, BlockPackSpriteFrame, BlockPackTintsFile, BlockPackVariant };
@@ -32,11 +32,19 @@ interface BlockModelVariant {
32
32
  /** Relative weight within its list; the game picks one per block position. */
33
33
  weight: number;
34
34
  }
35
- /** One entry of a `variants` map, with its `a=b,c=d` key already parsed. */
36
- interface BlockStateVariantCase {
35
+ /**
36
+ * One entry of a `variants` map, with its `a=b,c=d` key already parsed.
37
+ *
38
+ * Generic over the variant because the evaluation reads only `model`: a pack
39
+ * consumer holds variants whose rotations are optional (the emit omits them at
40
+ * their defaults) and can evaluate those directly, getting its own shape back.
41
+ */
42
+ interface BlockStateVariantCase<Variant extends {
43
+ model: string;
44
+ } = BlockModelVariant> {
37
45
  /** Properties this case constrains; unstated ones are wildcards. */
38
46
  when: Record<string, string>;
39
- apply: BlockModelVariant[];
47
+ apply: Variant[];
40
48
  }
41
49
  /**
42
50
  * A `multipart` predicate. `match` holds one or more accepted values per
@@ -52,17 +60,21 @@ type MultipartCondition = {
52
60
  op: 'or';
53
61
  terms: MultipartCondition[];
54
62
  };
55
- interface BlockStateMultipartCase {
63
+ interface BlockStateMultipartCase<Variant extends {
64
+ model: string;
65
+ } = BlockModelVariant> {
56
66
  /** null for an unconditional part, which always applies. */
57
67
  when: MultipartCondition | null;
58
- apply: BlockModelVariant[];
68
+ apply: Variant[];
59
69
  }
60
- type BlockStateDefinition = {
70
+ type BlockStateDefinition<Variant extends {
71
+ model: string;
72
+ } = BlockModelVariant> = {
61
73
  kind: 'variants';
62
- cases: BlockStateVariantCase[];
74
+ cases: Array<BlockStateVariantCase<Variant>>;
63
75
  } | {
64
76
  kind: 'multipart';
65
- cases: BlockStateMultipartCase[];
77
+ cases: Array<BlockStateMultipartCase<Variant>>;
66
78
  };
67
79
  declare class BlockStateError extends Error {}
68
80
  interface ParseBlockStateOptions {
@@ -104,7 +116,9 @@ declare function matchesCondition(condition: MultipartCondition, properties: Blo
104
116
  * Still empty when even that finds nothing, which is a real answer: a blockstate
105
117
  * that covers only some of a block's states draws nothing for the rest.
106
118
  */
107
- declare function evaluateBlockState(definition: BlockStateDefinition, properties: BlockProperties): BlockModelVariant[][];
119
+ declare function evaluateBlockState<Variant extends {
120
+ model: string;
121
+ }>(definition: BlockStateDefinition<Variant>, properties: BlockProperties): Variant[][];
108
122
  /** Every model a blockstate can name, for deciding what to export. */
109
123
  declare function collectModels(definition: BlockStateDefinition): string[];
110
124
  /**
@@ -1,6 +1,6 @@
1
1
  import { n as builtinPackPath } from "./builtin-WkWjATeh.js";
2
2
  import { n as LayeredResourceManager, t as FolderResourceManager } from "./manager-CYbAkWuT.js";
3
- import { t as exportBlockPack } from "./export-DY5sGwt0.js";
3
+ import { t as exportBlockPack } from "./export-B9lH7Tek.js";
4
4
  import { n as prepareModResources } from "./prepare-B8oPdGYz.js";
5
5
  import { t as downloadClientJar } from "./download-1wAfrGKx.js";
6
6
  import { a as prepareVersionResources, r as compareVersions } from "./prepare-C95vjt_o.js";
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { n as harvestTintOverrides, t as curatedTintOverrides } from "./tints-nx
6
6
  import { t as JarResourceManager } from "./jar-5aLDI0nT.js";
7
7
  import { t as downloadClientJar } from "./download-1wAfrGKx.js";
8
8
  import { a as prepareVersionResources, i as eraForVersion, n as GEOMETRY_DONOR_VERSIONS } from "./prepare-C95vjt_o.js";
9
- import { t as runBlocksCli } from "./cli-CWUKXFbx.js";
9
+ import { t as runBlocksCli } from "./cli-Dq4CFSPi.js";
10
10
  import { t as run } from "./run-Diql5y56.js";
11
11
  import path from "node:path";
12
12
  import os from "node:os";
@@ -191,26 +191,35 @@ function translateElements(elements, offset) {
191
191
  });
192
192
  }
193
193
  function serializeBlockState(definition, exported) {
194
- const cases = [];
195
- for (const entry of definition.cases) {
196
- const apply = entry.apply.filter((variant) => exported(variant.model));
197
- if (apply.length === 0) continue;
198
- cases.push({
199
- when: entry.when,
200
- apply: apply.map((variant) => {
201
- return {
202
- model: variant.model,
203
- ...variant.x !== 0 && { x: variant.x },
204
- ...variant.y !== 0 && { y: variant.y },
205
- ...variant.z !== 0 && { z: variant.z },
206
- ...variant.uvlock && { uvlock: true },
207
- ...variant.weight !== 1 && { weight: variant.weight }
208
- };
209
- })
194
+ /** Every default dropped, since most variants state none of these. */
195
+ const serializeApply = (apply) => apply.filter((variant) => exported(variant.model)).map((variant) => {
196
+ return {
197
+ model: variant.model,
198
+ ...variant.x !== 0 && { x: variant.x },
199
+ ...variant.y !== 0 && { y: variant.y },
200
+ ...variant.z !== 0 && { z: variant.z },
201
+ ...variant.uvlock && { uvlock: true },
202
+ ...variant.weight !== 1 && { weight: variant.weight }
203
+ };
204
+ });
205
+ if (definition.kind === "variants") {
206
+ const cases = definition.cases.flatMap((entry) => {
207
+ const apply = serializeApply(entry.apply);
208
+ return apply.length === 0 ? [] : [{
209
+ when: entry.when,
210
+ apply
211
+ }];
210
212
  });
213
+ return cases.length === 0 ? null : { variants: cases };
211
214
  }
212
- if (cases.length === 0) return null;
213
- return definition.kind === "variants" ? { variants: cases } : { multipart: cases };
215
+ const cases = definition.cases.flatMap((entry) => {
216
+ const apply = serializeApply(entry.apply);
217
+ return apply.length === 0 ? [] : [{
218
+ when: entry.when,
219
+ apply
220
+ }];
221
+ });
222
+ return cases.length === 0 ? null : { multipart: cases };
214
223
  }
215
224
  /**
216
225
  * Any texture the model binds, for a model that declares no `particle`. Ordered
@@ -549,10 +558,24 @@ async function exportBlockPack(options) {
549
558
  return model === void 0 || model.elements.length === 0 && !model.mesh?.length;
550
559
  });
551
560
  if (empty.length === 0) continue;
561
+ const definition = definitions.get(id);
562
+ if (definition?.kind === "multipart") {
563
+ const drawable = definition.cases.filter((part) => part.apply.some((variant) => !empty.includes(variant.model)));
564
+ if (drawable.length > 0) {
565
+ definition.cases = drawable;
566
+ blockModels.set(id, references.filter((reference) => !empty.includes(reference)));
567
+ failures.push({
568
+ id,
569
+ kind: "geometry",
570
+ reason: `the game draws ${empty.join(", ")} in code; the pack drops those parts and keeps the ${drawable.length} that do draw, since a multipart part laid over them would draw as well as them rather than instead`
571
+ });
572
+ continue;
573
+ }
574
+ }
552
575
  const substitute = await itemModelSubstitute(id, resources, models);
553
576
  if (substitute === null) continue;
554
577
  const stood = adoptSubstitute(substitute);
555
- for (const part of definitions.get(id)?.cases ?? []) for (const variant of part.apply) if (empty.includes(variant.model)) variant.model = stood;
578
+ for (const part of definition?.cases ?? []) for (const variant of part.apply) if (empty.includes(variant.model)) variant.model = stood;
556
579
  blockModels.set(id, [...references.filter((reference) => !empty.includes(reference)), stood]);
557
580
  const drawnInCode = empty.length === references.length ? "this block" : empty.join(", ");
558
581
  failures.push({
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { a as TextureMeta, i as TextureLoader, o as TextureResolutionError, r as
4
4
  import { d as parseAtlasSources, n as AtlasSource, r as AtlasSourceError, s as ResolvedSprite, t as AtlasResolver, u as createAtlasResolver } from "./sources-B9X9w3qP.js";
5
5
  import { a as PackedRect, i as PackedPage, n as PackOptions, o as packAtlas, r as PackedAtlas, t as PackEntry } from "./atlas-pack-DRTrWcSU.js";
6
6
  import { a as resolveTexture, n as ModelResolutionError, o as salvageJson, r as ResolvedModel, t as ModelLoader } from "./loader-C_1_amsq.js";
7
- import { a as BlockStateMultipartCase, d as matchesCondition, f as parseBlockState, i as BlockStateError, l as collectModels, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "./blockstate-eval-CObtPWzJ.js";
7
+ import { a as BlockStateMultipartCase, d as matchesCondition, f as parseBlockState, i as BlockStateError, l as collectModels, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "./blockstate-eval-BzznRcVY.js";
8
8
  import { i as exportBlockPack, n as BlockPackResult, r as ExportBlockPackOptions, t as BlockPackFailure } from "./export-BIpqNU3H.js";
9
9
  import { i as buildObjMesh, n as ObjMesh, r as ObjMeshError, t as MeshGroup } from "./obj-mesh-C6Sp4Ysc.js";
10
10
  import { i as buildBlockTints, n as BlockTintPack, t as BlockTint } from "./tints-2k3ZhkY3.js";
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ import { t as buildBlockTints } from "./tints-a9FWZLma.js";
10
10
  import { o as createAtlasResolver, s as parseAtlasSources, t as AtlasSourceError } from "./sources-BlUriDCs.js";
11
11
  import { n as LayeredResourceManager, r as ResourceKind, t as FolderResourceManager } from "./manager-CYbAkWuT.js";
12
12
  import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-C18GpurU.js";
13
- import { t as exportBlockPack } from "./export-DY5sGwt0.js";
13
+ import { t as exportBlockPack } from "./export-B9lH7Tek.js";
14
14
  import { a as defaultProperties, i as UNKNOWN_MODEL, n as InvalidItemDefinitionError, o as evaluateItemModel } from "./definition-ColsvWrH.js";
15
15
  import { n as UnsafeJarError, r as isUnsafeEntryPath, t as JarResourceManager } from "./jar-5aLDI0nT.js";
16
16
  import { n as prepareModResources } from "./prepare-B8oPdGYz.js";
@@ -1,5 +1,5 @@
1
1
  import { a as FaceDirectionName, l as Vec3, o as ModelElementJson, u as Vec4 } from "./types-qlp3I8_-.js";
2
- import { r as BlockStateDefinition } from "./blockstate-eval-CObtPWzJ.js";
2
+ import { a as BlockStateMultipartCase, o as BlockStateVariantCase } from "./blockstate-eval-BzznRcVY.js";
3
3
  import { t as MeshGroup } from "./obj-mesh-C6Sp4Ysc.js";
4
4
  import { n as BlockTintPack } from "./tints-2k3ZhkY3.js";
5
5
  //#region src/blocks/pack-format.d.ts
@@ -86,18 +86,28 @@ type BlockPackModelsFile = Record<string, BlockPackModel>;
86
86
  /** `blockstates.json`, by block id, with keys and predicates already parsed. */
87
87
  type BlockPackBlockStatesFile = Record<string, BlockPackBlockState>;
88
88
  /**
89
- * One block's cases as the pack writes them: the tagged union `evaluateBlockState`
90
- * takes, flattened to the key the file uses.
89
+ * A variant as the pack writes it. Every rotation is optional because the emit
90
+ * drops each one at its default, which is most of them.
91
+ */
92
+ interface BlockPackVariant {
93
+ model: string;
94
+ x?: number;
95
+ y?: number;
96
+ z?: number;
97
+ uvlock?: true;
98
+ weight?: number;
99
+ }
100
+ /**
101
+ * One block's cases as the pack writes them: what `evaluateBlockState` takes,
102
+ * flattened to the key the file uses. Pass it as
103
+ * `{ kind: 'variants', cases: state.variants }` and the models come back as
104
+ * `BlockPackVariant`, no cast in either direction.
91
105
  */
92
106
  type BlockPackBlockState = {
93
- variants: Extract<BlockStateDefinition, {
94
- kind: 'variants';
95
- }>['cases'];
107
+ variants: Array<BlockStateVariantCase<BlockPackVariant>>;
96
108
  multipart?: undefined;
97
109
  } | {
98
- multipart: Extract<BlockStateDefinition, {
99
- kind: 'multipart';
100
- }>['cases'];
110
+ multipart: Array<BlockStateMultipartCase<BlockPackVariant>>;
101
111
  variants?: undefined;
102
112
  };
103
113
  /** `tints.json`. */
@@ -118,4 +128,4 @@ interface BlockPackMetaFile {
118
128
  hashes: Record<string, string>;
119
129
  }
120
130
  //#endregion
121
- export { BlockPackElement as a, BlockPackModel as c, BlockPackSprite as d, BlockPackSpriteFrame as f, BlockPackBlockStatesFile as i, BlockPackModelsFile as l, BlockPackAtlasPage as n, BlockPackFace as o, BlockPackTintsFile as p, BlockPackBlockState as r, BlockPackMetaFile as s, BlockPackAtlasFile as t, BlockPackRenderLayer as u };
131
+ export { BlockPackElement as a, BlockPackModel as c, BlockPackSprite as d, BlockPackSpriteFrame as f, BlockPackBlockStatesFile as i, BlockPackModelsFile as l, BlockPackVariant as m, BlockPackAtlasPage as n, BlockPackFace as o, BlockPackTintsFile as p, BlockPackBlockState as r, BlockPackMetaFile as s, BlockPackAtlasFile as t, BlockPackRenderLayer as u };
package/dist/pack.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as BlockStateMultipartCase, d as matchesCondition, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "./blockstate-eval-CObtPWzJ.js";
1
+ import { a as BlockStateMultipartCase, d as matchesCondition, n as BlockProperties, o as BlockStateVariantCase, p as weightedVariantIndex, r as BlockStateDefinition, s as MultipartCondition, t as BlockModelVariant, u as evaluateBlockState } from "./blockstate-eval-BzznRcVY.js";
2
2
  import { n as ObjMesh, t as MeshGroup } from "./obj-mesh-C6Sp4Ysc.js";
3
3
  import { n as BlockTintPack, t as BlockTint } from "./tints-2k3ZhkY3.js";
4
- import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "./pack-format-BO2FsorN.js";
5
- export { type BlockModelVariant, type BlockPackAtlasFile, type BlockPackAtlasPage, type BlockPackBlockState, type BlockPackBlockStatesFile, type BlockPackElement, type BlockPackFace, type BlockPackMetaFile, type BlockPackModel, type BlockPackModelsFile, type BlockPackRenderLayer, type BlockPackSprite, type BlockPackSpriteFrame, type BlockPackTintsFile, type BlockProperties, type BlockStateDefinition, type BlockStateMultipartCase, type BlockStateVariantCase, type BlockTint, type BlockTintPack, type MeshGroup, type MultipartCondition, type ObjMesh, evaluateBlockState, matchesCondition, weightedVariantIndex };
4
+ import { a as BlockPackElement, c as BlockPackModel, d as BlockPackSprite, f as BlockPackSpriteFrame, i as BlockPackBlockStatesFile, l as BlockPackModelsFile, m as BlockPackVariant, n as BlockPackAtlasPage, o as BlockPackFace, p as BlockPackTintsFile, r as BlockPackBlockState, s as BlockPackMetaFile, t as BlockPackAtlasFile, u as BlockPackRenderLayer } from "./pack-format-CfCP4kzy.js";
5
+ export { type BlockModelVariant, type BlockPackAtlasFile, type BlockPackAtlasPage, type BlockPackBlockState, type BlockPackBlockStatesFile, type BlockPackElement, type BlockPackFace, type BlockPackMetaFile, type BlockPackModel, type BlockPackModelsFile, type BlockPackRenderLayer, type BlockPackSprite, type BlockPackSpriteFrame, type BlockPackTintsFile, type BlockPackVariant, type BlockProperties, type BlockStateDefinition, type BlockStateMultipartCase, type BlockStateVariantCase, type BlockTint, type BlockTintPack, type MeshGroup, type MultipartCondition, type ObjMesh, evaluateBlockState, matchesCondition, weightedVariantIndex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodecraft/rendermite",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Minecraft item icon renderer: renders inventory-identical item icons from vanilla and modded assets across game versions, outputting optimized PNG/WebP/AVIF plus CSS and a JSON item library.",
5
5
  "type": "module",
6
6
  "license": "MIT",