minerender 2.1.0-alpha.22 → 2.1.0-alpha.23

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.
@@ -668,6 +668,8 @@ declare class AssetLoadError extends Error {
668
668
  declare class AssetLoader {
669
669
  static ROOT: string;
670
670
  private static _SOURCES;
671
+ static get version(): string;
672
+ static setVersion(version: string): void;
671
673
  static addSource(key: string, source: AssetSource, override?: boolean): void;
672
674
  static removeSource(key: string): Maybe<AssetSource>;
673
675
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
@@ -668,6 +668,8 @@ declare class AssetLoadError extends Error {
668
668
  declare class AssetLoader {
669
669
  static ROOT: string;
670
670
  private static _SOURCES;
671
+ static get version(): string;
672
+ static setVersion(version: string): void;
671
673
  static addSource(key: string, source: AssetSource, override?: boolean): void;
672
674
  static removeSource(key: string): Maybe<AssetSource>;
673
675
  static getAll<T extends MinecraftAsset>(key: AssetKey, parser: AssetParser | string): Promise<T[]>;
@@ -1562,7 +1562,7 @@ var BlockStates = class {
1562
1562
  void 0,
1563
1563
  "assets",
1564
1564
  ".json",
1565
- DEFAULT_ROOT
1565
+ AssetLoader.ROOT
1566
1566
  );
1567
1567
  return Caching.listAssetCache.get(key.serialize(), () => {
1568
1568
  return AssetLoader.get(key, "list" /* LIST */);
@@ -1879,17 +1879,17 @@ var HostedAssetSource = class _HostedAssetSource extends AssetSource {
1879
1879
  if (typeof namespaced !== "undefined") {
1880
1880
  return namespaced;
1881
1881
  }
1882
- if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
1882
+ if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1883
1883
  console.info(p3, "Retrying", key, "with default root+namespace");
1884
- const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
1884
+ const namespacedRootedKey = new AssetKey(DEFAULT_NAMESPACE, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1885
1885
  const namespacedRooted = await this.load(namespacedRootedKey, parser);
1886
1886
  if (typeof namespacedRooted !== "undefined") {
1887
1887
  return namespacedRooted;
1888
1888
  }
1889
1889
  }
1890
- } else if (typeof key.root !== "undefined" && key.root !== DEFAULT_ROOT || typeof this.root !== "undefined" && this.root !== DEFAULT_ROOT) {
1890
+ } else if (typeof key.root !== "undefined" && key.root !== AssetLoader.ROOT || typeof this.root !== "undefined" && this.root !== AssetLoader.ROOT) {
1891
1891
  console.info(p3, "Retrying", key, "with default root");
1892
- const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, DEFAULT_ROOT);
1892
+ const rootKey = new AssetKey(key.namespace, key.path, key.assetType, key.type, key.rootType, key.extension, AssetLoader.ROOT);
1893
1893
  const rooted = await this.load(rootKey, parser);
1894
1894
  if (typeof rooted !== "undefined") {
1895
1895
  return rooted;
@@ -2023,6 +2023,20 @@ var AssetLoader = class {
2023
2023
  static {
2024
2024
  this._SOURCES = [];
2025
2025
  }
2026
+ static get version() {
2027
+ return this.ROOT.substring(this.ROOT.lastIndexOf("/") + 1);
2028
+ }
2029
+ static setVersion(version) {
2030
+ this.ROOT = `https://assets.mcasset.cloud/${version}`;
2031
+ const source = new HostedAssetSource(this.ROOT, { retryDefaults: false });
2032
+ const index = this._SOURCES.findIndex((s) => s.key === "mcassets");
2033
+ if (index !== -1) {
2034
+ this._SOURCES[index] = { key: "mcassets", source };
2035
+ } else {
2036
+ this.addSource("mcassets", source);
2037
+ }
2038
+ Caching.clear();
2039
+ }
2026
2040
  static addSource(key, source, override = true) {
2027
2041
  if (override) {
2028
2042
  const existing = this.removeSource(key);
@@ -2045,7 +2059,7 @@ var AssetLoader = class {
2045
2059
  }
2046
2060
  static {
2047
2061
  this.addSource("mcassets-fallback", new HostedAssetSource("https://raw.githubusercontent.com/InventivetalentDev/minerender-fallback-assets/master", { retryDefaults: false }));
2048
- this.addSource("mcassets", new HostedAssetSource(DEFAULT_ROOT, { retryDefaults: false }));
2062
+ this.addSource("mcassets", new HostedAssetSource(this.ROOT, { retryDefaults: false }));
2049
2063
  }
2050
2064
  static async getAll(key, parser) {
2051
2065
  let promises = [];