@nodecraft/rendermite 1.10.0 → 1.10.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.
Files changed (81) hide show
  1. package/README.md +8 -7
  2. package/dist/{block-behaviour-BBslelpW.d.ts → block-behaviour-CzK3KVLx.d.ts} +2 -0
  3. package/dist/{block-overrides-XtxICunI.js → block-overrides-BhuJIxKC.js} +1 -1
  4. package/dist/blocks/block-behaviour.d.ts +1 -1
  5. package/dist/blocks/block-overrides.d.ts +1 -1
  6. package/dist/blocks/block-overrides.js +1 -1
  7. package/dist/blocks/cli.js +1 -1
  8. package/dist/blocks/ender-storage.d.ts +1 -1
  9. package/dist/blocks/ender-storage.js +1 -1
  10. package/dist/blocks/entities.d.ts +1 -1
  11. package/dist/blocks/entity-geo.js +1 -1
  12. package/dist/blocks/entity-models.d.ts +1 -1
  13. package/dist/blocks/entity-models.js +1 -1
  14. package/dist/blocks/entity-sizes.js +1 -1
  15. package/dist/blocks/export.js +1 -1
  16. package/dist/blocks/game-rules.js +1 -1
  17. package/dist/blocks/geo-blocks.d.ts +1 -1
  18. package/dist/blocks/geo-blocks.js +1 -1
  19. package/dist/blocks/item-sprites.d.ts +1 -1
  20. package/dist/blocks/light-bytecode.d.ts +1 -1
  21. package/dist/blocks/light-bytecode.js +1 -1
  22. package/dist/blocks/light-eval.d.ts +1 -1
  23. package/dist/blocks/light.d.ts +3 -1
  24. package/dist/blocks/light.js +1 -1
  25. package/dist/blocks/obj-mesh.js +1 -1
  26. package/dist/blocks/pack-format.d.ts +1 -1
  27. package/dist/blocks/sprite-sheet.d.ts +1 -1
  28. package/dist/blocks/sprite-sheet.js +1 -1
  29. package/dist/cached-BOX3n1Dl.js +54 -0
  30. package/dist/{cli-DwMPoX0I.js → cli--LNKFich.js} +1 -1
  31. package/dist/cli.js +2 -2
  32. package/dist/{compose-BGsNFR12.js → compose-CuIKcRpx.js} +1 -1
  33. package/dist/{encode-LR9wxigC.js → encode-TzYXOEId.js} +5 -4
  34. package/dist/{ender-storage-Dgomp6r2.js → ender-storage-CKDiYgYc.js} +1 -1
  35. package/dist/entities/mappings.js +1 -1
  36. package/dist/entities/model-code.js +1 -1
  37. package/dist/{entity-fallback-BucEf6WB.js → entity-fallback-BEzCbJq0.js} +1 -1
  38. package/dist/{entity-geo-DbTtMlPL.js → entity-geo-DcrcN8TE.js} +1 -1
  39. package/dist/{entity-models-vFl_EwfA.js → entity-models-D6AMLAy6.js} +3 -3
  40. package/dist/{entity-sizes-DspxgSUA.js → entity-sizes-Dmr4w0vu.js} +4 -3
  41. package/dist/{export-ArMmWuCC.js → export-Btg1y70w.js} +12 -10
  42. package/dist/{face-DbyyYmzp.js → face-D6SfTISC.js} +1 -1
  43. package/dist/{game-rules-BDPTopVW.js → game-rules-Dehe210A.js} +4 -3
  44. package/dist/{geo-BoDxwvz5.js → geo-BOYYFFQn.js} +3 -3
  45. package/dist/{geo-blocks-W79q5A0f.js → geo-blocks-BQqFfAQT.js} +1 -1
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.js +6 -6
  48. package/dist/{light-CZRA1pOj.js → light-BtV-VxAi.js} +26 -9
  49. package/dist/{light-bytecode-BqpQWqP7.js → light-bytecode-Bx3XLTRI.js} +45 -6
  50. package/dist/{light-eval-C0-kt0bp.d.ts → light-eval-B4q-aVcf.d.ts} +1 -1
  51. package/dist/{mappings-DEl_7xxQ.js → mappings-CTB7_uZa.js} +16 -1
  52. package/dist/{model-code-BmA5ilgt.js → model-code-C5Au_FKU.js} +4 -3
  53. package/dist/{obj-DPEK_xee.js → obj-NxBaySXt.js} +67 -33
  54. package/dist/{obj-mesh-BFhtTBXX.js → obj-mesh-BBSLG2Fv.js} +1 -1
  55. package/dist/output/encode.js +1 -1
  56. package/dist/output/item-styles.d.ts +1 -1
  57. package/dist/output/stylesheet.d.ts +1 -1
  58. package/dist/output/stylesheet.js +1 -1
  59. package/dist/pack.d.ts +2 -2
  60. package/dist/{pipeline-Q_185kY6.js → pipeline-CCfkRth7.js} +7 -6
  61. package/dist/{rasterizer-DcVJzkxz.js → rasterizer-M9Y7mn-W.js} +13 -5
  62. package/dist/read-ahead-BlSzTexs.js +31 -0
  63. package/dist/render/compose.js +1 -1
  64. package/dist/render/entity-fallback.js +1 -1
  65. package/dist/render/face.js +1 -1
  66. package/dist/render/geo.js +1 -1
  67. package/dist/render/obj.js +1 -1
  68. package/dist/render/pipeline.js +1 -1
  69. package/dist/render/rasterizer.js +1 -1
  70. package/dist/render/renderer.js +1 -1
  71. package/dist/resources/cached.d.ts +27 -0
  72. package/dist/resources/cached.js +2 -0
  73. package/dist/resources/read-ahead.d.ts +12 -0
  74. package/dist/resources/read-ahead.js +2 -0
  75. package/dist/{run-5yX5KRiI.js → run-Bf5TLTJw.js} +7 -6
  76. package/dist/run.js +1 -1
  77. package/dist/{sprite-sheet-LQAEtGkp.js → sprite-sheet-BWsLl0Vd.js} +4 -2
  78. package/dist/{stylesheet-CovT3B2S.js → stylesheet-C61VrCAV.js} +6 -4
  79. package/dist/{stylesheet-i-t_7sZ7.d.ts → stylesheet-DxHkk4qA.d.ts} +2 -0
  80. package/dist/workers/render-worker.js +1 -1
  81. package/package.json +1 -1
@@ -1,9 +1,10 @@
1
1
  import { r as compareVersions } from "./prepare-DkJkZXuQ.js";
2
2
  import { t as parseClassFile } from "./classfile-BJSs3JH0.js";
3
- import { c as resolveMappings, s as remapDescriptor, t as MappingsUnavailableError } from "./mappings-DEl_7xxQ.js";
3
+ import { c as resolveMappings, s as remapDescriptor, t as MappingsUnavailableError } from "./mappings-CTB7_uZa.js";
4
+ import { t as readAhead } from "./read-ahead-BlSzTexs.js";
4
5
  import { t as blockBehaviour } from "./block-behaviour-DVjqeSkv.js";
5
- import { i as overrideOf, n as constantFluidOf, t as alwaysInvisible } from "./block-overrides-XtxICunI.js";
6
- import { t as extractBlockLight } from "./light-bytecode-BqpQWqP7.js";
6
+ import { i as overrideOf, n as constantFluidOf, t as alwaysInvisible } from "./block-overrides-BhuJIxKC.js";
7
+ import { t as extractBlockLight } from "./light-bytecode-Bx3XLTRI.js";
7
8
  //#region src/blocks/light.ts
8
9
  /**
9
10
  * Block light emission for the exported pack: `light.json`.
@@ -191,9 +192,15 @@ function findLightGetters(roots, propsClasses, resolve, notes) {
191
192
  }
192
193
  /** Reference renaming through the mappings: a mod's original names onto an obfuscated client's. */
193
194
  function remapper(mappings, superOf = () => null) {
195
+ const remappedClasses = /* @__PURE__ */ new Map();
194
196
  const remapClass = (internalName) => {
195
- const mapped = mappings.obfuscatedOf.get(internalName.replaceAll("/", "."));
196
- return mapped ? mapped.replaceAll(".", "/") : internalName;
197
+ let remapped = remappedClasses.get(internalName);
198
+ if (remapped === void 0) {
199
+ const mapped = mappings.obfuscatedOf.get(internalName.replaceAll("/", "."));
200
+ remapped = mapped ? mapped.replaceAll(".", "/") : internalName;
201
+ remappedClasses.set(internalName, remapped);
202
+ }
203
+ return remapped;
197
204
  };
198
205
  const remap = (reference, field) => {
199
206
  const dotted = reference.owner.replaceAll("/", ".");
@@ -206,15 +213,24 @@ function remapper(mappings, superOf = () => null) {
206
213
  descriptor: remapDescriptor(reference.descriptor, mappings.obfuscatedOf)
207
214
  };
208
215
  };
216
+ const memberNames = /* @__PURE__ */ new Map();
209
217
  const nameOf = (reference, field) => {
218
+ const key = field ? `field ${reference.owner}.${reference.name}` : `method ${reference.owner}.${reference.name}${reference.descriptor}`;
219
+ let name = memberNames.get(key);
220
+ if (name !== void 0) return name;
221
+ name = reference.name;
210
222
  let owner = reference.owner;
211
223
  for (let hops = 0; owner && hops < 8; hops++) {
212
224
  const dotted = owner.replaceAll("/", ".");
213
225
  const found = mappings.nameOf?.get(field ? `${dotted}.${reference.name}` : `${dotted}.${reference.name}${reference.descriptor}`);
214
- if (found) return found;
226
+ if (found) {
227
+ name = found;
228
+ break;
229
+ }
215
230
  owner = superOf(owner);
216
231
  }
217
- return reference.name;
232
+ memberNames.set(key, name);
233
+ return name;
218
234
  };
219
235
  return {
220
236
  remap,
@@ -243,8 +259,8 @@ async function collectBlockLight(options) {
243
259
  const { remap, remapClass } = remapper(mappings);
244
260
  const isClearJar = names.some((name) => name.replaceAll(".", "/") === "net/minecraft/world/level/block/Blocks");
245
261
  const bytes = /* @__PURE__ */ new Map();
246
- for (const name of names) {
247
- const read = await classes.read(name);
262
+ for (const [name, pending] of readAhead(names, (internal) => classes.read(internal))) {
263
+ const read = await pending;
248
264
  if (read) bytes.set(name.replaceAll(".", "/"), read);
249
265
  }
250
266
  const parsed = /* @__PURE__ */ new Map();
@@ -302,6 +318,7 @@ async function collectBlockLight(options) {
302
318
  remap,
303
319
  remapClass,
304
320
  nameOf,
321
+ defaultStateOf: options.defaultStateOf,
305
322
  propsClasses,
306
323
  lightGetters: findLightGetters(roots, propsClasses, resolve, notes),
307
324
  isVanillaClass: (name) => mappings.originalOf.size === 0 || mappings.originalOf.has(name.replaceAll("/", ".")) || name.startsWith("net/minecraft/") || name.startsWith("com/mojang/")
@@ -1,5 +1,5 @@
1
1
  import { r as parseDescriptor } from "./model-bytecode-CXYAZ5dX.js";
2
- import { n as instructions } from "./entity-sizes-DspxgSUA.js";
2
+ import { n as instructions } from "./entity-sizes-Dmr4w0vu.js";
3
3
  import { n as statedMapColor } from "./block-behaviour-DVjqeSkv.js";
4
4
  //#region src/blocks/light-bytecode.ts
5
5
  /**
@@ -428,6 +428,44 @@ var Interpreter = class Interpreter {
428
428
  return parent === "java/lang/Enum" || parent !== null && this.shared.source.resolve(parent)?.superClass === "java/lang/Enum";
429
429
  }
430
430
  /**
431
+ * A function of state run at a registered block's default state, which only the data generator's
432
+ * report states: a sign takes its log's colour, and a log is `axis=y` until placed otherwise.
433
+ */
434
+ atDefaultState(block, fn) {
435
+ const { source, registrations } = this.shared;
436
+ let values = null;
437
+ for (const [name, registration] of registrations) {
438
+ if (registration.block !== block || values) continue;
439
+ const id = name.includes(":") ? name : registration.vanilla ? `minecraft:${name}` : null;
440
+ values = id ? source.defaultStateOf?.(id) ?? null : null;
441
+ }
442
+ if (!values) return null;
443
+ const saved = {
444
+ steps: this.shared.steps,
445
+ frames: this.shared.frames,
446
+ probe: this.shared.probe
447
+ };
448
+ const probe = {
449
+ values: new Map(Object.entries(values)),
450
+ domains: /* @__PURE__ */ new Map(),
451
+ reads: /* @__PURE__ */ new Set(),
452
+ failure: null
453
+ };
454
+ this.shared.probe = probe;
455
+ this.shared.steps = Math.min(saved.steps, CTOR_BUDGET);
456
+ try {
457
+ const result = this.invokeLambda(fn, [{
458
+ kind: "state",
459
+ probe
460
+ }]);
461
+ return probe.failure ? null : result;
462
+ } finally {
463
+ this.shared.steps = saved.steps - Math.max(0, Math.min(saved.steps, CTOR_BUDGET) - this.shared.steps);
464
+ this.shared.frames = saved.frames;
465
+ this.shared.probe = saved.probe;
466
+ }
467
+ }
468
+ /**
431
469
  * The class a factory lambda constructs, read off its body rather than run: `props -> new
432
470
  * StairBlock(base, props)` builds a `StairBlock`. What a stair overrides lives on that class.
433
471
  */
@@ -455,7 +493,7 @@ var Interpreter = class Interpreter {
455
493
  }
456
494
  const ids = names.filter((name) => looksLikeId(name));
457
495
  if (ids.length === 0) return null;
458
- const known = ids.map((name) => this.shared.registrations.get(name)).find((entry) => entry !== void 0);
496
+ const known = ids.map((name) => this.shared.registrations.get(name)).findLast((entry) => entry !== void 0);
459
497
  if (known && ids.every((name) => this.shared.registrations.has(name))) return known.block ?? this.blockFor(known);
460
498
  let props = null;
461
499
  let block = null;
@@ -465,7 +503,7 @@ var Interpreter = class Interpreter {
465
503
  else if (arg.kind === "lambda" && arg.name === "<init>") blockType ??= this.shared.source.remapClass(arg.owner);
466
504
  else if (arg.kind === "lambda") blockType ??= this.constructedIn(arg);
467
505
  if (!props && !block) for (const arg of args) {
468
- if (arg.kind !== "lambda") continue;
506
+ if (arg.kind !== "lambda" || parseDescriptor(arg.descriptor).args.length > arg.captured.length) continue;
469
507
  const made = this.invokeLambda(arg, []);
470
508
  if (made?.kind === "object" && made.handle.props) {
471
509
  block = made.handle;
@@ -863,7 +901,7 @@ var Interpreter = class Interpreter {
863
901
  return;
864
902
  }
865
903
  }
866
- const registered = this.detectRegistration(args, `${remapped.owner}.${remapped.name}${remapped.descriptor}`);
904
+ const registered = returns.startsWith("L") && source.resolve(returns.slice(1, -1))?.superClass === "java/lang/Record" ? null : this.detectRegistration(args, `${remapped.owner}.${remapped.name}${remapped.descriptor}`);
867
905
  if (registered) {
868
906
  this.push(returns === "V" ? null : returns.startsWith("L") ? {
869
907
  kind: "object",
@@ -876,8 +914,9 @@ var Interpreter = class Interpreter {
876
914
  const named = source.nameOf?.(reference, false) ?? remapped.name;
877
915
  if (target.props && args.length === 0 && (named === "defaultMapColor" || named === "defaultMaterialColor")) {
878
916
  const colour = statedMapColor(target.props);
879
- if (colour && colour.kind !== "lambda") {
880
- this.push(colour);
917
+ const answer = colour?.kind === "lambda" ? this.atDefaultState(target, colour) : colour;
918
+ if (answer) {
919
+ this.push(answer);
881
920
  return;
882
921
  }
883
922
  }
@@ -1,5 +1,5 @@
1
1
  import { n as BlockProperties } from "./blockstate-eval-BzznRcVY.js";
2
- import { j as BlockPackLight } from "./block-behaviour-BBslelpW.js";
2
+ import { j as BlockPackLight } from "./block-behaviour-CzK3KVLx.js";
3
3
  //#region src/blocks/light-eval.d.ts
4
4
  /**
5
5
  * The light a block emits in the given state, 0–15.
@@ -160,8 +160,23 @@ function parseMappings(text) {
160
160
  nameOf
161
161
  };
162
162
  }
163
+ /**
164
+ * The last file parsed. An export reads one version's mappings from light, entity sizes and entity
165
+ * geometry in turn, and each parse is most of a second; one slot keeps a seed across versions bounded.
166
+ */
167
+ let lastParsed = null;
163
168
  async function loadMappings(version, cacheDir) {
164
- return parseMappings(await readFile(await downloadClientMappings(version, cacheDir), "utf8"));
169
+ const file = await downloadClientMappings(version, cacheDir);
170
+ if (lastParsed?.file === file) return lastParsed.mappings;
171
+ const entry = {
172
+ file,
173
+ mappings: readFile(file, "utf8").then((text) => parseMappings(text))
174
+ };
175
+ lastParsed = entry;
176
+ entry.mappings.catch(() => {
177
+ if (lastParsed === entry) lastParsed = null;
178
+ });
179
+ return entry.mappings;
165
180
  }
166
181
  /**
167
182
  * Mappings for a jar that was never obfuscated: every class maps to itself.
@@ -1,4 +1,5 @@
1
1
  import { t as parseClassFile } from "./classfile-BJSs3JH0.js";
2
+ import { t as readAhead } from "./read-ahead-BlSzTexs.js";
2
3
  //#region src/entities/model-code.ts
3
4
  /**
4
5
  * Which classes in a jar count as model code, and their parsed form.
@@ -24,9 +25,9 @@ function isModelCode(name) {
24
25
  */
25
26
  async function loadModelCode(names, read, originalOf) {
26
27
  const code = /* @__PURE__ */ new Map();
27
- for (const name of names) {
28
- if (!isModelCode(originalOf?.(name) ?? name)) continue;
29
- const bytes = await read(name);
28
+ const modelNames = Iterator.from(names).filter((name) => isModelCode(originalOf?.(name) ?? name));
29
+ for (const [name, pending] of readAhead(modelNames, read)) {
30
+ const bytes = await pending;
30
31
  if (bytes) code.set(name.replaceAll(".", "/"), bytes);
31
32
  }
32
33
  const parsed = /* @__PURE__ */ new Map();
@@ -2,9 +2,9 @@ import { n as ResourceLocator } from "./locator-COMEtEn9.js";
2
2
  import { l as toFloatTexture, n as cloneFloatTexture, r as darkenTexture, s as tintTexture, t as blendPixel } from "./blend-KXMclcHk.js";
3
3
  import { c as normalize, g as transformVector, m as sub, n as displayMatrix, o as identity, r as dot, s as multiply, t as cross } from "./vector-CCxLae_T.js";
4
4
  import { c as lightsForProfile } from "./lighting--5myudVu.js";
5
- import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, t as RowCursor } from "./rasterizer-DcVJzkxz.js";
6
- import { t as combineFaceBuffers } from "./compose-BGsNFR12.js";
7
- import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-DbyyYmzp.js";
5
+ import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, t as RowCursor } from "./rasterizer-M9Y7mn-W.js";
6
+ import { t as combineFaceBuffers } from "./compose-CuIKcRpx.js";
7
+ import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "./face-D6SfTISC.js";
8
8
  import { t as paintBucketFluid } from "./fluid-bucket-B-I4ZYHl.js";
9
9
  import { r as buildElementFaces } from "./geometry-bUDBhncX.js";
10
10
  import { i as resolveTexture } from "./loader-qOH0Jynq.js";
@@ -226,10 +226,14 @@ async function renderGeneratedItemWith(model, supplier, renderSize, tints) {
226
226
  const float = toFloatTexture(texture);
227
227
  const tint = tints?.[layerIndex] ?? null;
228
228
  if (tint) tintTexture(float, tint.r, tint.g, tint.b);
229
- const resized = pointResize(float, renderSize, renderSize);
230
- for (let offset = 0; offset < out.length; offset += 4) {
231
- const alpha = resized.data[offset + 3];
232
- if (alpha > 0) blendPixel(out, offset, resized.data[offset], resized.data[offset + 1], resized.data[offset + 2], alpha);
229
+ const srcXs = pointColumns(float.width, renderSize);
230
+ for (let y = 0; y < renderSize; y++) {
231
+ const srcRow = pointRow(float.height, renderSize, y) * float.width;
232
+ for (let x = 0; x < renderSize; x++) {
233
+ const src = (srcRow + srcXs[x]) * 4;
234
+ const alpha = float.data[src + 3];
235
+ if (alpha > 0) blendPixel(out, (y * renderSize + x) * 4, float.data[src], float.data[src + 1], float.data[src + 2], alpha);
236
+ }
233
237
  }
234
238
  }
235
239
  return {
@@ -336,18 +340,29 @@ async function renderElementModelWith(model, supplier, renderSize, options, sess
336
340
  }
337
341
  return combineFaceBuffers(renderSize, renderSize, buffers);
338
342
  }
339
- /** Nearest-neighbour resize matching Imagick FILTER_POINT (destination-center sampling). */
340
- function pointResize(texture, width, height) {
341
- const data = new Float64Array(width * height * 4);
343
+ /**
344
+ * Source column for every destination column of a point resize. The mapping is
345
+ * identical for every row, so computing it once avoids width * height redundant
346
+ * Math.floor + division calls.
347
+ */
348
+ function pointColumns(sourceWidth, width) {
342
349
  const srcXs = new Int32Array(width);
343
350
  for (let x = 0; x < width; x++) {
344
- const srcX = Math.floor((x + .5) * texture.width / width);
345
- srcXs[x] = srcX >= texture.width ? texture.width - 1 : srcX;
351
+ const srcX = Math.floor((x + .5) * sourceWidth / width);
352
+ srcXs[x] = srcX >= sourceWidth ? sourceWidth - 1 : srcX;
346
353
  }
354
+ return srcXs;
355
+ }
356
+ function pointRow(sourceHeight, height, y) {
357
+ const srcY = Math.floor((y + .5) * sourceHeight / height);
358
+ return srcY >= sourceHeight ? sourceHeight - 1 : srcY;
359
+ }
360
+ /** Nearest-neighbour resize matching Imagick FILTER_POINT (destination-center sampling). */
361
+ function pointResize(texture, width, height) {
362
+ const data = new Float64Array(width * height * 4);
363
+ const srcXs = pointColumns(texture.width, width);
347
364
  for (let y = 0; y < height; y++) {
348
- let srcY = Math.floor((y + .5) * texture.height / height);
349
- srcY = srcY >= texture.height ? texture.height - 1 : srcY;
350
- const srcRow = srcY * texture.width;
365
+ const srcRow = pointRow(texture.height, height, y) * texture.width;
351
366
  const dstRow = y * width;
352
367
  for (let x = 0; x < width; x++) {
353
368
  const src = (srcRow + srcXs[x]) * 4;
@@ -371,29 +386,48 @@ function pointResize(texture, width, height) {
371
386
  * Q16 quantum with round-half-up. Verified against Imagick FILTER_BOX output.
372
387
  */
373
388
  function boxDownscale(texture, factor) {
374
- return boxPass(boxPass(texture, factor, true), factor, false);
375
- }
376
- function boxPass(texture, factor, isHorizontal) {
377
- const width = isHorizontal ? Math.round(texture.width / factor) : texture.width;
378
- const height = isHorizontal ? texture.height : Math.round(texture.height / factor);
389
+ const { width: sourceWidth, height: sourceHeight, data: src } = texture;
390
+ const width = Math.round(sourceWidth / factor);
391
+ const height = Math.round(sourceHeight / factor);
392
+ const quanta = new Float64Array(width * sourceHeight * 4);
393
+ for (let y = 0; y < sourceHeight; y++) for (let x = 0; x < width; x++) {
394
+ const start = (y * sourceWidth + x * factor) * 4;
395
+ let alphaSum = 0;
396
+ for (let i = 0, srcOffset = start; i < factor; i++, srcOffset += 4) alphaSum += Math.round(src[srcOffset + 3] * 65535);
397
+ const dst = (y * width + x) * 4;
398
+ if (alphaSum > 0) {
399
+ let r = 0;
400
+ let g = 0;
401
+ let b = 0;
402
+ for (let i = 0, srcOffset = start; i < factor; i++, srcOffset += 4) {
403
+ const alpha = Math.round(src[srcOffset + 3] * 65535);
404
+ r += Math.round(src[srcOffset] * 65535) * alpha;
405
+ g += Math.round(src[srcOffset + 1] * 65535) * alpha;
406
+ b += Math.round(src[srcOffset + 2] * 65535) * alpha;
407
+ }
408
+ quanta[dst] = clampQuantum(r / alphaSum);
409
+ quanta[dst + 1] = clampQuantum(g / alphaSum);
410
+ quanta[dst + 2] = clampQuantum(b / alphaSum);
411
+ }
412
+ quanta[dst + 3] = clampQuantum(alphaSum / factor);
413
+ }
379
414
  const data = new Float64Array(width * height * 4);
380
- const { data: src } = texture;
415
+ const rowStride = width * 4;
381
416
  for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
382
- let r = 0;
383
- let g = 0;
384
- let b = 0;
417
+ const start = (y * factor * width + x) * 4;
385
418
  let alphaSum = 0;
386
- for (let i = 0; i < factor; i++) {
387
- const srcX = isHorizontal ? x * factor + i : x;
388
- const srcOffset = ((isHorizontal ? y : y * factor + i) * texture.width + srcX) * 4;
389
- const alpha = Math.round(src[srcOffset + 3] * 65535);
390
- r += Math.round(src[srcOffset] * 65535) * alpha;
391
- g += Math.round(src[srcOffset + 1] * 65535) * alpha;
392
- b += Math.round(src[srcOffset + 2] * 65535) * alpha;
393
- alphaSum += alpha;
394
- }
419
+ for (let i = 0, srcOffset = start; i < factor; i++, srcOffset += rowStride) alphaSum += quanta[srcOffset + 3];
395
420
  const dst = (y * width + x) * 4;
396
421
  if (alphaSum > 0) {
422
+ let r = 0;
423
+ let g = 0;
424
+ let b = 0;
425
+ for (let i = 0, srcOffset = start; i < factor; i++, srcOffset += rowStride) {
426
+ const alpha = quanta[srcOffset + 3];
427
+ r += quanta[srcOffset] * alpha;
428
+ g += quanta[srcOffset + 1] * alpha;
429
+ b += quanta[srcOffset + 2] * alpha;
430
+ }
397
431
  data[dst] = clampQuantum(r / alphaSum) / 65535;
398
432
  data[dst + 1] = clampQuantum(g / alphaSum) / 65535;
399
433
  data[dst + 2] = clampQuantum(b / alphaSum) / 65535;
@@ -1,5 +1,5 @@
1
1
  import { n as ResourceLocator } from "./locator-COMEtEn9.js";
2
- import { n as parseMtl, r as parseObj, t as materialTexture } from "./obj-DPEK_xee.js";
2
+ import { n as parseMtl, r as parseObj, t as materialTexture } from "./obj-NxBaySXt.js";
3
3
  //#region src/blocks/obj-mesh.ts
4
4
  /**
5
5
  * OBJ geometry as pack data.
@@ -1,2 +1,2 @@
1
- import { n as encodeIcon, r as encodeRasterAsset, t as encodeAnimatedIcon } from "../encode-LR9wxigC.js";
1
+ import { n as encodeIcon, r as encodeRasterAsset, t as encodeAnimatedIcon } from "../encode-TzYXOEId.js";
2
2
  export { encodeAnimatedIcon, encodeIcon, encodeRasterAsset };
@@ -1,4 +1,4 @@
1
- import { t as ItemStyle } from "../stylesheet-i-t_7sZ7.js";
1
+ import { t as ItemStyle } from "../stylesheet-DxHkk4qA.js";
2
2
  //#region src/output/item-styles.d.ts
3
3
  /**
4
4
  * Build the ItemStyle for a rendered item. `renderedIds` gates variant rules to
@@ -1,2 +1,2 @@
1
- import { i as itemClass, n as StylesheetOptions, r as generateStylesheet, t as ItemStyle } from "../stylesheet-i-t_7sZ7.js";
1
+ import { i as itemClass, n as StylesheetOptions, r as generateStylesheet, t as ItemStyle } from "../stylesheet-DxHkk4qA.js";
2
2
  export { ItemStyle, StylesheetOptions, generateStylesheet, itemClass };
@@ -1,2 +1,2 @@
1
- import { n as itemClass, t as generateStylesheet } from "../stylesheet-CovT3B2S.js";
1
+ import { n as itemClass, t as generateStylesheet } from "../stylesheet-C61VrCAV.js";
2
2
  export { generateStylesheet, itemClass };
package/dist/pack.d.ts CHANGED
@@ -3,6 +3,6 @@ import { a as BlockStateMultipartCase, d as matchesCondition, n as BlockProperti
3
3
  import { t as GameRule } from "./game-rules-ThvdDG3B.js";
4
4
  import { n as ObjMesh, t as MeshGroup } from "./obj-mesh-CzL0lOlJ.js";
5
5
  import { n as BlockTintPack, t as BlockTint } from "./tints-DwFmEkf3.js";
6
- import { B as BlockPackStatesFile, C as BlockPackBlockState, F as BlockPackModelsFile, H as BlockPackTintsFile, I as BlockPackNamesFile, L as BlockPackRenderLayer, M as BlockPackLightFile, N as BlockPackMetaFile, O as BlockPackFace, P as BlockPackModel, R as BlockPackSprite, S as BlockPackBiomesFile, T as BlockPackElement, U as BlockPackVariant, V as BlockPackTagsFile, b as BlockPackAtlasPage, j as BlockPackLight, k as BlockPackGameRulesFile, n as PushReactionName, t as BlockBehaviour, v as BlockPackAdvancementsFile, w as BlockPackBlockStatesFile, x as BlockPackBehaviourFile, y as BlockPackAtlasFile, z as BlockPackSpriteFrame } from "./block-behaviour-BBslelpW.js";
7
- import { t as blockLightLevel } from "./light-eval-C0-kt0bp.js";
6
+ import { B as BlockPackStatesFile, C as BlockPackBlockState, F as BlockPackModelsFile, H as BlockPackTintsFile, I as BlockPackNamesFile, L as BlockPackRenderLayer, M as BlockPackLightFile, N as BlockPackMetaFile, O as BlockPackFace, P as BlockPackModel, R as BlockPackSprite, S as BlockPackBiomesFile, T as BlockPackElement, U as BlockPackVariant, V as BlockPackTagsFile, b as BlockPackAtlasPage, j as BlockPackLight, k as BlockPackGameRulesFile, n as PushReactionName, t as BlockBehaviour, v as BlockPackAdvancementsFile, w as BlockPackBlockStatesFile, x as BlockPackBehaviourFile, y as BlockPackAtlasFile, z as BlockPackSpriteFrame } from "./block-behaviour-CzK3KVLx.js";
7
+ import { t as blockLightLevel } from "./light-eval-B4q-aVcf.js";
8
8
  export { type BiomeClimate, type BiomeClimatePack, type BlockBehaviour, type BlockModelVariant, type BlockPackAdvancementsFile, type BlockPackAtlasFile, type BlockPackAtlasPage, type BlockPackBehaviourFile, type BlockPackBiomesFile, type BlockPackBlockState, type BlockPackBlockStatesFile, type BlockPackElement, type BlockPackFace, type BlockPackGameRulesFile, type BlockPackLight, type BlockPackLightFile, type BlockPackMetaFile, type BlockPackModel, type BlockPackModelsFile, type BlockPackNamesFile, type BlockPackRenderLayer, type BlockPackSprite, type BlockPackSpriteFrame, type BlockPackStatesFile, type BlockPackTagsFile, type BlockPackTintsFile, type BlockPackVariant, type BlockProperties, type BlockStateDefinition, type BlockStateMultipartCase, type BlockStateVariantCase, type BlockTint, type BlockTintPack, type GameRule, type MeshGroup, type MultipartCondition, type ObjMesh, type PushReactionName, blockLightLevel, evaluateBlockState, matchesCondition, weightedVariantIndex };
@@ -2,16 +2,17 @@ import { n as ResourceLocator } from "./locator-COMEtEn9.js";
2
2
  import { n as LayeredResourceManager, t as FolderResourceManager } from "./manager-D6zXmFrO.js";
3
3
  import { l as toFloatTexture, t as blendPixel } from "./blend-KXMclcHk.js";
4
4
  import { t as ModelLoader } from "./loader-qOH0Jynq.js";
5
- import { c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "./obj-DPEK_xee.js";
6
- import { a as renderGeo, t as findGeoForItem } from "./geo-BoDxwvz5.js";
5
+ import { c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "./obj-NxBaySXt.js";
6
+ import { a as renderGeo, t as findGeoForItem } from "./geo-BOYYFFQn.js";
7
7
  import { a as defaultProperties } from "./definition-ColsvWrH.js";
8
8
  import { i as resolveItem } from "./discovery-CD0QqxSF.js";
9
9
  import { a as resolveTints } from "./tints-B3WQcPtx.js";
10
10
  import { t as loadAtlasResolver } from "./registry-DafxsAhG.js";
11
+ import { t as CachedListingResourceManager } from "./cached-BOX3n1Dl.js";
11
12
  import { n as TextureLoader } from "./loader-CsgtBuBo.js";
12
- import { t as encodeAnimatedIcon } from "./encode-LR9wxigC.js";
13
+ import { t as encodeAnimatedIcon } from "./encode-TzYXOEId.js";
13
14
  import { a as builtinDynamicResources } from "./generators-D6giKoab.js";
14
- import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-BucEf6WB.js";
15
+ import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "./entity-fallback-BEzCbJq0.js";
15
16
  import { t as legacyTintsForChain } from "./legacy-tints-l-541wgI.js";
16
17
  import { n as defaultBlockStateModel, t as blockStateTransform } from "./blockstate-DVb8Mhxc.js";
17
18
  import path from "node:path";
@@ -27,11 +28,11 @@ import { mkdir, writeFile } from "node:fs/promises";
27
28
  var ItemPipeline = class ItemPipeline {
28
29
  static async create(base, settings) {
29
30
  const dynamic = settings.builtin ? builtinDynamicResources() : null;
30
- const resources = settings.builtin && dynamic ? new LayeredResourceManager([
31
+ const resources = new CachedListingResourceManager(settings.builtin && dynamic ? new LayeredResourceManager([
31
32
  new FolderResourceManager(settings.builtin),
32
33
  dynamic.layer,
33
34
  base
34
- ]) : base;
35
+ ]) : base);
35
36
  const pipeline = new ItemPipeline(resources, dynamic?.items.map((item) => item.id) ?? null, settings);
36
37
  pipeline.textures.setAtlasResolver(await loadAtlasResolver(resources, (locator) => pipeline.textures.load(locator)));
37
38
  return pipeline;
@@ -48,12 +48,20 @@ function compactFaceBuffer(buffer) {
48
48
  let minY = buffer.height;
49
49
  let maxX = -1;
50
50
  let maxY = -1;
51
- for (let y = Math.max(buffer.dirty.minY, 0); y <= Math.min(buffer.dirty.maxY, buffer.height - 1); y++) for (let x = Math.max(buffer.dirty.minX, 0); x <= Math.min(buffer.dirty.maxX, buffer.width - 1); x++) {
52
- if (buffer.colors[(y * buffer.width + x) * 4 + 3] <= 0) continue;
53
- minX = Math.min(minX, x);
51
+ const source = buffer.colors;
52
+ const startX = Math.max(buffer.dirty.minX, 0);
53
+ const endX = Math.min(buffer.dirty.maxX, buffer.width - 1);
54
+ for (let y = Math.max(buffer.dirty.minY, 0); y <= Math.min(buffer.dirty.maxY, buffer.height - 1); y++) {
55
+ const row = y * buffer.width;
56
+ let first = startX;
57
+ while (first <= endX && source[(row + first) * 4 + 3] <= 0) first++;
58
+ if (first > endX) continue;
59
+ let last = endX;
60
+ while (last > first && source[(row + last) * 4 + 3] <= 0) last--;
61
+ minX = Math.min(minX, first);
62
+ maxX = Math.max(maxX, last);
54
63
  minY = Math.min(minY, y);
55
- maxX = Math.max(maxX, x);
56
- maxY = Math.max(maxY, y);
64
+ maxY = y;
57
65
  }
58
66
  if (maxX < minX || maxY < minY) return null;
59
67
  const width = maxX - minX + 1;
@@ -0,0 +1,31 @@
1
+ //#region src/resources/read-ahead.ts
2
+ /** Loads kept running ahead of the caller: enough to overlap one entry's decode with the next one's I/O. */
3
+ const WINDOW = 32;
4
+ /**
5
+ * Each item paired with its load, already started, in the order given; a fixed number of loads run
6
+ * ahead of the one the caller is awaiting.
7
+ *
8
+ * Whole-jar sweeps and atlas builds awaited one entry at a time, so every read paid its disk round trip
9
+ * and decode in series. The caller still awaits each load in order, so results, progress and the first
10
+ * failure land exactly where the one-at-a-time loop put them.
11
+ */
12
+ function* readAhead(items, load) {
13
+ const iterator = items[Symbol.iterator]();
14
+ const pending = [];
15
+ const fill = () => {
16
+ while (pending.length < WINDOW) {
17
+ const next = iterator.next();
18
+ if (next.done) return;
19
+ const result = Promise.try(load, next.value);
20
+ result.catch(() => {});
21
+ pending.push([next.value, result]);
22
+ }
23
+ };
24
+ fill();
25
+ for (let entry = pending.shift(); entry; entry = pending.shift()) {
26
+ yield entry;
27
+ fill();
28
+ }
29
+ }
30
+ //#endregion
31
+ export { readAhead as t };
@@ -1,2 +1,2 @@
1
- import { t as combineFaceBuffers } from "../compose-BGsNFR12.js";
1
+ import { t as combineFaceBuffers } from "../compose-CuIKcRpx.js";
2
2
  export { combineFaceBuffers };
@@ -1,2 +1,2 @@
1
- import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-BucEf6WB.js";
1
+ import { a as spawnEggTints, i as renderEntityFallback, n as dyedVariantTint, r as renderDyedVariantFallback, t as dyeVariantName } from "../entity-fallback-BEzCbJq0.js";
2
2
  export { dyeVariantName, dyedVariantTint, renderDyedVariantFallback, renderEntityFallback, spawnEggTints };
@@ -1,2 +1,2 @@
1
- import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "../face-DbyyYmzp.js";
1
+ import { n as faceMaxZ, r as renderFace, t as createShadeCache } from "../face-D6SfTISC.js";
2
2
  export { createShadeCache, faceMaxZ, renderFace };
@@ -1,2 +1,2 @@
1
- import { a as renderGeo, i as parseGeo, n as geoToFaces, r as nameTokens, t as findGeoForItem } from "../geo-BoDxwvz5.js";
1
+ import { a as renderGeo, i as parseGeo, n as geoToFaces, r as nameTokens, t as findGeoForItem } from "../geo-BOYYFFQn.js";
2
2
  export { findGeoForItem, geoToFaces, nameTokens, parseGeo, renderGeo };
@@ -1,2 +1,2 @@
1
- import { i as renderObjModel, n as parseMtl, r as parseObj, t as materialTexture } from "../obj-DPEK_xee.js";
1
+ import { i as renderObjModel, n as parseMtl, r as parseObj, t as materialTexture } from "../obj-NxBaySXt.js";
2
2
  export { materialTexture, parseMtl, parseObj, renderObjModel };
@@ -1,2 +1,2 @@
1
- import { t as ItemPipeline } from "../pipeline-Q_185kY6.js";
1
+ import { t as ItemPipeline } from "../pipeline-CCfkRth7.js";
2
2
  export { ItemPipeline };
@@ -1,2 +1,2 @@
1
- import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, r as compactFaceBuffer, t as RowCursor } from "../rasterizer-DcVJzkxz.js";
1
+ import { a as drawTexturedTriangle, i as createFaceBuffer, n as clearFaceBuffer, o as phpRound, r as compactFaceBuffer, t as RowCursor } from "../rasterizer-M9Y7mn-W.js";
2
2
  export { RowCursor, clearFaceBuffer, compactFaceBuffer, createFaceBuffer, drawTexturedTriangle, phpRound };
@@ -1,2 +1,2 @@
1
- import { a as ItemRenderError, c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "../obj-DPEK_xee.js";
1
+ import { a as ItemRenderError, c as renderModel, l as renderModelFrames, o as boxDownscale, s as pointResize } from "../obj-NxBaySXt.js";
2
2
  export { ItemRenderError, boxDownscale, pointResize, renderModel, renderModelFrames };
@@ -0,0 +1,27 @@
1
+ import { n as ResourceLocator } from "../locator-jDbdUeTd.js";
2
+ import { a as ResourceManager, i as ResourceKindName, s as ResourceDescriptor } from "../manager-Ct0dEOMg.js";
3
+ //#region src/resources/cached.d.ts
4
+ /**
5
+ * Remembers directory listings for the lifetime of one render or export.
6
+ *
7
+ * Fallback lookups (mob heads, chests, geo files, sprite fallbacks) scan a
8
+ * whole namespace per item, and every scan re-walked the jar index, re-read
9
+ * the builtin pack from disk and re-deduplicated thousands of locators across
10
+ * layers: one block export listed `minecraft` textures 849 times. The model
11
+ * and texture caches beside it already assume the tree is fixed for the run,
12
+ * so this assumes the same and no more. Reads pass straight through.
13
+ */
14
+ declare class CachedListingResourceManager implements ResourceManager {
15
+ private readonly inner;
16
+ private readonly listings;
17
+ private namespaces;
18
+ constructor(inner: ResourceManager);
19
+ getResource(kind: ResourceKindName, locator: ResourceLocator): Promise<Buffer | null>;
20
+ getAllResources(kind: ResourceKindName, locator: ResourceLocator): Promise<Buffer[]>;
21
+ hasResource(kind: ResourceKindName, locator: ResourceLocator): Promise<boolean>;
22
+ listResources(kind: ResourceKindName, namespace: string): Promise<ResourceLocator[]>;
23
+ listNamespaces(): Promise<string[]>;
24
+ describe(): ResourceDescriptor | null;
25
+ }
26
+ //#endregion
27
+ export { CachedListingResourceManager };
@@ -0,0 +1,2 @@
1
+ import { t as CachedListingResourceManager } from "../cached-BOX3n1Dl.js";
2
+ export { CachedListingResourceManager };
@@ -0,0 +1,12 @@
1
+ //#region src/resources/read-ahead.d.ts
2
+ /**
3
+ * Each item paired with its load, already started, in the order given; a fixed number of loads run
4
+ * ahead of the one the caller is awaiting.
5
+ *
6
+ * Whole-jar sweeps and atlas builds awaited one entry at a time, so every read paid its disk round trip
7
+ * and decode in series. The caller still awaits each load in order, so results, progress and the first
8
+ * failure land exactly where the one-at-a-time loop put them.
9
+ */
10
+ declare function readAhead<Item, Result>(items: Iterable<Item>, load: (item: Item) => Promise<Result>): Generator<[Item, Promise<Result>]>;
11
+ //#endregion
12
+ export { readAhead };
@@ -0,0 +1,2 @@
1
+ import { t as readAhead } from "../read-ahead-BlSzTexs.js";
2
+ export { readAhead };
@@ -2,11 +2,11 @@ import { n as ResourceLocator } from "./locator-COMEtEn9.js";
2
2
  import { n as LayeredResourceManager } from "./manager-D6zXmFrO.js";
3
3
  import { n as discoverItems } from "./discovery-CD0QqxSF.js";
4
4
  import { t as curatedModelOverrides } from "./models-BsYA-NZg.js";
5
- import { r as encodeRasterAsset } from "./encode-LR9wxigC.js";
5
+ import { r as encodeRasterAsset } from "./encode-TzYXOEId.js";
6
6
  import { t as classifyItemStyle } from "./item-styles-BAeneY1R.js";
7
7
  import { t as minifyStylesheet } from "./minify-bjMRmr5J.js";
8
- import { t as generateStylesheet } from "./stylesheet-CovT3B2S.js";
9
- import { t as ItemPipeline } from "./pipeline-Q_185kY6.js";
8
+ import { t as generateStylesheet } from "./stylesheet-C61VrCAV.js";
9
+ import { t as ItemPipeline } from "./pipeline-CCfkRth7.js";
10
10
  import { t as describeResources } from "./descriptor-Dz2cR-BH.js";
11
11
  import { t as WorkerRenderPool } from "./pool-CKGp1qup.js";
12
12
  import path from "node:path";
@@ -62,8 +62,8 @@ async function run(options) {
62
62
  });
63
63
  const { resources } = pipeline;
64
64
  const glint = await resolveEnchantmentGlint(resources);
65
- if (!glint) throw new Error("Missing enchantment glint texture (minecraft:misc/enchanted_glint_item or enchanted_item_glint)");
66
- const encodedGlint = await encodeRasterAsset(glint, fallback ? ["png", format] : [format]);
65
+ if (!glint) options.onProgress?.(0, 0, "enchantment glint", "Missing enchantment glint texture (minecraft:misc/enchanted_glint_item or enchanted_item_glint); the stylesheet has no glint overlay");
66
+ const encodedGlint = glint ? await encodeRasterAsset(glint, fallback ? ["png", format] : [format]) : /* @__PURE__ */ new Map();
67
67
  const ids = [];
68
68
  const seen = /* @__PURE__ */ new Set();
69
69
  if (options.builtin) for (const placeholder of ["renderchest:unknown", "renderchest:empty"]) {
@@ -164,7 +164,8 @@ async function run(options) {
164
164
  const stylesheet = generateStylesheet(styles, {
165
165
  prefix,
166
166
  format,
167
- fallback
167
+ fallback,
168
+ glint: glint !== null
168
169
  });
169
170
  const finalStylesheet = options.minify === false ? stylesheet : minifyStylesheet(stylesheet, (message) => options.onProgress?.(0, 0, "stylesheet", message));
170
171
  await writeFile(path.join(options.output, `${prefix}${namespaces[0]}-${size}.css`), finalStylesheet);