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/node/index.mjs
CHANGED
|
@@ -1662,7 +1662,8 @@ var init_MineRenderData = __esm({
|
|
|
1662
1662
|
}
|
|
1663
1663
|
/**
|
|
1664
1664
|
* Uses the exact version when published. Otherwise, selects the nearest patch in the same
|
|
1665
|
-
* release line (older on ties), then the latest earlier release
|
|
1665
|
+
* release line (older on ties), then the latest earlier release or the oldest published release.
|
|
1666
|
+
* Unpublished snapshots reject.
|
|
1666
1667
|
*/
|
|
1667
1668
|
static async resolve(root) {
|
|
1668
1669
|
const requestRoot = root?.replace(/\/+$/, "");
|
|
@@ -1671,11 +1672,11 @@ var init_MineRenderData = __esm({
|
|
|
1671
1672
|
const scope = AssetLoader.persistentScope;
|
|
1672
1673
|
return this.cached(`resolve:${requestRoot === void 0 ? "sources" : "explicit"}:${root}`, scope, defaultRoot, async () => {
|
|
1673
1674
|
const requestedVersion = root.slice(root.lastIndexOf("/") + 1);
|
|
1674
|
-
let manifest = await this.manifest(root, release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1675
|
+
let manifest = await this.manifest(root, requestRoot !== void 0 && release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1675
1676
|
if (manifest) return { requestedVersion, version: manifest.minecraftVersion, root, manifest };
|
|
1676
1677
|
const requested = release(requestedVersion);
|
|
1677
|
-
if (!requested
|
|
1678
|
-
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release
|
|
1678
|
+
if (!requested) {
|
|
1679
|
+
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release`);
|
|
1679
1680
|
}
|
|
1680
1681
|
const base = root.slice(0, root.lastIndexOf("/"));
|
|
1681
1682
|
const index = await this.cached(`versions:${base}`, scope, defaultRoot, async () => {
|
|
@@ -1685,9 +1686,9 @@ var init_MineRenderData = __esm({
|
|
|
1685
1686
|
}
|
|
1686
1687
|
return value.versions;
|
|
1687
1688
|
});
|
|
1688
|
-
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number
|
|
1689
|
+
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number).sort((left, right) => compare(left.number, right.number));
|
|
1689
1690
|
const sameLine = versions.filter((entry) => entry.number[0] === requested[0] && entry.number[1] === requested[1]);
|
|
1690
|
-
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] ?? versions.filter((entry) => compare(entry.number, requested) <= 0).pop();
|
|
1691
|
+
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] ?? versions.filter((entry) => compare(entry.number, requested) <= 0).pop() ?? versions[0];
|
|
1691
1692
|
if (!selected) throw new Error(`No compatible MineRender data is published for ${requestedVersion}`);
|
|
1692
1693
|
const resolvedRoot = `${base}/${selected.name}`;
|
|
1693
1694
|
manifest = await this.manifest(resolvedRoot, selected.name, resolvedRoot);
|
|
@@ -1803,12 +1804,7 @@ var init_BannerPatterns = __esm({
|
|
|
1803
1804
|
static async getLayers(value, target, root) {
|
|
1804
1805
|
if (value === void 0) return [];
|
|
1805
1806
|
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
1806
|
-
const activeRoot = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
1807
|
-
const checkSources = () => {
|
|
1808
|
-
if (activeRoot !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading banner patterns; retry the request");
|
|
1809
|
-
};
|
|
1810
1807
|
const colors = value.length ? await this.getColors(root) : void 0;
|
|
1811
|
-
checkSources();
|
|
1812
1808
|
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
1813
1809
|
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
1814
1810
|
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(colors, layer.color)) throw new Error(`Unsupported dye color ${layer.color}`);
|
|
@@ -1818,7 +1814,6 @@ var init_BannerPatterns = __esm({
|
|
|
1818
1814
|
const id = this.identifier(pattern2);
|
|
1819
1815
|
const key = new AssetKey(id.namespace, id.getFullPath(), "banner_pattern", void 0, "data", ".json", root);
|
|
1820
1816
|
pattern2 = await Caching.bannerPatternCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
1821
|
-
checkSources();
|
|
1822
1817
|
if (!pattern2) throw new Error(`Missing banner pattern ${layer.pattern}`);
|
|
1823
1818
|
}
|
|
1824
1819
|
if (!pattern2 || typeof pattern2 !== "object" || Array.isArray(pattern2) || typeof pattern2.translation_key !== "string") throw new Error("Banner patterns require asset_id and translation_key");
|
|
@@ -2107,30 +2102,24 @@ var init_Models = __esm({
|
|
|
2107
2102
|
}).then((r) => r?.files ?? []);
|
|
2108
2103
|
}
|
|
2109
2104
|
static async loadAndMerge(key, context = {}) {
|
|
2110
|
-
const checkSources = this.sourceCheck();
|
|
2111
2105
|
const model = key.type === "item" ? await this.getItemModel(key, context) : await this.getRaw(key);
|
|
2112
2106
|
if (!model) {
|
|
2113
2107
|
return void 0;
|
|
2114
2108
|
}
|
|
2115
2109
|
const merged = await ModelMerger.mergeWithParents(model);
|
|
2116
|
-
checkSources();
|
|
2117
2110
|
return merged;
|
|
2118
2111
|
}
|
|
2119
2112
|
static async getItemModel(key, context = {}) {
|
|
2120
|
-
const checkSources = this.sourceCheck();
|
|
2121
2113
|
const preview = this.snapshotContext(key, context);
|
|
2122
2114
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2123
|
-
checkSources();
|
|
2124
2115
|
return this.getPreparedItemModel(key, preview, dataKey);
|
|
2125
2116
|
}
|
|
2126
2117
|
static async getPreparedItemModel(key, preview, dataKey) {
|
|
2127
|
-
const checkSources = this.sourceCheck();
|
|
2128
2118
|
const itemId = `${key.namespace}:${key.path}`;
|
|
2129
2119
|
const itemKey2 = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
2130
2120
|
const cacheKey = itemKey2.serialize() + this.contextKey(preview) + dataKey;
|
|
2131
2121
|
const model = await this.PERSISTENT_CACHE.getOrLoad(`${this.ITEM_CACHE_VERSION}:${AssetLoader.persistentKey(cacheKey)}`, async () => {
|
|
2132
2122
|
const result = await AssetLoader.getFirst([itemKey2, key], "json" /* JSON */);
|
|
2133
|
-
checkSources();
|
|
2134
2123
|
if (!result) return void 0;
|
|
2135
2124
|
if (result.key.assetType !== "items") return { ...result.asset, key, itemId, components: preview.components };
|
|
2136
2125
|
const load = async (selected) => {
|
|
@@ -2149,10 +2138,8 @@ var init_Models = __esm({
|
|
|
2149
2138
|
return { ...model3, itemId, components: preview.components, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
2150
2139
|
};
|
|
2151
2140
|
const model2 = await load(this.selectItemModel(result.asset.model, key, preview));
|
|
2152
|
-
checkSources();
|
|
2153
2141
|
return model2;
|
|
2154
2142
|
});
|
|
2155
|
-
checkSources();
|
|
2156
2143
|
const restore = (model2) => ({
|
|
2157
2144
|
...model2,
|
|
2158
2145
|
key: Object.assign(new AssetKey("", ""), model2.key),
|
|
@@ -2216,22 +2203,14 @@ var init_Models = __esm({
|
|
|
2216
2203
|
}
|
|
2217
2204
|
static async applyDefaults(key, preview) {
|
|
2218
2205
|
if (key.type !== "item") return "";
|
|
2219
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2220
2206
|
const resolved = await MineRenderData.resolve(key.root);
|
|
2221
2207
|
const defaults = await ItemDefaults.get(`${key.namespace}:${key.path}`, key.root);
|
|
2222
2208
|
preview.components = { ...defaults, ...preview.components };
|
|
2223
2209
|
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)) {
|
|
2224
2210
|
preview.components["minecraft:enchantment_glint_override"] = true;
|
|
2225
2211
|
}
|
|
2226
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item defaults; retry the request");
|
|
2227
2212
|
return `|data:${resolved.root}:${resolved.manifest.datasets.itemDefaults?.sha256}:${resolved.manifest.datasets.potionColors?.sha256}`;
|
|
2228
2213
|
}
|
|
2229
|
-
static sourceCheck() {
|
|
2230
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2231
|
-
return () => {
|
|
2232
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item models; retry the request");
|
|
2233
|
-
};
|
|
2234
|
-
}
|
|
2235
2214
|
static contextKey(context) {
|
|
2236
2215
|
const itemReferences = Object.fromEntries(Object.entries(context.itemReferences).map(([id, key]) => [id, key.serialize()]));
|
|
2237
2216
|
return `|${this.ITEM_CACHE_VERSION}:${JSON.stringify(this.snapshotJson({ ...context, itemReferences }))}`;
|
|
@@ -2418,7 +2397,6 @@ var init_Models = __esm({
|
|
|
2418
2397
|
* @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
|
|
2419
2398
|
*/
|
|
2420
2399
|
static async getMerged(key, context = {}) {
|
|
2421
|
-
const checkSources = this.sourceCheck();
|
|
2422
2400
|
if (!key.assetType) {
|
|
2423
2401
|
key.assetType = "models";
|
|
2424
2402
|
}
|
|
@@ -2427,15 +2405,12 @@ var init_Models = __esm({
|
|
|
2427
2405
|
}
|
|
2428
2406
|
const preview = this.snapshotContext(key, context);
|
|
2429
2407
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2430
|
-
checkSources();
|
|
2431
2408
|
const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
|
|
2432
2409
|
const model = await Caching.mergedModelCache.get(keyStr, async () => {
|
|
2433
2410
|
const raw = key.type === "item" ? await this.getPreparedItemModel(key, preview, dataKey) : await this.getRaw(key);
|
|
2434
2411
|
const merged = raw ? await ModelMerger.mergeWithParents(raw) : void 0;
|
|
2435
|
-
checkSources();
|
|
2436
2412
|
return merged;
|
|
2437
2413
|
});
|
|
2438
|
-
checkSources();
|
|
2439
2414
|
return model;
|
|
2440
2415
|
}
|
|
2441
2416
|
/** Alias for {@link getMerged}. */
|
|
@@ -12419,7 +12394,6 @@ import { Euler as Euler10, Matrix4 as Matrix411, Quaternion as Quaternion5, Vect
|
|
|
12419
12394
|
init_ModelCulling();
|
|
12420
12395
|
init_FluidGeometry();
|
|
12421
12396
|
init_MineRenderData();
|
|
12422
|
-
init_AssetLoader();
|
|
12423
12397
|
init_Entities();
|
|
12424
12398
|
var BlockObject = class _BlockObject extends SceneObject {
|
|
12425
12399
|
constructor(blockState3, options) {
|
|
@@ -12449,19 +12423,12 @@ var BlockObject = class _BlockObject extends SceneObject {
|
|
|
12449
12423
|
});
|
|
12450
12424
|
}
|
|
12451
12425
|
async init() {
|
|
12452
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
12453
|
-
const checkSources = () => {
|
|
12454
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading a block; retry the request");
|
|
12455
|
-
};
|
|
12456
12426
|
this._fluidRules = await MineRenderData.get("fluids", this.blockState.key?.root);
|
|
12457
|
-
checkSources();
|
|
12458
12427
|
if (this.options.applyDefaultState) {
|
|
12459
12428
|
this._setState(await BlockStateResolver.defaults(this.blockState));
|
|
12460
|
-
checkSources();
|
|
12461
12429
|
}
|
|
12462
12430
|
if (this.options.initialState !== void 0) this._setState(this.options.initialState);
|
|
12463
12431
|
await this.recreateModels();
|
|
12464
|
-
checkSources();
|
|
12465
12432
|
}
|
|
12466
12433
|
dispose() {
|
|
12467
12434
|
this.clearModels();
|
|
@@ -16382,7 +16349,6 @@ init_util2();
|
|
|
16382
16349
|
// src/world/AnvilParser.ts
|
|
16383
16350
|
init_MineRenderError();
|
|
16384
16351
|
init_MineRenderData();
|
|
16385
|
-
init_AssetLoader();
|
|
16386
16352
|
init_NBTHelper();
|
|
16387
16353
|
|
|
16388
16354
|
// src/world/ChunkData.ts
|
|
@@ -16653,14 +16619,12 @@ var AnvilParser = class {
|
|
|
16653
16619
|
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
16654
16620
|
static async parse(data, options = {}) {
|
|
16655
16621
|
options = { ...options };
|
|
16656
|
-
const checkSources = this.assetGuard();
|
|
16657
16622
|
options.signal?.throwIfAborted();
|
|
16658
16623
|
const bytes = this.bytes(data);
|
|
16659
16624
|
const chunks = [];
|
|
16660
16625
|
for (const location of this.locations(bytes)) {
|
|
16661
16626
|
chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
|
|
16662
16627
|
}
|
|
16663
|
-
checkSources();
|
|
16664
16628
|
return { chunks };
|
|
16665
16629
|
}
|
|
16666
16630
|
/**
|
|
@@ -16671,22 +16635,12 @@ var AnvilParser = class {
|
|
|
16671
16635
|
*/
|
|
16672
16636
|
static async parseChunk(data, localX, localZ, options = {}) {
|
|
16673
16637
|
options = { ...options };
|
|
16674
|
-
const checkSources = this.assetGuard();
|
|
16675
16638
|
options.signal?.throwIfAborted();
|
|
16676
16639
|
const bytes = this.bytes(data);
|
|
16677
16640
|
const location = this.location(bytes, localX, localZ);
|
|
16678
16641
|
const chunk = location ? await this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
|
|
16679
|
-
checkSources();
|
|
16680
16642
|
return chunk;
|
|
16681
16643
|
}
|
|
16682
|
-
static assetGuard() {
|
|
16683
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
16684
|
-
return () => {
|
|
16685
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) {
|
|
16686
|
-
throw new MineRenderError("Asset sources changed while parsing Anvil data; retry the request");
|
|
16687
|
-
}
|
|
16688
|
-
};
|
|
16689
|
-
}
|
|
16690
16644
|
/**
|
|
16691
16645
|
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
16692
16646
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
@@ -17407,7 +17361,6 @@ function resolveSavedEntity(entity) {
|
|
|
17407
17361
|
|
|
17408
17362
|
// src/world/_entities/WorldEntities.ts
|
|
17409
17363
|
init_BannerPatterns();
|
|
17410
|
-
init_AssetLoader();
|
|
17411
17364
|
var WorldEntities = class {
|
|
17412
17365
|
constructor(scene) {
|
|
17413
17366
|
this.scene = scene;
|
|
@@ -17415,10 +17368,6 @@ var WorldEntities = class {
|
|
|
17415
17368
|
}
|
|
17416
17369
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
17417
17370
|
prepare(entities = [], column) {
|
|
17418
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
17419
|
-
const checkSources = () => {
|
|
17420
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading saved entities; retry the request");
|
|
17421
|
-
};
|
|
17422
17371
|
const placements = entities.flatMap((entity) => {
|
|
17423
17372
|
const resolved = resolveSavedEntity(entity);
|
|
17424
17373
|
if (!resolved) return [];
|
|
@@ -17434,17 +17383,13 @@ var WorldEntities = class {
|
|
|
17434
17383
|
let object4;
|
|
17435
17384
|
try {
|
|
17436
17385
|
if (!current()) return;
|
|
17437
|
-
checkSources();
|
|
17438
17386
|
const models = await Entities.getEntityList();
|
|
17439
|
-
checkSources();
|
|
17440
17387
|
if (!models.includes(placement.key.path) || !current()) return;
|
|
17441
17388
|
const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
|
|
17442
|
-
checkSources();
|
|
17443
17389
|
if (!model || !current()) return;
|
|
17444
17390
|
let tints = placement.tints;
|
|
17445
17391
|
if (placement.woolDye) {
|
|
17446
17392
|
const dye = (await BannerPatterns.getColors(placement.key.root))[placement.woolDye];
|
|
17447
|
-
checkSources();
|
|
17448
17393
|
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);
|
|
17449
17394
|
tints = { ...tints, wool_color: tint };
|
|
17450
17395
|
}
|
|
@@ -17454,7 +17399,6 @@ var WorldEntities = class {
|
|
|
17454
17399
|
object4.position.fromArray(placement.position).multiplyScalar(16).addScalar(-8);
|
|
17455
17400
|
object4.rotation.y = placement.yaw;
|
|
17456
17401
|
await object4.init();
|
|
17457
|
-
checkSources();
|
|
17458
17402
|
if (!current()) return;
|
|
17459
17403
|
placement.owner.add(object4);
|
|
17460
17404
|
this.scene.add(object4);
|