Merge 1.16 into 1.18

This commit is contained in:
embeddedt 2023-06-26 12:59:32 -04:00
commit 2ffb31f00d
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 6 additions and 4 deletions

View File

@ -10,6 +10,7 @@ is directly derived from Sodium and used under the terms of the LGPL-3.0 license
- 1.18.2, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.18/Package.zip - 1.18.2, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.18/Package.zip
- 1.19.2, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.19.2/Package.zip - 1.19.2, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.19.2/Package.zip
- 1.19.4, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.19.4/Package.zip - 1.19.4, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.19.4/Package.zip
- 1.20.1, both modloaders: https://nightly.link/embeddedt/ModernFix/workflows/gradle/1.20/Package.zip
------------ ------------

View File

@ -4,22 +4,23 @@ import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import java.lang.ref.WeakReference;
public class ModernFixFabric implements ModInitializer { public class ModernFixFabric implements ModInitializer {
private ModernFix commonMod; private ModernFix commonMod;
public static MinecraftServer theServer; public static WeakReference<MinecraftServer> theServer = new WeakReference<>(null);
@Override @Override
public void onInitialize() { public void onInitialize() {
commonMod = new ModernFix(); commonMod = new ModernFix();
ServerLifecycleEvents.SERVER_STARTING.register(server -> { ServerLifecycleEvents.SERVER_STARTING.register(server -> {
theServer = server; theServer = new WeakReference<>(server);
}); });
ServerLifecycleEvents.SERVER_STARTED.register(server -> { ServerLifecycleEvents.SERVER_STARTED.register(server -> {
commonMod.onServerStarted(); commonMod.onServerStarted();
}); });
ServerLifecycleEvents.SERVER_STOPPED.register(server -> { ServerLifecycleEvents.SERVER_STOPPED.register(server -> {
commonMod.onServerDead(server); commonMod.onServerDead(server);
theServer = null;
}); });
// TODO: implement entity ID desync // TODO: implement entity ID desync

View File

@ -53,7 +53,7 @@ public class ModernFixPlatformHooksImpl {
} }
public static MinecraftServer getCurrentServer() { public static MinecraftServer getCurrentServer() {
return ModernFixFabric.theServer; return ModernFixFabric.theServer.get();
} }
public static boolean isLoadingNormally() { public static boolean isLoadingNormally() {