Skip to content

Commit bcbb6f8

Browse files
committed
🛠️ Fix broken asset download on first startup.
1 parent 9a3b525 commit bcbb6f8

File tree

5 files changed

+733
-31
lines changed

5 files changed

+733
-31
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"title": "Animated Java",
55
"icon": "icon.svg",
66
"description": "A Blockbench plugin that makes complex animation a breeze in Minecraft: Java Edition.",
7-
"version": "1.5.1",
8-
"display_version": "1.5.1",
7+
"version": "1.5.2",
8+
"display_version": "1.5.2",
99
"min_blockbench_version": "4.11.1",
1010
"variant": "desktop",
1111
"tags": [
@@ -82,6 +82,7 @@
8282
},
8383
"devDependencies": {
8484
"@novacbn/svelte-codejar": "^0.1.2",
85+
"@types/download": "^8.0.5",
8586
"@types/eslint": "^8.21.1",
8687
"@types/js-yaml": "^4.0.5",
8788
"@types/node": "^17.0.21",
@@ -105,7 +106,7 @@
105106
},
106107
"dependencies": {
107108
"deepslate": "^0.19.2",
108-
"easydl": "^1.2.0",
109+
"download": "^8.0.0",
109110
"fflate": "^0.8.2",
110111
"generic-stream": "^1.2.6",
111112
"marked": "^4.3.0",

src/systems/datapackCompiler/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ namespace TELLRAW {
146146
color: 'aqua',
147147
underlined: true,
148148
},
149-
// '\n',
150-
// TELLRAW_LEARN_MORE_LINK(''),
151149
TELLRAW_SUFFIX(),
152150
])
153151
export const RIG_OUTDATED_TEXT_DISPLAY = () =>

src/systems/minecraft/assetManager.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ import { events } from '../../util/events'
55
import index from '../../assets/vanillaAssetOverrides/index.json'
66
import { Unzipped } from 'fflate'
77
import { unzip } from '../util'
8-
import EasyDl from 'easydl'
8+
import download from 'download'
99
import {
10+
showOfflineError,
1011
updateLoadingProgress,
1112
updateLoadingProgressLabel,
1213
} from '../../interface/animatedJavaLoadingPopup'
1314
const ASSET_OVERRIDES = index as unknown as Record<string, string>
1415

1516
async function downloadJar(url: string, savePath: string) {
1617
updateLoadingProgressLabel('Downloading Minecraft Assets...')
17-
await new EasyDl(url, savePath, {
18-
existBehavior: 'overwrite',
19-
maxRetry: 3,
20-
reportInterval: 100,
21-
})
22-
.on('progress', progress => {
23-
updateLoadingProgress(progress.total.percentage)
18+
19+
const data = await download(url, { retry: { retries: 3 } })
20+
.on('downloadProgress', progress => {
21+
updateLoadingProgress(progress.percent * 100)
2422
})
25-
.on('error', error => {
23+
.catch((error: any) => {
2624
console.error('Failed to download Minecraft client:', error)
2725
})
28-
.on('end', () => {
29-
updateLoadingProgress(100)
30-
updateLoadingProgressLabel('')
31-
})
32-
.wait()
26+
27+
if (!data) {
28+
showOfflineError()
29+
throw new Error('Failed to download Minecraft client after 3 retries.')
30+
}
31+
32+
await fs.promises.writeFile(savePath, data)
3333
}
3434

3535
export async function getLatestVersionClientDownloadUrl() {
@@ -74,8 +74,6 @@ export async function updateAssets() {
7474

7575
export async function checkForAssetsUpdate() {
7676
console.log('Checking for Minecraft assets update...')
77-
// DEBUG
78-
// await updateAssets()
7977

8078
const currentVersion = getCurrentVersion()
8179
if (!currentVersion) {
@@ -95,6 +93,9 @@ export async function checkForAssetsUpdate() {
9593
await updateAssets()
9694
}
9795

96+
console.log('Does file exist?', fs.existsSync(cachedJarFilePath))
97+
console.log('Are assets loaded?', localStorage.getItem('assetsLoaded') === 'true')
98+
9899
await extractAssets()
99100
console.log('Minecraft assets are up to date!')
100101
localStorage.setItem('assetsLoaded', 'true')

tools/plugins/packagerPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function plugin(): Plugin {
5353
manifest.animated_java.icon = PACKAGE.icon
5454
manifest.animated_java.description = PACKAGE.description
5555
manifest.animated_java.version = PACKAGE.version
56-
manifest.animated_java.min_version = PACKAGE.min_version
56+
manifest.animated_java.min_version = PACKAGE.min_blockbench_version
5757
manifest.animated_java.variant = PACKAGE.variant
5858
manifest.animated_java.tags = PACKAGE.tags
5959

0 commit comments

Comments
 (0)