Skip to content

Commit f87e807

Browse files
committed
🛠️ Possible fix for infinite loading
1 parent d977143 commit f87e807

File tree

3 files changed

+53
-26
lines changed

3 files changed

+53
-26
lines changed

src/index.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,7 @@ import { BLOCKSTATE_REGISTRY } from './systems/minecraft/blockstateManager'
4646
import { exportProject } from './systems/exporter'
4747
import { openBlueprintLoadingDialog } from './interface/blueprintLoadingPopup'
4848
import { openInstallPopup } from './interface/installedPopup'
49-
50-
// Show loading popup
51-
void showLoadingPopup().then(async () => {
52-
if (!window.navigator.onLine) {
53-
showOfflineError()
54-
// return
55-
}
56-
events.NETWORK_CONNECTED.dispatch()
57-
58-
await Promise.all([
59-
new Promise<void>(resolve => events.MINECRAFT_ASSETS_LOADED.subscribe(() => resolve())),
60-
new Promise<void>(resolve => events.MINECRAFT_REGISTRY_LOADED.subscribe(() => resolve())),
61-
new Promise<void>(resolve => events.MINECRAFT_FONTS_LOADED.subscribe(() => resolve())),
62-
new Promise<void>(resolve => events.BLOCKSTATE_REGISTRY_LOADED.subscribe(() => resolve())),
63-
])
64-
.then(() => {
65-
hideLoadingPopup()
66-
})
67-
.catch(error => {
68-
console.error(error)
69-
Blockbench.showToastNotification({
70-
text: 'Animated Java failed to load! Please restart Blockbench',
71-
color: 'var(--color-error)',
72-
})
73-
})
74-
})
49+
import { createBlockbenchMod } from './util/moddingTools'
7550

7651
// @ts-ignore
7752
globalThis.AnimatedJava = {

src/mods/assetSetupMod.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { PACKAGE } from '../constants'
2+
import {
3+
hideLoadingPopup,
4+
showLoadingPopup,
5+
showOfflineError,
6+
} from '../interface/animatedJavaLoadingPopup'
7+
import { events } from '../util/events'
8+
import { createBlockbenchMod } from '../util/moddingTools'
9+
10+
createBlockbenchMod(
11+
`${PACKAGE.name}:assetLoading`,
12+
undefined,
13+
() => {
14+
// Show loading popup
15+
void showLoadingPopup().then(async () => {
16+
if (!window.navigator.onLine) {
17+
showOfflineError()
18+
// return
19+
}
20+
events.NETWORK_CONNECTED.dispatch()
21+
22+
await Promise.all([
23+
new Promise<void>(resolve =>
24+
events.MINECRAFT_ASSETS_LOADED.subscribe(() => resolve())
25+
),
26+
new Promise<void>(resolve =>
27+
events.MINECRAFT_REGISTRY_LOADED.subscribe(() => resolve())
28+
),
29+
new Promise<void>(resolve =>
30+
events.MINECRAFT_FONTS_LOADED.subscribe(() => resolve())
31+
),
32+
new Promise<void>(resolve =>
33+
events.BLOCKSTATE_REGISTRY_LOADED.subscribe(() => resolve())
34+
),
35+
])
36+
.then(() => {
37+
hideLoadingPopup()
38+
})
39+
.catch(error => {
40+
console.error(error)
41+
Blockbench.showToastNotification({
42+
text: 'Animated Java failed to load! Please restart Blockbench',
43+
color: 'var(--color-error)',
44+
})
45+
})
46+
})
47+
},
48+
() => {
49+
//
50+
}
51+
)

src/mods/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './assetSetupMod'
12
import './addLocatorActionMod'
23
import './animationControllerMod'
34
import './animationPropertiesAction'

0 commit comments

Comments
 (0)