minerender 2.1.0-alpha.116 → 2.1.0-alpha.118
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 +14 -5
- package/dist/browser/index.d.ts +14 -5
- package/dist/browser/index.js +50 -69
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +50 -69
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +50 -69
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +14 -5
- package/dist/node/index.d.ts +14 -5
- package/dist/node/index.js +50 -69
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +50 -69
- 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();
|
|
@@ -13309,6 +13276,8 @@ import { Controls, Euler as Euler11, MathUtils as MathUtils2, Quaternion as Quat
|
|
|
13309
13276
|
var VANILLA_FLY_SPEED = 10.89;
|
|
13310
13277
|
var PITCH_LIMIT = Math.PI / 2;
|
|
13311
13278
|
var MOVE_EPSILON = 1e-6;
|
|
13279
|
+
var MAX_STEP_SECONDS = 0.1;
|
|
13280
|
+
var CLICK_SLOP_PIXELS = 4;
|
|
13312
13281
|
var _euler = new Euler11(0, 0, 0, "YXZ");
|
|
13313
13282
|
var _forward = new Vector313();
|
|
13314
13283
|
var _right = new Vector313();
|
|
@@ -13343,7 +13312,8 @@ var FlyControls = class extends Controls {
|
|
|
13343
13312
|
right: ["KeyD", "ArrowRight"],
|
|
13344
13313
|
up: ["Space"],
|
|
13345
13314
|
down: ["ShiftLeft", "ShiftRight"],
|
|
13346
|
-
|
|
13315
|
+
// Not Control: Ctrl+W closes the browser tab on Windows and Linux, and a page cannot block it.
|
|
13316
|
+
sprint: ["KeyR"]
|
|
13347
13317
|
};
|
|
13348
13318
|
this._pressed = /* @__PURE__ */ new Set();
|
|
13349
13319
|
this._velocity = new Vector313();
|
|
@@ -13351,8 +13321,12 @@ var FlyControls = class extends Controls {
|
|
|
13351
13321
|
this._lastQuaternion = new Quaternion6();
|
|
13352
13322
|
this._position0 = new Vector313();
|
|
13353
13323
|
this._quaternion0 = new Quaternion6();
|
|
13324
|
+
this._dragX = 0;
|
|
13325
|
+
this._dragY = 0;
|
|
13354
13326
|
this._dragMoved = false;
|
|
13327
|
+
this._dragTravel = 0;
|
|
13355
13328
|
this._locked = false;
|
|
13329
|
+
this._madeFocusable = false;
|
|
13356
13330
|
this._onKeyDown = (event) => this.handleKey(event, true);
|
|
13357
13331
|
this._onKeyUp = (event) => this.handleKey(event, false);
|
|
13358
13332
|
this._onPointerDown = (event) => this.handlePointerDown(event);
|
|
@@ -13382,7 +13356,10 @@ var FlyControls = class extends Controls {
|
|
|
13382
13356
|
element.addEventListener("wheel", this._onWheel, { passive: false });
|
|
13383
13357
|
element.addEventListener("blur", this._onBlur);
|
|
13384
13358
|
element.style.touchAction = "none";
|
|
13385
|
-
if (element.tabIndex < 0)
|
|
13359
|
+
if (element.tabIndex < 0) {
|
|
13360
|
+
element.tabIndex = 0;
|
|
13361
|
+
this._madeFocusable = true;
|
|
13362
|
+
}
|
|
13386
13363
|
}
|
|
13387
13364
|
disconnect() {
|
|
13388
13365
|
const element = this.domElement;
|
|
@@ -13400,6 +13377,10 @@ var FlyControls = class extends Controls {
|
|
|
13400
13377
|
element.removeEventListener("wheel", this._onWheel);
|
|
13401
13378
|
element.removeEventListener("blur", this._onBlur);
|
|
13402
13379
|
element.style.touchAction = "auto";
|
|
13380
|
+
if (this._madeFocusable) {
|
|
13381
|
+
element.removeAttribute("tabindex");
|
|
13382
|
+
this._madeFocusable = false;
|
|
13383
|
+
}
|
|
13403
13384
|
this.unlock();
|
|
13404
13385
|
this._locked = false;
|
|
13405
13386
|
this.releaseKeys();
|
|
@@ -13470,6 +13451,7 @@ var FlyControls = class extends Controls {
|
|
|
13470
13451
|
/**
|
|
13471
13452
|
* Advances movement by `delta` seconds (measured since the previous call when omitted)
|
|
13472
13453
|
* and dispatches `change` when the camera moved.
|
|
13454
|
+
* A step longer than 0.1 s is applied as 0.1 s.
|
|
13473
13455
|
*/
|
|
13474
13456
|
update(delta) {
|
|
13475
13457
|
if (delta === void 0) {
|
|
@@ -13481,7 +13463,7 @@ var FlyControls = class extends Controls {
|
|
|
13481
13463
|
this._velocity.set(0, 0, 0);
|
|
13482
13464
|
return;
|
|
13483
13465
|
}
|
|
13484
|
-
if (delta > 0) this.move(delta);
|
|
13466
|
+
if (delta > 0) this.move(Math.min(delta, MAX_STEP_SECONDS));
|
|
13485
13467
|
this.notifyChange();
|
|
13486
13468
|
}
|
|
13487
13469
|
move(delta) {
|
|
@@ -13528,15 +13510,21 @@ var FlyControls = class extends Controls {
|
|
|
13528
13510
|
this._pressed.clear();
|
|
13529
13511
|
}
|
|
13530
13512
|
handleKey(event, down) {
|
|
13513
|
+
if (event.code === "MetaLeft" || event.code === "MetaRight") this.releaseKeys();
|
|
13531
13514
|
const action = this.actionFor(event.code);
|
|
13532
13515
|
if (!action) return;
|
|
13533
13516
|
const ownsInput = this.enabled && (this._locked || event.target === this.domElement);
|
|
13534
|
-
if (down && !ownsInput) return;
|
|
13517
|
+
if (down && (!ownsInput || this.isBrowserShortcut(event))) return;
|
|
13535
13518
|
const pressed = this._pressed.has(action);
|
|
13536
13519
|
if (down) this._pressed.add(action);
|
|
13537
13520
|
else this._pressed.delete(action);
|
|
13538
13521
|
if (ownsInput || this.enabled && pressed) event.preventDefault();
|
|
13539
13522
|
}
|
|
13523
|
+
/** A key pressed with Control, Alt, or Command stays a browser shortcut unless that modifier is bound to an action. */
|
|
13524
|
+
isBrowserShortcut(event) {
|
|
13525
|
+
const bound = (modifier) => Object.values(this.keys).some((codes) => codes.some((code) => code.startsWith(modifier)));
|
|
13526
|
+
return event.ctrlKey && !bound("Control") || event.altKey && !bound("Alt") || event.metaKey && !bound("Meta");
|
|
13527
|
+
}
|
|
13540
13528
|
actionFor(code) {
|
|
13541
13529
|
for (const action in this.keys) {
|
|
13542
13530
|
if (this.keys[action].includes(code)) return action;
|
|
@@ -13556,7 +13544,10 @@ var FlyControls = class extends Controls {
|
|
|
13556
13544
|
if (this._dragPointer !== void 0) return;
|
|
13557
13545
|
if (event.pointerType === "mouse" && event.button !== 0 && event.button !== 2) return;
|
|
13558
13546
|
this._dragPointer = event.pointerId;
|
|
13547
|
+
this._dragX = event.clientX;
|
|
13548
|
+
this._dragY = event.clientY;
|
|
13559
13549
|
this._dragMoved = false;
|
|
13550
|
+
this._dragTravel = 0;
|
|
13560
13551
|
element.setPointerCapture?.(event.pointerId);
|
|
13561
13552
|
}
|
|
13562
13553
|
onJoystickSide(event) {
|
|
@@ -13572,8 +13563,20 @@ var FlyControls = class extends Controls {
|
|
|
13572
13563
|
return;
|
|
13573
13564
|
}
|
|
13574
13565
|
if (!this._locked && event.pointerId !== this._dragPointer) return;
|
|
13575
|
-
|
|
13576
|
-
|
|
13566
|
+
let dx, dy;
|
|
13567
|
+
if (this._locked) {
|
|
13568
|
+
dx = event.movementX ?? 0;
|
|
13569
|
+
dy = event.movementY ?? 0;
|
|
13570
|
+
} else {
|
|
13571
|
+
dx = event.clientX - this._dragX;
|
|
13572
|
+
dy = event.clientY - this._dragY;
|
|
13573
|
+
this._dragX = event.clientX;
|
|
13574
|
+
this._dragY = event.clientY;
|
|
13575
|
+
if (!this._dragMoved) {
|
|
13576
|
+
this._dragTravel += Math.hypot(dx, dy);
|
|
13577
|
+
if (this._dragTravel <= CLICK_SLOP_PIXELS) return;
|
|
13578
|
+
}
|
|
13579
|
+
}
|
|
13577
13580
|
if (!dx && !dy) return;
|
|
13578
13581
|
this._dragMoved = true;
|
|
13579
13582
|
this.turn(dx, dy);
|
|
@@ -15533,6 +15536,7 @@ var Renderer = class _Renderer {
|
|
|
15533
15536
|
/**
|
|
15534
15537
|
* Replaces renderer-owned controls with the selected mode, keeping the camera where it is.
|
|
15535
15538
|
* Switching to orbit controls targets the point the camera looks at, at the previous orbit distance.
|
|
15539
|
+
* The previous controls object is disposed, so its listeners and settings do not carry over.
|
|
15536
15540
|
* Returns the new controls, or undefined when controls were disabled at construction or after disposal.
|
|
15537
15541
|
*/
|
|
15538
15542
|
setControlsMode(mode) {
|
|
@@ -16382,7 +16386,6 @@ init_util2();
|
|
|
16382
16386
|
// src/world/AnvilParser.ts
|
|
16383
16387
|
init_MineRenderError();
|
|
16384
16388
|
init_MineRenderData();
|
|
16385
|
-
init_AssetLoader();
|
|
16386
16389
|
init_NBTHelper();
|
|
16387
16390
|
|
|
16388
16391
|
// src/world/ChunkData.ts
|
|
@@ -16653,14 +16656,12 @@ var AnvilParser = class {
|
|
|
16653
16656
|
/** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
|
|
16654
16657
|
static async parse(data, options = {}) {
|
|
16655
16658
|
options = { ...options };
|
|
16656
|
-
const checkSources = this.assetGuard();
|
|
16657
16659
|
options.signal?.throwIfAborted();
|
|
16658
16660
|
const bytes = this.bytes(data);
|
|
16659
16661
|
const chunks = [];
|
|
16660
16662
|
for (const location of this.locations(bytes)) {
|
|
16661
16663
|
chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
|
|
16662
16664
|
}
|
|
16663
|
-
checkSources();
|
|
16664
16665
|
return { chunks };
|
|
16665
16666
|
}
|
|
16666
16667
|
/**
|
|
@@ -16671,22 +16672,12 @@ var AnvilParser = class {
|
|
|
16671
16672
|
*/
|
|
16672
16673
|
static async parseChunk(data, localX, localZ, options = {}) {
|
|
16673
16674
|
options = { ...options };
|
|
16674
|
-
const checkSources = this.assetGuard();
|
|
16675
16675
|
options.signal?.throwIfAborted();
|
|
16676
16676
|
const bytes = this.bytes(data);
|
|
16677
16677
|
const location = this.location(bytes, localX, localZ);
|
|
16678
16678
|
const chunk = location ? await this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
|
|
16679
|
-
checkSources();
|
|
16680
16679
|
return chunk;
|
|
16681
16680
|
}
|
|
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
16681
|
/**
|
|
16691
16682
|
* Decodes one chunk from an `entities/r.x.z.mca` file without migrating its NBT.
|
|
16692
16683
|
* @param localX - Chunk x within the region, from 0 to 31.
|
|
@@ -17407,7 +17398,6 @@ function resolveSavedEntity(entity) {
|
|
|
17407
17398
|
|
|
17408
17399
|
// src/world/_entities/WorldEntities.ts
|
|
17409
17400
|
init_BannerPatterns();
|
|
17410
|
-
init_AssetLoader();
|
|
17411
17401
|
var WorldEntities = class {
|
|
17412
17402
|
constructor(scene) {
|
|
17413
17403
|
this.scene = scene;
|
|
@@ -17415,10 +17405,6 @@ var WorldEntities = class {
|
|
|
17415
17405
|
}
|
|
17416
17406
|
/** Captures column ownership before asynchronous block or asset loading starts. */
|
|
17417
17407
|
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
17408
|
const placements = entities.flatMap((entity) => {
|
|
17423
17409
|
const resolved = resolveSavedEntity(entity);
|
|
17424
17410
|
if (!resolved) return [];
|
|
@@ -17434,17 +17420,13 @@ var WorldEntities = class {
|
|
|
17434
17420
|
let object4;
|
|
17435
17421
|
try {
|
|
17436
17422
|
if (!current()) return;
|
|
17437
|
-
checkSources();
|
|
17438
17423
|
const models = await Entities.getEntityList();
|
|
17439
|
-
checkSources();
|
|
17440
17424
|
if (!models.includes(placement.key.path) || !current()) return;
|
|
17441
17425
|
const model = await Entities.getEntity(placement.key, placement.texture, { when: placement.when });
|
|
17442
|
-
checkSources();
|
|
17443
17426
|
if (!model || !current()) return;
|
|
17444
17427
|
let tints = placement.tints;
|
|
17445
17428
|
if (placement.woolDye) {
|
|
17446
17429
|
const dye = (await BannerPatterns.getColors(placement.key.root))[placement.woolDye];
|
|
17447
|
-
checkSources();
|
|
17448
17430
|
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
17431
|
tints = { ...tints, wool_color: tint };
|
|
17450
17432
|
}
|
|
@@ -17454,7 +17436,6 @@ var WorldEntities = class {
|
|
|
17454
17436
|
object4.position.fromArray(placement.position).multiplyScalar(16).addScalar(-8);
|
|
17455
17437
|
object4.rotation.y = placement.yaw;
|
|
17456
17438
|
await object4.init();
|
|
17457
|
-
checkSources();
|
|
17458
17439
|
if (!current()) return;
|
|
17459
17440
|
placement.owner.add(object4);
|
|
17460
17441
|
this.scene.add(object4);
|