Fix dedicated server loading by constructing mods before data packs are created.

This commit is contained in:
LexManos 2020-06-26 09:56:23 -07:00
parent 30227a1e28
commit 99917e569c
2 changed files with 12 additions and 3 deletions

View file

@ -17,7 +17,7 @@
Path path1 = Paths.get("eula.txt"); Path path1 = Paths.get("eula.txt");
ServerEula servereula = new ServerEula(path1); ServerEula servereula = new ServerEula(path1);
if (optionset.has(optionspec1)) { if (optionset.has(optionspec1)) {
@@ -105,6 +106,10 @@ @@ -105,6 +106,11 @@
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository(); GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(file1, MinecraftServer.field_152367_a.getName())); PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(file1, MinecraftServer.field_152367_a.getName()));
String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(serverpropertiesprovider.func_219034_a().field_219021_o); String s = Optional.ofNullable(optionset.valueOf(optionspec10)).orElse(serverpropertiesprovider.func_219034_a().field_219021_o);
@ -25,10 +25,11 @@
+ field_240759_a_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s); + field_240759_a_.error("Invalid world directory specified, must not be null, empty or the same directory as your universe! " + s);
+ return; + return;
+ } + }
+ net.minecraftforge.fml.server.ServerModLoader.gatherAndInit(); // Gather and construct mods before resource loading and before world conversions.
SaveFormat saveformat = SaveFormat.func_237269_a_(file1.toPath()); SaveFormat saveformat = SaveFormat.func_237269_a_(file1.toPath());
SaveFormat.LevelSave saveformat$levelsave = saveformat.func_237274_c_(s); SaveFormat.LevelSave saveformat$levelsave = saveformat.func_237274_c_(s);
MinecraftServer.func_240777_a_(saveformat$levelsave); MinecraftServer.func_240777_a_(saveformat$levelsave);
@@ -170,6 +175,7 @@ @@ -170,6 +176,7 @@
Thread thread = new Thread("Server Shutdown Thread") { Thread thread = new Thread("Server Shutdown Thread") {
public void run() { public void run() {
dedicatedserver.func_71263_m(true); dedicatedserver.func_71263_m(true);

View file

@ -36,13 +36,21 @@ public class ServerModLoader
private static DedicatedServer server; private static DedicatedServer server;
private static boolean hasErrors = false; private static boolean hasErrors = false;
public static void gatherAndInit() {
try {
ModLoader.get().gatherAndInitializeMods(() -> {});
} catch (LoadingFailedException e) {
ServerModLoader.hasErrors = true;
throw e;
}
}
public static void begin(DedicatedServer dedicatedServer) { public static void begin(DedicatedServer dedicatedServer) {
ServerModLoader.server = dedicatedServer; ServerModLoader.server = dedicatedServer;
SidedProvider.setServer(()->dedicatedServer); SidedProvider.setServer(()->dedicatedServer);
LogicalSidedProvider.setServer(()->dedicatedServer); LogicalSidedProvider.setServer(()->dedicatedServer);
LanguageHook.loadForgeAndMCLangs(); LanguageHook.loadForgeAndMCLangs();
try { try {
ModLoader.get().gatherAndInitializeMods(() -> {});
ModLoader.get().loadMods(Runnable::run, (a)->{}, (a)->{}); ModLoader.get().loadMods(Runnable::run, (a)->{}, (a)->{});
} catch (LoadingFailedException e) { } catch (LoadingFailedException e) {
ServerModLoader.hasErrors = true; ServerModLoader.hasErrors = true;