Skip to content

AssetDirector

makamys edited this page Apr 19, 2023 · 8 revisions

AssetDirector is a library module that can be used to download Mojang's assets and Minecraft jars directly off their servers, allowing use and redistribution of things like sounds without EULA worries. It was created to let mods like Et Futurum Requiem use assets from other versions of the game without having to embed them in the jar, saving bandwidth and storage space.

Directory

By default, AssetDirector will create an asset_director directory inside the assets directory of your launcher, and use it for storage. This can be overridden by setting the minecraft.sharedDataDir JVM flag or the MINECRAFT_SHARED_DATA_DIR environmental variable.

To be exact, AssetDirector will use the first directory matched in this list:

  • <minecraft.sharedDataDir>/asset_director, if the minecraft.sharedDataDir JVM argument is set.
  • $MINECRAFT_SHARED_DATA_DIR/asset_director, if the MINECRAFT_SHARED_DATA_DIR environmental variable is set.
  • <launcher's assets dir>/../asset_director if the legacy launcher is used. (This is a workaround for it deleting extra files from the assets directory.)
  • Otherwise, <launcher's assets dir>/asset_director is used.

The directory used will be printed in the log during startup.

Example

With the official launcher:

[19:52:19] [Client thread/INFO] [AssetDirector/]: Using directory C:\Users\(You)\AppData\Roaming\.minecraft\assets\asset_director

Connection

There are two domains AssetDirector will connect to:

  • launchermeta.mojang.com
  • resources.download.minecraft.net

Make sure there's nothing blocking access to these domains (like a firewall or the NonUpdate mod).

Overlay

AssetDirector's assets/objects directory is overlaid on top of the launcher's assets/objects directory. This means if an object can already be found in the launcher's assets/objects directory, that copy will be used instead of downloading it again. AssetDirector will never write into the launcher's assets/objects directory, as this can cause issues with some launchers.

Overlaying is not implemented for the manifest JSONs and the version jars, since the location of these is launcher-specific - AssetDirector will always download its own copy for these.

JVM Flags

  • -DassetDirector.dumpSoundsJson=true: dump the dynamically generated sounds.json files to .minecraft/asset_director/out/sounds-<version>.json
    • Useful for people creating resource packs.

Known issues

  • TLauncher deletes AssetDirector's directory on every launch, causing assets to get redownloaded every time. As a workaround, use a different launcher or change the directory location (see the Directory section above).
  • Old versions of Java may not compatible, because they do not support the SSL cipher used by Mojang's resource server. For Java 1.8.0_51, a special compatibility hack is applied.

Developer usage

Asset downloading commands from AssetDirector are exposed through AssetDirectorAPI. Create a new ADConfig instance in your mod's FMLConstructionEvent, and use addObject, addSoundEvent etc. to request the assets you require. This ADConfig is initialized through the use of AssetDirectorAPI.register(configVar).

Clone this wiki locally