4
4
import dev .architectury .event .events .common .LifecycleEvent ;
5
5
import dev .architectury .platform .forge .EventBuses ;
6
6
import net .minecraft .resource .ResourcePackManager ;
7
- import net .minecraft .server .ServerTask ;
8
7
import net .minecraft .world .SaveProperties ;
9
8
import net .minecraftforge .api .distmarker .Dist ;
10
9
import net .minecraftforge .client .event .EntityRenderersEvent ;
16
15
import smartin .miapi .Miapi ;
17
16
import smartin .miapi .attributes .AttributeRegistry ;
18
17
import smartin .miapi .config .MiapiConfig ;
19
- import smartin .miapi .events . MiapiEvents ;
18
+ import smartin .miapi .datapack . ReloadEvents ;
20
19
import smartin .miapi .modules .properties .AttributeProperty ;
21
20
22
21
import java .util .Collection ;
22
+ import java .util .HashMap ;
23
23
import java .util .Iterator ;
24
+ import java .util .Map ;
24
25
25
26
import static smartin .miapi .Miapi .MOD_ID ;
26
27
import static smartin .miapi .attributes .AttributeRegistry .SWIM_SPEED ;
@@ -41,33 +42,16 @@ public TrulyModularForge() {
41
42
}));
42
43
LifecycleEvent .SERVER_STARTED .register ((minecraftServer -> {
43
44
if (!Environment .isClient () && MiapiConfig .OtherConfigGroup .forgeAutoReloads .getValue ()){
45
+ Map <String ,String > cacheDatapack = new HashMap <>(ReloadEvents .DATA_PACKS );
44
46
Miapi .LOGGER .info ("Truly Modular will now go onto reload twice." );
45
47
Miapi .LOGGER .info ("This is done because Forges classloading is buggy and stupid. Until we have a better fix, this is used" );
46
48
Miapi .LOGGER .info ("This can be turned off in Miapis config.json" );
47
- MiapiEvents .GENERATED_MATERIAL .hasBeenSorted ();
48
- minecraftServer .executeTask (new ServerTask (10 , () -> {
49
- ResourcePackManager resourcePackManager = minecraftServer .getDataPackManager ();
50
- SaveProperties saveProperties = minecraftServer .getSaveProperties ();
51
- Collection <String > collection = resourcePackManager .getEnabledNames ();
52
- Collection <String > collection2 = findNewDataPacks (resourcePackManager , saveProperties , collection );
53
- minecraftServer .reloadResources (collection2 ).exceptionally ((throwable ) -> {
54
- Miapi .LOGGER .warn ("Failed to execute sceduled reload reload" , throwable );
55
- return null ;
56
- });
57
- minecraftServer .executeTask (new ServerTask (10 , () -> {
58
- ResourcePackManager resourcePackManager1 = minecraftServer .getDataPackManager ();
59
- SaveProperties saveProperties1 = minecraftServer .getSaveProperties ();
60
- Collection <String > collection1 = resourcePackManager1 .getEnabledNames ();
61
- Collection <String > collection21 = findNewDataPacks (resourcePackManager1 , saveProperties1 , collection1 );
62
- minecraftServer .reloadResources (collection21 ).exceptionally ((throwable ) -> {
63
- Miapi .LOGGER .warn ("Failed to execute sceduled reload reload" , throwable );
64
- return null ;
65
- });
66
- Miapi .LOGGER .info ("Truly Modulars double Reload was successfull." );
67
- Miapi .LOGGER .info ("This is done because Forges classloading is buggy and stupid. Until we have a better fix, this is used" );
68
- Miapi .LOGGER .info ("This can be turned off in Miapis config.json" );
69
- }));
70
- }));
49
+ ReloadEvents .inReload = true ;
50
+ ReloadEvents .START .fireEvent (false );
51
+ ReloadEvents .DataPackLoader .trigger (cacheDatapack );
52
+ ReloadEvents .MAIN .fireEvent (false );
53
+ ReloadEvents .END .fireEvent (false );
54
+ ReloadEvents .inReload = false ;
71
55
}
72
56
}));
73
57
AttributeProperty .replaceMap .put ("miapi:generic.reach" , ForgeMod .BLOCK_REACH );
0 commit comments