@nodecraft/rendermite 1.1.0 → 1.1.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.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { n as LayeredResourceManager, t as FolderResourceManager } from "./manag
4
4
  import { t as curatedModelOverrides } from "./models-BKxGkPS7.js";
5
5
  import { n as harvestTintOverrides, t as curatedTintOverrides } from "./tints-CebmvjmP.js";
6
6
  import { t as JarResourceManager } from "./jar-D9z-X7tA.js";
7
- import { t as run } from "./run-C6AP3Bn8.js";
7
+ import { t as run } from "./run-DAayk01r.js";
8
8
  import { t as downloadClientJar } from "./download-D9aARBFp.js";
9
9
  import { a as prepareVersionResources, i as eraForVersion, n as GEOMETRY_DONOR_VERSIONS } from "./prepare-Cc8QZ3j0.js";
10
10
  import path from "node:path";
@@ -1,5 +1,5 @@
1
1
  import { n as ResourceLocator } from "./locator-ycZzh_6z.js";
2
- import { i as renderModel } from "./renderer-oi1MSF3Y.js";
2
+ import { i as renderModel } from "./renderer-Dw4dN33b.js";
3
3
  //#region src/render/entity-fallback.ts
4
4
  /**
5
5
  * Heuristic rendering for mod items that parent `builtin/entity` — chests,
package/dist/index.js CHANGED
@@ -9,12 +9,12 @@ import { a as builtinDynamicResources } from "./generators-BlG4KmtP.js";
9
9
  import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
10
10
  import { n as itemClass, t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
11
11
  import { c as lightsForProfile, r as LightingProfile } from "./lighting--5myudVu.js";
12
- import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-DwkA9LR5.js";
13
- import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-oi1MSF3Y.js";
12
+ import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, t as ModelLoader } from "./loader-CWsTZgrk.js";
13
+ import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "./renderer-Dw4dN33b.js";
14
14
  import { a as resolveTints, i as resolveTint, n as InvalidTinterDefinitionError, r as parseTintValue, t as DYE_COLORS } from "./tints-3VI_2SNy.js";
15
15
  import { o as createAtlasResolver, s as parseAtlasSources, t as AtlasSourceError } from "./sources-Bxk-WOzH.js";
16
16
  import { n as TextureLoader, r as TextureResolutionError, t as AnimatedTexture } from "./loader-Lb0ZeILz.js";
17
- import { t as run } from "./run-C6AP3Bn8.js";
17
+ import { t as run } from "./run-DAayk01r.js";
18
18
  import { a as prepareVersionResources, i as eraForVersion, r as compareVersions } from "./prepare-Cc8QZ3j0.js";
19
19
  import { n as prepareModResources } from "./prepare-D56Z-9cg.js";
20
20
  export { AnimatedTexture, AtlasSourceError, DYE_COLORS, FolderResourceManager, InvalidItemDefinitionError, InvalidResourceLocatorError, InvalidTinterDefinitionError, ItemRenderError, ItemResolutionError, JarResourceManager, LayeredResourceManager, LightingProfile, ModelLoader, ModelResolutionError, ResourceKind, ResourceLocator, TextureLoader, TextureResolutionError, UNKNOWN_MODEL, UnsafeJarError, boxDownscale, builtinDynamicResources, compareVersions, createAtlasResolver, defaultProperties, discoverItems, encodeAnimatedIcon, encodeIcon, eraForVersion, evaluateItemModel, generateStylesheet, isUnsafeEntryPath, itemClass, lightsForProfile, minifyStylesheet, parseAtlasSources, parseTintValue, pointResize, prepareModResources, prepareVersionResources, renderModel, renderModelFrames, resolveItem, resolveTexture, resolveTint, resolveTints, run, salvageJson, toByteTexture, toFloatTexture };
@@ -506,7 +506,13 @@ var ModelLoader = class {
506
506
  if (seen.has(key)) throw new ModelResolutionError(`Model parent cycle at ${key} (from ${locator})`);
507
507
  if (chain.length >= MAX_PARENT_DEPTH) throw new ModelResolutionError(`Model parent chain exceeds ${MAX_PARENT_DEPTH} at ${locator}`);
508
508
  seen.add(key);
509
- const json = await this.readModelJson(current);
509
+ let json;
510
+ try {
511
+ json = await this.readModelJson(current);
512
+ } catch (err) {
513
+ if (chain.length === 0 || !(err instanceof ModelResolutionError)) throw err;
514
+ break;
515
+ }
510
516
  chain.push({
511
517
  locator: current,
512
518
  json
@@ -1,2 +1,2 @@
1
- import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, r as flattenLoaderModel, t as ModelLoader } from "../loader-DwkA9LR5.js";
1
+ import { a as salvageJson, i as resolveTexture, n as ModelResolutionError, r as flattenLoaderModel, t as ModelLoader } from "../loader-CWsTZgrk.js";
2
2
  export { ModelLoader, ModelResolutionError, flattenLoaderModel, resolveTexture, salvageJson };
@@ -5,9 +5,9 @@ import { r as resolveItem } from "./discovery-B9aqV_Rz.js";
5
5
  import { l as toFloatTexture, t as blendPixel } from "./blend-KXMclcHk.js";
6
6
  import { t as encodeAnimatedIcon } from "./encode-LR9wxigC.js";
7
7
  import { a as builtinDynamicResources } from "./generators-BlG4KmtP.js";
8
- import { t as ModelLoader } from "./loader-DwkA9LR5.js";
9
- import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize } from "./renderer-oi1MSF3Y.js";
10
- import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-BnFMSHS6.js";
8
+ import { t as ModelLoader } from "./loader-CWsTZgrk.js";
9
+ import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize } from "./renderer-Dw4dN33b.js";
10
+ import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-DsHZKlSe.js";
11
11
  import { i as renderGeo, t as findGeoForItem } from "./geo-w9HHIrb5.js";
12
12
  import { t as legacyTintsForChain } from "./legacy-tints-B09J0Rxh.js";
13
13
  import { a as resolveTints } from "./tints-3VI_2SNy.js";
@@ -56,7 +56,17 @@ var ItemPipeline = class ItemPipeline {
56
56
  * pipeline's black-icon audit checked exactly this). A real sprite beats
57
57
  * no icon; the fallback is recorded so it is never a silent substitution.
58
58
  */
59
- async spriteFallback(id) {
59
+ /** Whether the game draws this item from an entity model rather than a sprite. */
60
+ async isEntityDrawn(id) {
61
+ try {
62
+ const [instruction] = await resolveItem(this.resources, id, defaultProperties());
63
+ if (!instruction) return false;
64
+ return (await this.models.load(instruction.model)).builtinParent === "builtin/entity";
65
+ } catch {
66
+ return false;
67
+ }
68
+ }
69
+ async spriteFallback(id, entityDrawn) {
60
70
  const { size, quality } = this.settings;
61
71
  const locator = ResourceLocator.parse(id);
62
72
  const draw = (texture) => {
@@ -67,6 +77,7 @@ var ItemPipeline = class ItemPipeline {
67
77
  const texture = await this.textures.load(new ResourceLocator(locator.namespace, `${directory}/${locator.path}`));
68
78
  if (texture) return draw(texture);
69
79
  }
80
+ if (entityDrawn) return null;
70
81
  const leaf = locator.path.split("/").pop();
71
82
  const candidates = await this.resources.listResources("texture", locator.namespace);
72
83
  for (const prefix of [/^items?\//, /^blocks?\//]) {
@@ -215,7 +226,7 @@ var ItemPipeline = class ItemPipeline {
215
226
  delaysMs: [50],
216
227
  usedFallback: false
217
228
  };
218
- const sprite = await this.spriteFallback(id).catch(() => null);
229
+ const sprite = await this.spriteFallback(id, await this.isEntityDrawn(id)).catch(() => null);
219
230
  if (!sprite) throw err;
220
231
  return {
221
232
  frames: [sprite],
@@ -40,6 +40,8 @@ declare class ItemPipeline {
40
40
  * pipeline's black-icon audit checked exactly this). A real sprite beats
41
41
  * no icon; the fallback is recorded so it is never a silent substitution.
42
42
  */
43
+ /** Whether the game draws this item from an entity model rather than a sprite. */
44
+ private isEntityDrawn;
43
45
  private spriteFallback;
44
46
  /**
45
47
  * A blockstate-named block model, drawn the way a block-entity item renderer
@@ -1,2 +1,2 @@
1
- import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-BnFMSHS6.js";
1
+ import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-DsHZKlSe.js";
2
2
  export { dyeVariantName, dyedVariantTint, renderDyedVariantFallback, renderEntityFallback, spawnEggTints };
@@ -1,2 +1,2 @@
1
- import { c as renderObjModel, o as parseMtl, s as parseObj } from "../renderer-oi1MSF3Y.js";
1
+ import { c as renderObjModel, o as parseMtl, s as parseObj } from "../renderer-Dw4dN33b.js";
2
2
  export { parseMtl, parseObj, renderObjModel };
@@ -1,2 +1,2 @@
1
- import { i as RenderedFrames, n as ItemRenderOutcome, r as PipelineSettings, t as ItemPipeline } from "../pipeline-CJNiQG-1.js";
1
+ import { i as RenderedFrames, n as ItemRenderOutcome, r as PipelineSettings, t as ItemPipeline } from "../pipeline-Bp6amYz_.js";
2
2
  export { ItemPipeline, ItemRenderOutcome, PipelineSettings, RenderedFrames };
@@ -1,2 +1,2 @@
1
- import { t as ItemPipeline } from "../pipeline-BVYj7OP0.js";
1
+ import { t as ItemPipeline } from "../pipeline-B_bU50qk.js";
2
2
  export { ItemPipeline };
@@ -1,2 +1,2 @@
1
- import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "../renderer-oi1MSF3Y.js";
1
+ import { a as renderModelFrames, i as renderModel, n as boxDownscale, r as pointResize, t as ItemRenderError } from "../renderer-Dw4dN33b.js";
2
2
  export { ItemRenderError, boxDownscale, pointResize, renderModel, renderModelFrames };
@@ -7,7 +7,7 @@ import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-CM
7
7
  import { t as paintBucketFluid } from "./fluid-bucket-BzoLofB_.js";
8
8
  import { r as buildElementFaces } from "./geometry-Bi-Bf5rb.js";
9
9
  import { c as lightsForProfile } from "./lighting--5myudVu.js";
10
- import { i as resolveTexture } from "./loader-DwkA9LR5.js";
10
+ import { i as resolveTexture } from "./loader-CWsTZgrk.js";
11
11
  //#region src/render/obj.ts
12
12
  /**
13
13
  * Forge/NeoForge OBJ model rendering — the class the old pipeline left
@@ -220,6 +220,8 @@ async function renderObjModel(model, resources, textures, options) {
220
220
  var ItemRenderError = class extends Error {};
221
221
  const TICK_MS = 50;
222
222
  const MAX_ANIMATION_FRAMES = 128;
223
+ /** Per-frame delay is a uint16 of milliseconds in both WebP and GIF. */
224
+ const MAX_FRAME_DELAY_MS = 65535;
223
225
  function gcd(left, right) {
224
226
  return right === 0 ? left : gcd(right, left % right);
225
227
  }
@@ -282,8 +284,8 @@ async function renderModelFrames(model, textures, options) {
282
284
  return {
283
285
  frames,
284
286
  delaysMs: emitTicks.map((tick, index) => {
285
- const next = index + 1 < emitTicks.length ? emitTicks[index + 1] : ticks;
286
- return Math.max(TICK_MS, (next - tick) * TICK_MS);
287
+ const raw = ((index + 1 < emitTicks.length ? emitTicks[index + 1] : ticks) - tick) * TICK_MS;
288
+ return Math.min(MAX_FRAME_DELAY_MS, Math.max(TICK_MS, Math.round(raw)));
287
289
  }),
288
290
  animation: {
289
291
  ticks,
@@ -4,7 +4,7 @@ import { r as encodeRasterAsset } from "./encode-LR9wxigC.js";
4
4
  import { t as classifyItemStyle } from "./item-styles-upgEO1yP.js";
5
5
  import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
6
6
  import { t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
7
- import { t as ItemPipeline } from "./pipeline-BVYj7OP0.js";
7
+ import { t as ItemPipeline } from "./pipeline-B_bU50qk.js";
8
8
  import { t as describeResources } from "./descriptor-DWebtkI1.js";
9
9
  import { t as WorkerRenderPool } from "./pool-CKGp1qup.js";
10
10
  import path from "node:path";
package/dist/run.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import { o as evaluateItemModel } from "./definition-ColsvWrH.js";
2
- import { t as run } from "./run-C6AP3Bn8.js";
2
+ import { t as run } from "./run-DAayk01r.js";
3
3
  export { evaluateItemModel, run };
@@ -1,5 +1,5 @@
1
1
  import { s as ResourceDescriptor } from "../manager-Cv1NeFyF.js";
2
- import { n as ItemRenderOutcome, r as PipelineSettings } from "../pipeline-CJNiQG-1.js";
2
+ import { n as ItemRenderOutcome, r as PipelineSettings } from "../pipeline-Bp6amYz_.js";
3
3
  //#region src/workers/render-worker.d.ts
4
4
  interface RenderWorkerData {
5
5
  resources: ResourceDescriptor;
@@ -1,4 +1,4 @@
1
- import { t as ItemPipeline } from "../pipeline-BVYj7OP0.js";
1
+ import { t as ItemPipeline } from "../pipeline-B_bU50qk.js";
2
2
  import { n as restoreResources } from "../descriptor-DWebtkI1.js";
3
3
  import sharp from "sharp";
4
4
  import { parentPort, workerData } from "node:worker_threads";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodecraft/rendermite",
3
- "version": "1.1.0",
3
+ "version": "1.1.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",