moving loading of scripts to after worlds are loaded, fixes #331
This commit is contained in:
1 parent
d838cfd32f
commit
be7d7ed46e
3 files changed
+22
-3
No files matched your search
@@ -16,11 +16,18 @@ public interface CarpetExtension
|
||||
default void onGameStarted() {}
|
||||
|
||||
/**
|
||||
* Runs once per loaded world once the World files / gamerules etc are fully loaded
|
||||
* Runs once per loaded world once the server / gamerules etc are fully loaded
|
||||
* but before worlds are loaded
|
||||
* Can be loaded multiple times in SinglePlayer
|
||||
*/
|
||||
default void onServerLoaded(MinecraftServer server) {}
|
||||
|
||||
/**
|
||||
* Runs once per loaded world once the World files are fully loaded
|
||||
* Can be loaded multiple times in SinglePlayer
|
||||
*/
|
||||
default void onServerLoadedWorlds(MinecraftServer server) {}
|
||||
|
||||
/**
|
||||
* Runs once per game tick, as a first thing in the tick
|
||||
*/
|
||||
@@ -55,4 +62,6 @@ public interface CarpetExtension
|
||||
default void registerLoggers() {}
|
||||
|
||||
default Map<String, String> canHasTranslations(String lang) { return null;}
|
||||
|
||||
|
||||
}
|
||||
@@ -58,12 +58,17 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
e.onServerLoaded(server);
|
||||
});
|
||||
scriptServer = new CarpetScriptServer(server);
|
||||
scriptServer.loadAllWorldScripts();
|
||||
MobAI.resetTrackers();
|
||||
LoggerRegistry.initLoggers();
|
||||
//TickSpeed.reset();
|
||||
}
|
||||
|
||||
public static void onServerLoadedWorlds(MinecraftServer minecraftServer)
|
||||
{
|
||||
extensions.forEach(e -> e.onServerLoadedWorlds(minecraftServer));
|
||||
scriptServer.loadAllWorldScripts();
|
||||
}
|
||||
|
||||
public static void tick(MinecraftServer server)
|
||||
{
|
||||
TickSpeed.tick(server);
|
||||
|
||||
@@ -31,13 +31,18 @@ public abstract class MinecraftServer_coreMixin
|
||||
CarpetServer.tick((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
// Dedicated server only
|
||||
@Inject(method = "loadWorld", at = @At("HEAD"))
|
||||
private void serverLoaded(String string_1, String string_2, long long_1, LevelGeneratorType levelGeneratorType_1, JsonElement jsonElement_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerLoaded((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "loadWorld", at = @At("RETURN"))
|
||||
private void serverLoadedWorlds(String string_1, String string_2, long long_1, LevelGeneratorType levelGeneratorType_1, JsonElement jsonElement_1, CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerLoadedWorlds((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "shutdown", at = @At("HEAD"))
|
||||
private void serverClosed(CallbackInfo ci)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user