minerender 2.1.0-alpha.116 → 2.1.0-alpha.117
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/browser/index.d.mts +3 -3
- package/dist/browser/index.d.ts +3 -3
- package/dist/browser/index.js +7 -63
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +7 -63
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +7 -63
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +3 -3
- package/dist/node/index.d.ts +3 -3
- package/dist/node/index.js +7 -63
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +7 -63
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -43235,7 +43235,8 @@ void main() {
|
|
|
43235
43235
|
}
|
|
43236
43236
|
/**
|
|
43237
43237
|
* Uses the exact version when published. Otherwise, selects the nearest patch in the same
|
|
43238
|
-
* release line (older on ties), then the latest earlier release
|
|
43238
|
+
* release line (older on ties), then the latest earlier release or the oldest published release.
|
|
43239
|
+
* Unpublished snapshots reject.
|
|
43239
43240
|
*/
|
|
43240
43241
|
static async resolve(root) {
|
|
43241
43242
|
const requestRoot = root?.replace(/\/+$/, "");
|
|
@@ -43244,11 +43245,11 @@ void main() {
|
|
|
43244
43245
|
const scope = AssetLoader.persistentScope;
|
|
43245
43246
|
return this.cached(`resolve:${requestRoot === void 0 ? "sources" : "explicit"}:${root}`, scope, defaultRoot, async () => {
|
|
43246
43247
|
const requestedVersion = root.slice(root.lastIndexOf("/") + 1);
|
|
43247
|
-
let manifest = await this.manifest(root, release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
43248
|
+
let manifest = await this.manifest(root, requestRoot !== void 0 && release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
43248
43249
|
if (manifest) return { requestedVersion, version: manifest.minecraftVersion, root, manifest };
|
|
43249
43250
|
const requested = release(requestedVersion);
|
|
43250
|
-
if (!requested
|
|
43251
|
-
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release
|
|
43251
|
+
if (!requested) {
|
|
43252
|
+
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release`);
|
|
43252
43253
|
}
|
|
43253
43254
|
const base = root.slice(0, root.lastIndexOf("/"));
|
|
43254
43255
|
const index = await this.cached(`versions:${base}`, scope, defaultRoot, async () => {
|
|
@@ -43258,9 +43259,9 @@ void main() {
|
|
|
43258
43259
|
}
|
|
43259
43260
|
return value.versions;
|
|
43260
43261
|
});
|
|
43261
|
-
const versions2 = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number
|
|
43262
|
+
const versions2 = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number).sort((left, right) => compare(left.number, right.number));
|
|
43262
43263
|
const sameLine = versions2.filter((entry) => entry.number[0] === requested[0] && entry.number[1] === requested[1]);
|
|
43263
|
-
const selected = sameLine.sort((left, right) => Math.abs((left.number[2] ?? 0) - (requested[2] ?? 0)) - Math.abs((right.number[2] ?? 0) - (requested[2] ?? 0)) || compare(left.number, right.number))[0] ?? versions2.filter((entry) => compare(entry.number, requested) <= 0).pop();
|
|
43264
|
+
const selected = sameLine.sort((left, right) => Math.abs((left.number[2] ?? 0) - (requested[2] ?? 0)) - Math.abs((right.number[2] ?? 0) - (requested[2] ?? 0)) || compare(left.number, right.number))[0] ?? versions2.filter((entry) => compare(entry.number, requested) <= 0).pop() ?? versions2[0];
|
|
43264
43265
|
if (!selected) throw new Error(`No compatible MineRender data is published for ${requestedVersion}`);
|
|
43265
43266
|
const resolvedRoot = `${base}/${selected.name}`;
|
|
43266
43267
|
manifest = await this.manifest(resolvedRoot, selected.name, resolvedRoot);
|
|
@@ -43379,12 +43380,7 @@ ${key}` : key, async () => {
|
|
|
43379
43380
|
static async getLayers(value, target, root) {
|
|
43380
43381
|
if (value === void 0) return [];
|
|
43381
43382
|
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
43382
|
-
const activeRoot = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
43383
|
-
const checkSources = () => {
|
|
43384
|
-
if (activeRoot !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading banner patterns; retry the request");
|
|
43385
|
-
};
|
|
43386
43383
|
const colors = value.length ? await this.getColors(root) : void 0;
|
|
43387
|
-
checkSources();
|
|
43388
43384
|
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
43389
43385
|
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
43390
43386
|
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(colors, layer.color)) throw new Error(`Unsupported dye color ${layer.color}`);
|
|
@@ -43394,7 +43390,6 @@ ${key}` : key, async () => {
|
|
|
43394
43390
|
const id = this.identifier(pattern2);
|
|
43395
43391
|
const key = new AssetKey(id.namespace, id.getFullPath(), "banner_pattern", void 0, "data", ".json", root);
|
|
43396
43392
|
pattern2 = await Caching.bannerPatternCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
43397
|
-
checkSources();
|
|
43398
43393
|
if (!pattern2) throw new Error(`Missing banner pattern ${layer.pattern}`);
|
|
43399
43394
|
}
|
|
43400
43395
|
if (!pattern2 || typeof pattern2 !== "object" || Array.isArray(pattern2) || typeof pattern2.translation_key !== "string") throw new Error("Banner patterns require asset_id and translation_key");
|
|
@@ -43694,30 +43689,24 @@ ${key}` : key, async () => {
|
|
|
43694
43689
|
}).then((r5) => r5?.files ?? []);
|
|
43695
43690
|
}
|
|
43696
43691
|
static async loadAndMerge(key, context = {}) {
|
|
43697
|
-
const checkSources = this.sourceCheck();
|
|
43698
43692
|
const model = key.type === "item" ? await this.getItemModel(key, context) : await this.getRaw(key);
|
|
43699
43693
|
if (!model) {
|
|
43700
43694
|
return void 0;
|
|
43701
43695
|
}
|
|
43702
43696
|
const merged = await ModelMerger.mergeWithParents(model);
|
|
43703
|
-
checkSources();
|
|
43704
43697
|
return merged;
|
|
43705
43698
|
}
|
|
43706
43699
|
static async getItemModel(key, context = {}) {
|
|
43707
|
-
const checkSources = this.sourceCheck();
|
|
43708
43700
|
const preview = this.snapshotContext(key, context);
|
|
43709
43701
|
const dataKey = await this.applyDefaults(key, preview);
|
|
43710
|
-
checkSources();
|
|
43711
43702
|
return this.getPreparedItemModel(key, preview, dataKey);
|
|
43712
43703
|
}
|
|
43713
43704
|
static async getPreparedItemModel(key, preview, dataKey) {
|
|
43714
|
-
const checkSources = this.sourceCheck();
|
|
43715
43705
|
const itemId = `${key.namespace}:${key.path}`;
|
|
43716
43706
|
const itemKey2 = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
43717
43707
|
const cacheKey = itemKey2.serialize() + this.contextKey(preview) + dataKey;
|
|
43718
43708
|
const model = await this.PERSISTENT_CACHE.getOrLoad(`${this.ITEM_CACHE_VERSION}:${AssetLoader.persistentKey(cacheKey)}`, async () => {
|
|
43719
43709
|
const result = await AssetLoader.getFirst([itemKey2, key], "json" /* JSON */);
|
|
43720
|
-
checkSources();
|
|
43721
43710
|
if (!result) return void 0;
|
|
43722
43711
|
if (result.key.assetType !== "items") return { ...result.asset, key, itemId, components: preview.components };
|
|
43723
43712
|
const load = async (selected) => {
|
|
@@ -43736,10 +43725,8 @@ ${key}` : key, async () => {
|
|
|
43736
43725
|
return { ...model3, itemId, components: preview.components, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
43737
43726
|
};
|
|
43738
43727
|
const model2 = await load(this.selectItemModel(result.asset.model, key, preview));
|
|
43739
|
-
checkSources();
|
|
43740
43728
|
return model2;
|
|
43741
43729
|
});
|
|
43742
|
-
checkSources();
|
|
43743
43730
|
const restore = (model2) => ({
|
|
43744
43731
|
...model2,
|
|
43745
43732
|
key: Object.assign(new AssetKey("", ""), model2.key),
|
|
@@ -43803,22 +43790,14 @@ ${key}` : key, async () => {
|
|
|
43803
43790
|
}
|
|
43804
43791
|
static async applyDefaults(key, preview) {
|
|
43805
43792
|
if (key.type !== "item") return "";
|
|
43806
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
43807
43793
|
const resolved = await MineRenderData.resolve(key.root);
|
|
43808
43794
|
const defaults = await ItemDefaults.get(`${key.namespace}:${key.path}`, key.root);
|
|
43809
43795
|
preview.components = { ...defaults, ...preview.components };
|
|
43810
43796
|
if (resolved.manifest.dataVersion < 3337 && key.namespace === DEFAULT_NAMESPACE && ["potion", "splash_potion", "lingering_potion"].includes(key.path) && !Object.prototype.hasOwnProperty.call(preview.components, "minecraft:enchantment_glint_override") && await ItemTints.hasPotionEffects(preview.components["minecraft:potion_contents"], key.root)) {
|
|
43811
43797
|
preview.components["minecraft:enchantment_glint_override"] = true;
|
|
43812
43798
|
}
|
|
43813
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item defaults; retry the request");
|
|
43814
43799
|
return `|data:${resolved.root}:${resolved.manifest.datasets.itemDefaults?.sha256}:${resolved.manifest.datasets.potionColors?.sha256}`;
|
|
43815
43800
|
}
|
|
43816
|
-
static sourceCheck() {
|
|
43817
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
43818
|
-
return () => {
|
|
43819
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item models; retry the request");
|
|
43820
|
-
};
|
|
43821
|
-
}
|
|
43822
43801
|
static contextKey(context) {
|
|
43823
43802
|
const itemReferences = Object.fromEntries(Object.entries(context.itemReferences).map(([id, key]) => [id, key.serialize()]));
|
|
43824
43803
|
return `|${this.ITEM_CACHE_VERSION}:${JSON.stringify(this.snapshotJson({ ...context, itemReferences }))}`;
|
|
@@ -44005,7 +43984,6 @@ ${key}` : key, async () => {
|
|
|
44005
43984
|
* @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
|
|
44006
43985
|
*/
|
|
44007
43986
|
static async getMerged(key, context = {}) {
|
|
44008
|
-
const checkSources = this.sourceCheck();
|
|
44009
43987
|
if (!key.assetType) {
|
|
44010
43988
|
key.assetType = "models";
|
|
44011
43989
|
}
|
|
@@ -44014,15 +43992,12 @@ ${key}` : key, async () => {
|
|
|
44014
43992
|
}
|
|
44015
43993
|
const preview = this.snapshotContext(key, context);
|
|
44016
43994
|
const dataKey = await this.applyDefaults(key, preview);
|
|
44017
|
-
checkSources();
|
|
44018
43995
|
const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
|
|
44019
43996
|
const model = await Caching.mergedModelCache.get(keyStr, async () => {
|
|
44020
43997
|
const raw = key.type === "item" ? await this.getPreparedItemModel(key, preview, dataKey) : await this.getRaw(key);
|
|
44021
43998
|
const merged = raw ? await ModelMerger.mergeWithParents(raw) : void 0;
|
|
44022
|
-
checkSources();
|
|
44023
43999
|
return merged;
|
|
44024
44000
|
});
|
|
44025
|
-
checkSources();
|
|
44026
44001
|
return model;
|
|
44027
44002
|
}
|
|
44028
44003
|
/** Alias for {@link getMerged}. */
|
|
@@ -100647,7 +100622,6 @@ property list uchar int vertex_index
|
|
|
100647
100622
|
init_ModelCulling();
|
|
100648
100623
|
init_FluidGeometry();
|
|
100649
100624
|
init_MineRenderData();
|
|
100650
|
-
init_AssetLoader();
|
|
100651
100625
|
init_Entities();
|
|
100652
100626
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
100653
100627
|
constructor(blockState3, options) {
|
|
@@ -100672,19 +100646,12 @@ property list uchar int vertex_index
|
|
|
100672
100646
|
this.biomePosition = options?.biomePosition ? [...options.biomePosition] : void 0;
|
|
100673
100647
|
}
|
|
100674
100648
|
async init() {
|
|
100675
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
100676
|
-
const checkSources = () => {
|
|
100677
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading a block; retry the request");
|
|
100678
|
-
};
|
|
100679
100649
|
this._fluidRules = await MineRenderData.get("fluids", this.blockState.key?.root);
|
|
100680
|
-
checkSources();
|
|
100681
100650
|
if (this.options.applyDefaultState) {
|
|
100682
100651
|
this._setState(await BlockStateResolver.defaults(this.blockState));
|
|
100683
|
-
checkSources();
|
|
100684
100652
|
}
|
|
100685
100653
|
if (this.options.initialState !== void 0) this._setState(this.options.initialState);
|
|
100686
100654
|
await this.recreateModels();
|
|
100687
|
-
checkSources();
|
|
100688
100655
|
}
|
|
100689
100656
|
dispose() {
|
|
100690
100657
|
this.clearModels();
|
|
@@ -106679,7 +106646,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
106679
106646
|
init_process2();
|
|
106680
106647
|
init_MineRenderError();
|
|
106681
106648
|
init_MineRenderData();
|
|
106682
|
-
init_AssetLoader();
|
|
106683
106649
|
init_NBTHelper();
|
|
106684
106650
|
|
|
106685
106651
|
// src/world/ChunkData.ts
|
|
@@ -106956,14 +106922,12 @@ gl_FragDepth=readDepth(vUv);
|
|
|
106956
106922
|
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
106957
106923
|
static async parse(data, options = {}) {
|
|
106958
106924
|
options = { ...options };
|
|
106959
|
-
const checkSources = this.assetGuard();
|
|
106960
106925
|
options.signal?.throwIfAborted();
|
|
106961
106926
|
const bytes = this.bytes(data);
|
|
106962
106927
|
const chunks = [];
|
|
106963
106928
|
for (const location of this.locations(bytes)) {
|
|
106964
106929
|
chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
|
|
106965
106930
|
}
|
|
106966
|
-
checkSources();
|
|
106967
106931
|
return { chunks };
|
|
106968
106932
|
}
|
|
106969
106933
|
/**
|
|
@@ -106974,22 +106938,12 @@ gl_FragDepth=readDepth(vUv);
|
|
|
106974
106938
|
*/
|
|
106975
106939
|
static async parseChunk(data, localX, localZ, options = {}) {
|
|
106976
106940
|
options = { ...options };
|
|
106977
|
-
const checkSources = this.assetGuard();
|
|
106978
106941
|
options.signal?.throwIfAborted();
|
|
106979
106942
|
const bytes = this.bytes(data);
|
|
106980
106943
|
const location = this.location(bytes, localX, localZ);
|
|
106981
106944
|
const chunk = location ? await this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
|
|
106982
|
-
checkSources();
|
|
106983
106945
|
return chunk;
|
|
106984
106946
|
}
|
|
106985
|
-
static assetGuard() {
|
|
106986
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
106987
|
-
return () => {
|
|
106988
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) {
|
|
106989
|
-
throw new MineRenderError("Asset sources changed while parsing Anvil data; retry the request");
|
|
106990
|
-
}
|
|
106991
|
-
};
|
|
106992
|
-
}
|
|
106993
106947
|
/**
|
|
106994
106948
|
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
106995
106949
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
@@ -107733,7 +107687,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107733
107687
|
|
|
107734
107688
|
// src/world/_entities/WorldEntities.ts
|
|
107735
107689
|
init_BannerPatterns();
|
|
107736
|
-
init_AssetLoader();
|
|
107737
107690
|
var WorldEntities = class {
|
|
107738
107691
|
constructor(scene) {
|
|
107739
107692
|
this.scene = scene;
|
|
@@ -107741,10 +107694,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107741
107694
|
}
|
|
107742
107695
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
107743
107696
|
prepare(entities = [], column) {
|
|
107744
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
107745
|
-
const checkSources = () => {
|
|
107746
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading saved entities; retry the request");
|
|
107747
|
-
};
|
|
107748
107697
|
const placements = entities.flatMap((entity) => {
|
|
107749
107698
|
const resolved = resolveSavedEntity(entity);
|
|
107750
107699
|
if (!resolved) return [];
|
|
@@ -107760,17 +107709,13 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107760
107709
|
let object4;
|
|
107761
107710
|
try {
|
|
107762
107711
|
if (!current()) return;
|
|
107763
|
-
checkSources();
|
|
107764
107712
|
const models = await Entities.getEntityList();
|
|
107765
|
-
checkSources();
|
|
107766
107713
|
if (!models.includes(placement.key.path) || !current()) return;
|
|
107767
107714
|
const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
|
|
107768
|
-
checkSources();
|
|
107769
107715
|
if (!model || !current()) return;
|
|
107770
107716
|
let tints = placement.tints;
|
|
107771
107717
|
if (placement.woolDye) {
|
|
107772
107718
|
const dye = (await BannerPatterns.getColors(placement.key.root))[placement.woolDye];
|
|
107773
|
-
checkSources();
|
|
107774
107719
|
const tint = placement.woolDye === "white" ? 15132390 : Math.floor((dye >> 16 & 255) * 0.75) << 16 | Math.floor((dye >> 8 & 255) * 0.75) << 8 | Math.floor((dye & 255) * 0.75);
|
|
107775
107720
|
tints = { ...tints, wool_color: tint };
|
|
107776
107721
|
}
|
|
@@ -107780,7 +107725,6 @@ gl_FragDepth=readDepth(vUv);
|
|
|
107780
107725
|
object4.position.fromArray(placement.position).multiplyScalar(16).addScalar(-8);
|
|
107781
107726
|
object4.rotation.y = placement.yaw;
|
|
107782
107727
|
await object4.init();
|
|
107783
|
-
checkSources();
|
|
107784
107728
|
if (!current()) return;
|
|
107785
107729
|
placement.owner.add(object4);
|
|
107786
107730
|
this.scene.add(object4);
|