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/browser/index.mjs
CHANGED
|
@@ -1606,7 +1606,8 @@ var init_MineRenderData = __esm({
|
|
|
1606
1606
|
}
|
|
1607
1607
|
/**
|
|
1608
1608
|
* Uses the exact version when published. Otherwise, selects the nearest patch in the same
|
|
1609
|
-
* release line (older on ties), then the latest earlier release
|
|
1609
|
+
* release line (older on ties), then the latest earlier release or the oldest published release.
|
|
1610
|
+
* Unpublished snapshots reject.
|
|
1610
1611
|
*/
|
|
1611
1612
|
static async resolve(root) {
|
|
1612
1613
|
const requestRoot = root?.replace(/\/+$/, "");
|
|
@@ -1615,11 +1616,11 @@ var init_MineRenderData = __esm({
|
|
|
1615
1616
|
const scope = AssetLoader.persistentScope;
|
|
1616
1617
|
return this.cached(`resolve:${requestRoot === void 0 ? "sources" : "explicit"}:${root}`, scope, defaultRoot, async () => {
|
|
1617
1618
|
const requestedVersion = root.slice(root.lastIndexOf("/") + 1);
|
|
1618
|
-
let manifest = await this.manifest(root, release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1619
|
+
let manifest = await this.manifest(root, requestRoot !== void 0 && release(requestedVersion) ? requestedVersion : void 0, requestRoot);
|
|
1619
1620
|
if (manifest) return { requestedVersion, version: manifest.minecraftVersion, root, manifest };
|
|
1620
1621
|
const requested = release(requestedVersion);
|
|
1621
|
-
if (!requested
|
|
1622
|
-
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release
|
|
1622
|
+
if (!requested) {
|
|
1623
|
+
throw new Error(`No MineRender data is published for ${requestedVersion}; automatic fallback requires a release`);
|
|
1623
1624
|
}
|
|
1624
1625
|
const base = root.slice(0, root.lastIndexOf("/"));
|
|
1625
1626
|
const index = await this.cached(`versions:${base}`, scope, defaultRoot, async () => {
|
|
@@ -1629,9 +1630,9 @@ var init_MineRenderData = __esm({
|
|
|
1629
1630
|
}
|
|
1630
1631
|
return value.versions;
|
|
1631
1632
|
});
|
|
1632
|
-
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number
|
|
1633
|
+
const versions = index.map((entry) => ({ name: entry.name, number: release(entry.name) })).filter((entry) => !!entry.number).sort((left, right) => compare(left.number, right.number));
|
|
1633
1634
|
const sameLine = versions.filter((entry) => entry.number[0] === requested[0] && entry.number[1] === requested[1]);
|
|
1634
|
-
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();
|
|
1635
|
+
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];
|
|
1635
1636
|
if (!selected) throw new Error(`No compatible MineRender data is published for ${requestedVersion}`);
|
|
1636
1637
|
const resolvedRoot = `${base}/${selected.name}`;
|
|
1637
1638
|
manifest = await this.manifest(resolvedRoot, selected.name, resolvedRoot);
|
|
@@ -1747,12 +1748,7 @@ var init_BannerPatterns = __esm({
|
|
|
1747
1748
|
static async getLayers(value, target, root) {
|
|
1748
1749
|
if (value === void 0) return [];
|
|
1749
1750
|
if (!Array.isArray(value)) throw new Error("banner_patterns must be an array");
|
|
1750
|
-
const activeRoot = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
1751
|
-
const checkSources = () => {
|
|
1752
|
-
if (activeRoot !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading banner patterns; retry the request");
|
|
1753
|
-
};
|
|
1754
1751
|
const colors = value.length ? await this.getColors(root) : void 0;
|
|
1755
|
-
checkSources();
|
|
1756
1752
|
return Promise.all(value.slice(0, 16).map(async (layer) => {
|
|
1757
1753
|
if (!layer || typeof layer !== "object" || Array.isArray(layer)) throw new Error("Each banner pattern requires a pattern and dye color");
|
|
1758
1754
|
if (typeof layer.color !== "string" || !Object.prototype.hasOwnProperty.call(colors, layer.color)) throw new Error(`Unsupported dye color ${layer.color}`);
|
|
@@ -1762,7 +1758,6 @@ var init_BannerPatterns = __esm({
|
|
|
1762
1758
|
const id = this.identifier(pattern2);
|
|
1763
1759
|
const key = new AssetKey(id.namespace, id.getFullPath(), "banner_pattern", void 0, "data", ".json", root);
|
|
1764
1760
|
pattern2 = await Caching.bannerPatternCache.get(key.serialize(), () => AssetLoader.get(key, "json" /* JSON */));
|
|
1765
|
-
checkSources();
|
|
1766
1761
|
if (!pattern2) throw new Error(`Missing banner pattern ${layer.pattern}`);
|
|
1767
1762
|
}
|
|
1768
1763
|
if (!pattern2 || typeof pattern2 !== "object" || Array.isArray(pattern2) || typeof pattern2.translation_key !== "string") throw new Error("Banner patterns require asset_id and translation_key");
|
|
@@ -2047,30 +2042,24 @@ var init_Models = __esm({
|
|
|
2047
2042
|
}).then((r) => r?.files ?? []);
|
|
2048
2043
|
}
|
|
2049
2044
|
static async loadAndMerge(key, context = {}) {
|
|
2050
|
-
const checkSources = this.sourceCheck();
|
|
2051
2045
|
const model = key.type === "item" ? await this.getItemModel(key, context) : await this.getRaw(key);
|
|
2052
2046
|
if (!model) {
|
|
2053
2047
|
return void 0;
|
|
2054
2048
|
}
|
|
2055
2049
|
const merged = await ModelMerger.mergeWithParents(model);
|
|
2056
|
-
checkSources();
|
|
2057
2050
|
return merged;
|
|
2058
2051
|
}
|
|
2059
2052
|
static async getItemModel(key, context = {}) {
|
|
2060
|
-
const checkSources = this.sourceCheck();
|
|
2061
2053
|
const preview = this.snapshotContext(key, context);
|
|
2062
2054
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2063
|
-
checkSources();
|
|
2064
2055
|
return this.getPreparedItemModel(key, preview, dataKey);
|
|
2065
2056
|
}
|
|
2066
2057
|
static async getPreparedItemModel(key, preview, dataKey) {
|
|
2067
|
-
const checkSources = this.sourceCheck();
|
|
2068
2058
|
const itemId = `${key.namespace}:${key.path}`;
|
|
2069
2059
|
const itemKey2 = new AssetKey(key.namespace, key.path, "items", void 0, key.rootType, ".json", key.root);
|
|
2070
2060
|
const cacheKey = itemKey2.serialize() + this.contextKey(preview) + dataKey;
|
|
2071
2061
|
const model = await this.PERSISTENT_CACHE.getOrLoad(`${this.ITEM_CACHE_VERSION}:${AssetLoader.persistentKey(cacheKey)}`, async () => {
|
|
2072
2062
|
const result = await AssetLoader.getFirst([itemKey2, key], "json" /* JSON */);
|
|
2073
|
-
checkSources();
|
|
2074
2063
|
if (!result) return void 0;
|
|
2075
2064
|
if (result.key.assetType !== "items") return { ...result.asset, key, itemId, components: preview.components };
|
|
2076
2065
|
const load = async (selected) => {
|
|
@@ -2089,10 +2078,8 @@ var init_Models = __esm({
|
|
|
2089
2078
|
return { ...model3, itemId, components: preview.components, ...selected.special && { special: selected.special }, ...selected.tints && { tints: selected.tints } };
|
|
2090
2079
|
};
|
|
2091
2080
|
const model2 = await load(this.selectItemModel(result.asset.model, key, preview));
|
|
2092
|
-
checkSources();
|
|
2093
2081
|
return model2;
|
|
2094
2082
|
});
|
|
2095
|
-
checkSources();
|
|
2096
2083
|
const restore = (model2) => ({
|
|
2097
2084
|
...model2,
|
|
2098
2085
|
key: Object.assign(new AssetKey("", ""), model2.key),
|
|
@@ -2156,22 +2143,14 @@ var init_Models = __esm({
|
|
|
2156
2143
|
}
|
|
2157
2144
|
static async applyDefaults(key, preview) {
|
|
2158
2145
|
if (key.type !== "item") return "";
|
|
2159
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2160
2146
|
const resolved = await MineRenderData.resolve(key.root);
|
|
2161
2147
|
const defaults = await ItemDefaults.get(`${key.namespace}:${key.path}`, key.root);
|
|
2162
2148
|
preview.components = { ...defaults, ...preview.components };
|
|
2163
2149
|
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)) {
|
|
2164
2150
|
preview.components["minecraft:enchantment_glint_override"] = true;
|
|
2165
2151
|
}
|
|
2166
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item defaults; retry the request");
|
|
2167
2152
|
return `|data:${resolved.root}:${resolved.manifest.datasets.itemDefaults?.sha256}:${resolved.manifest.datasets.potionColors?.sha256}`;
|
|
2168
2153
|
}
|
|
2169
|
-
static sourceCheck() {
|
|
2170
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
2171
|
-
return () => {
|
|
2172
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) throw new Error("Asset sources changed while loading item models; retry the request");
|
|
2173
|
-
};
|
|
2174
|
-
}
|
|
2175
2154
|
static contextKey(context) {
|
|
2176
2155
|
const itemReferences = Object.fromEntries(Object.entries(context.itemReferences).map(([id, key]) => [id, key.serialize()]));
|
|
2177
2156
|
return `|${this.ITEM_CACHE_VERSION}:${JSON.stringify(this.snapshotJson({ ...context, itemReferences }))}`;
|
|
@@ -2358,7 +2337,6 @@ var init_Models = __esm({
|
|
|
2358
2337
|
* @param key - Model key, for example `AssetKey.parse("models", "minecraft:item/diamond_sword")`.
|
|
2359
2338
|
*/
|
|
2360
2339
|
static async getMerged(key, context = {}) {
|
|
2361
|
-
const checkSources = this.sourceCheck();
|
|
2362
2340
|
if (!key.assetType) {
|
|
2363
2341
|
key.assetType = "models";
|
|
2364
2342
|
}
|
|
@@ -2367,15 +2345,12 @@ var init_Models = __esm({
|
|
|
2367
2345
|
}
|
|
2368
2346
|
const preview = this.snapshotContext(key, context);
|
|
2369
2347
|
const dataKey = await this.applyDefaults(key, preview);
|
|
2370
|
-
checkSources();
|
|
2371
2348
|
const keyStr = AssetLoader.persistentKey(key.serialize() + (key.type === "item" ? this.contextKey(preview) + dataKey : ""));
|
|
2372
2349
|
const model = await Caching.mergedModelCache.get(keyStr, async () => {
|
|
2373
2350
|
const raw = key.type === "item" ? await this.getPreparedItemModel(key, preview, dataKey) : await this.getRaw(key);
|
|
2374
2351
|
const merged = raw ? await ModelMerger.mergeWithParents(raw) : void 0;
|
|
2375
|
-
checkSources();
|
|
2376
2352
|
return merged;
|
|
2377
2353
|
});
|
|
2378
|
-
checkSources();
|
|
2379
2354
|
return model;
|
|
2380
2355
|
}
|
|
2381
2356
|
/** Alias for {@link getMerged}. */
|
|
@@ -12365,7 +12340,6 @@ import { Euler as Euler10, Matrix4 as Matrix411, Quaternion as Quaternion5, Vect
|
|
|
12365
12340
|
init_ModelCulling();
|
|
12366
12341
|
init_FluidGeometry();
|
|
12367
12342
|
init_MineRenderData();
|
|
12368
|
-
init_AssetLoader();
|
|
12369
12343
|
init_Entities();
|
|
12370
12344
|
var _BlockObject = class _BlockObject extends SceneObject {
|
|
12371
12345
|
constructor(blockState3, options) {
|
|
@@ -12390,19 +12364,12 @@ var _BlockObject = class _BlockObject extends SceneObject {
|
|
|
12390
12364
|
this.biomePosition = options?.biomePosition ? [...options.biomePosition] : void 0;
|
|
12391
12365
|
}
|
|
12392
12366
|
async init() {
|
|
12393
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
12394
|
-
const checkSources = () => {
|
|
12395
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading a block; retry the request");
|
|
12396
|
-
};
|
|
12397
12367
|
this._fluidRules = await MineRenderData.get("fluids", this.blockState.key?.root);
|
|
12398
|
-
checkSources();
|
|
12399
12368
|
if (this.options.applyDefaultState) {
|
|
12400
12369
|
this._setState(await BlockStateResolver.defaults(this.blockState));
|
|
12401
|
-
checkSources();
|
|
12402
12370
|
}
|
|
12403
12371
|
if (this.options.initialState !== void 0) this._setState(this.options.initialState);
|
|
12404
12372
|
await this.recreateModels();
|
|
12405
|
-
checkSources();
|
|
12406
12373
|
}
|
|
12407
12374
|
dispose() {
|
|
12408
12375
|
this.clearModels();
|
|
@@ -16325,7 +16292,6 @@ init_util2();
|
|
|
16325
16292
|
// src/world/AnvilParser.ts
|
|
16326
16293
|
init_MineRenderError();
|
|
16327
16294
|
init_MineRenderData();
|
|
16328
|
-
init_AssetLoader();
|
|
16329
16295
|
init_NBTHelper();
|
|
16330
16296
|
|
|
16331
16297
|
// src/world/ChunkData.ts
|
|
@@ -16596,14 +16562,12 @@ var AnvilParser = class {
|
|
|
16596
16562
|
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
16597
16563
|
static async parse(data, options = {}) {
|
|
16598
16564
|
options = { ...options };
|
|
16599
|
-
const checkSources = this.assetGuard();
|
|
16600
16565
|
options.signal?.throwIfAborted();
|
|
16601
16566
|
const bytes = this.bytes(data);
|
|
16602
16567
|
const chunks = [];
|
|
16603
16568
|
for (const location of this.locations(bytes)) {
|
|
16604
16569
|
chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
|
|
16605
16570
|
}
|
|
16606
|
-
checkSources();
|
|
16607
16571
|
return { chunks };
|
|
16608
16572
|
}
|
|
16609
16573
|
/**
|
|
@@ -16614,22 +16578,12 @@ var AnvilParser = class {
|
|
|
16614
16578
|
*/
|
|
16615
16579
|
static async parseChunk(data, localX, localZ, options = {}) {
|
|
16616
16580
|
options = { ...options };
|
|
16617
|
-
const checkSources = this.assetGuard();
|
|
16618
16581
|
options.signal?.throwIfAborted();
|
|
16619
16582
|
const bytes = this.bytes(data);
|
|
16620
16583
|
const location = this.location(bytes, localX, localZ);
|
|
16621
16584
|
const chunk = location ? await this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
|
|
16622
|
-
checkSources();
|
|
16623
16585
|
return chunk;
|
|
16624
16586
|
}
|
|
16625
|
-
static assetGuard() {
|
|
16626
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
16627
|
-
return () => {
|
|
16628
|
-
if (AssetLoader.ROOT !== root || AssetLoader.persistentScope !== scope) {
|
|
16629
|
-
throw new MineRenderError("Asset sources changed while parsing Anvil data; retry the request");
|
|
16630
|
-
}
|
|
16631
|
-
};
|
|
16632
|
-
}
|
|
16633
16587
|
/**
|
|
16634
16588
|
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
16635
16589
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
@@ -17350,7 +17304,6 @@ function resolveSavedEntity(entity) {
|
|
|
17350
17304
|
|
|
17351
17305
|
// src/world/_entities/WorldEntities.ts
|
|
17352
17306
|
init_BannerPatterns();
|
|
17353
|
-
init_AssetLoader();
|
|
17354
17307
|
var WorldEntities = class {
|
|
17355
17308
|
constructor(scene) {
|
|
17356
17309
|
this.scene = scene;
|
|
@@ -17358,10 +17311,6 @@ var WorldEntities = class {
|
|
|
17358
17311
|
}
|
|
17359
17312
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
17360
17313
|
prepare(entities = [], column) {
|
|
17361
|
-
const root = AssetLoader.ROOT, scope = AssetLoader.persistentScope;
|
|
17362
|
-
const checkSources = () => {
|
|
17363
|
-
if (root !== AssetLoader.ROOT || scope !== AssetLoader.persistentScope) throw new Error("Asset sources changed while loading saved entities; retry the request");
|
|
17364
|
-
};
|
|
17365
17314
|
const placements = entities.flatMap((entity) => {
|
|
17366
17315
|
const resolved = resolveSavedEntity(entity);
|
|
17367
17316
|
if (!resolved) return [];
|
|
@@ -17377,17 +17326,13 @@ var WorldEntities = class {
|
|
|
17377
17326
|
let object4;
|
|
17378
17327
|
try {
|
|
17379
17328
|
if (!current()) return;
|
|
17380
|
-
checkSources();
|
|
17381
17329
|
const models = await Entities.getEntityList();
|
|
17382
|
-
checkSources();
|
|
17383
17330
|
if (!models.includes(placement.key.path) || !current()) return;
|
|
17384
17331
|
const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
|
|
17385
|
-
checkSources();
|
|
17386
17332
|
if (!model || !current()) return;
|
|
17387
17333
|
let tints = placement.tints;
|
|
17388
17334
|
if (placement.woolDye) {
|
|
17389
17335
|
const dye = (await BannerPatterns.getColors(placement.key.root))[placement.woolDye];
|
|
17390
|
-
checkSources();
|
|
17391
17336
|
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);
|
|
17392
17337
|
tints = { ...tints, wool_color: tint };
|
|
17393
17338
|
}
|
|
@@ -17397,7 +17342,6 @@ var WorldEntities = class {
|
|
|
17397
17342
|
object4.position.fromArray(placement.position).multiplyScalar(16).addScalar(-8);
|
|
17398
17343
|
object4.rotation.y = placement.yaw;
|
|
17399
17344
|
await object4.init();
|
|
17400
|
-
checkSources();
|
|
17401
17345
|
if (!current()) return;
|
|
17402
17346
|
placement.owner.add(object4);
|
|
17403
17347
|
this.scene.add(object4);
|