fix minecraft assets downloading

This commit is contained in:
Bixilon 2021-04-07 00:09:26 +02:00
parent e72aab9f74
commit cfd492eee4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -46,7 +46,7 @@ class MinecraftAssetsManager(
if (!verifyAssetHash(assetVersion.indexHash!!)) { if (!verifyAssetHash(assetVersion.indexHash!!)) {
downloadAssetsIndex() downloadAssetsIndex()
} }
this.assetsMapping.putAll(verifyAssets(AssetsSource.MOJANG, latch!!, parseAssetsIndex(assetVersion.indexHash))) this.assetsMapping.putAll(verifyAssets(AssetsSource.MINECRAFT, latch, parseAssetsIndex(assetVersion.indexHash)))
// generate jar assets index // generate jar assets index
generateJarAssets() generateJarAssets()
@ -132,19 +132,19 @@ class MinecraftAssetsManager(
} }
} }
private fun verifyAssets(source: AssetsSource, latch: CountUpAndDownLatch, assets: Map<ResourceLocation, String>): Map<ResourceLocation, String> { private fun verifyAssets(source: AssetsSource, latch: CountUpAndDownLatch?, assets: Map<ResourceLocation, String>): Map<ResourceLocation, String> {
val assetsLatch = CountUpAndDownLatch(assets.size) val assetsLatch = CountUpAndDownLatch(assets.size)
latch.addCount(assets.size) latch?.addCount(assets.size)
for (hash in assets.values) { for (hash in assets.values) {
Minosoft.THREAD_POOL.execute { Minosoft.THREAD_POOL.execute {
val compressed = source == AssetsSource.MOJANG val compressed = source != AssetsSource.PIXLYZER
if (StaticConfiguration.DEBUG_SLOW_LOADING) { if (StaticConfiguration.DEBUG_SLOW_LOADING) {
Thread.sleep(100L) Thread.sleep(100L)
} }
if (!verifyAssetHash(hash, compressed)) { if (!verifyAssetHash(hash, compressed)) {
downloadAsset(source, hash) downloadAsset(source, hash)
} }
latch.countDown() latch?.countDown()
assetsLatch.countDown() assetsLatch.countDown()
} }
} }