Events/Launch/minified-launch
DownloadAssetsEvent
Gets fired every time a new asset file has been downloaded
Fields
progressdoubleThe overall download progress as a value from 0.0 to 1.0
downloadedByteslongThe total number of bytes downloaded so far
totalByteslongThe total size of all assets in bytes
currentFileStringThe name or path of the asset currently being downloaded
currentFileByteslongThe number of bytes downloaded for the current file
currentFileSizelongThe total size of the current file in bytes
When it fires
AssetDownloader downloads assets across a worker pool sized by LaunchConfiguration.downloadThreads (5 by default), so this event fires concurrently from multiple threads - one post per finished file, plus one final call once every future in the pool has completed to guarantee a progress: 1.0 event even if the last file was tiny.
Because progress/downloadedBytes/totalBytes describe the overall asset download (not just currentFile), don't assume events arrive in a strict order by file - two threads can post around the same time with currentFile referring to whichever file each thread just finished. If you're rendering a single progress bar, key off progress; if you want a live "currently downloading" list, track currentFile per listener call rather than assuming monotonic ordering.
This event is only posted when a non-null LaunchContext is available, which is always the case when assets are downloaded as part of Launcher.launchMinecraft(...).
Listening
Subscribe on the EventBus the event is posted to, see Events for which bus that is.
eventBus.subscribe(DownloadAssetsEvent.class, event -> {
double progress = event.progress();
long downloadedBytes = event.downloadedBytes();
long totalBytes = event.totalBytes();
String currentFile = event.currentFile();
long currentFileBytes = event.currentFileBytes();
long currentFileSize = event.currentFileSize();
});eventBus.subscribe(DownloadAssetsEvent::class.java) { event ->
val progress = event.progress()
val downloadedBytes = event.downloadedBytes()
val totalBytes = event.totalBytes()
val currentFile = event.currentFile()
val currentFileBytes = event.currentFileBytes()
val currentFileSize = event.currentFileSize()
}Posted by
API reference: com.dervarex.minified.launch.events.download.assets.DownloadAssetsEvent