From 904f6e33891dd17b811e33a795a75f30e4c2f8cd Mon Sep 17 00:00:00 2001 From: Ivan1F Date: Sat, 24 Dec 2022 15:02:50 +0800 Subject: [PATCH] better extension registration --- .../IvanCarpetAdditionMod.java | 2 ++ .../IvanCarpetAdditionServer.java | 5 +++-- .../mixins/carpet/CarpetServerMixin.java | 20 ------------------- .../ivan-carpet-addition.mixins.json | 1 - 4 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 src/main/java/me/ivan/ivancarpetaddition/mixins/carpet/CarpetServerMixin.java diff --git a/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionMod.java b/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionMod.java index 3b286e18..ce1122cb 100644 --- a/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionMod.java +++ b/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionMod.java @@ -9,6 +9,8 @@ public class IvanCarpetAdditionMod implements ModInitializer { @Override public void onInitialize() { version = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString(); + + IvanCarpetAdditionServer.init(); } public static String getModId() diff --git a/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionServer.java b/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionServer.java index 18f50dc0..d061522f 100644 --- a/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionServer.java +++ b/src/main/java/me/ivan/ivancarpetaddition/IvanCarpetAdditionServer.java @@ -41,8 +41,9 @@ public static IvanCarpetAdditionServer getInstance() { return INSTANCE; } - public void registerExtension() { - CarpetServer.manageExtension(this); + public static void init() { + CarpetServer.manageExtension(INSTANCE); + ICATranslations.loadTranslations(); } @Override diff --git a/src/main/java/me/ivan/ivancarpetaddition/mixins/carpet/CarpetServerMixin.java b/src/main/java/me/ivan/ivancarpetaddition/mixins/carpet/CarpetServerMixin.java deleted file mode 100644 index c402a331..00000000 --- a/src/main/java/me/ivan/ivancarpetaddition/mixins/carpet/CarpetServerMixin.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.ivan.ivancarpetaddition.mixins.carpet; - -import carpet.CarpetServer; -import me.ivan.ivancarpetaddition.IvanCarpetAdditionServer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(CarpetServer.class) -public abstract class CarpetServerMixin { - @Inject( - method = "onGameStarted", - at = @At(value = "HEAD"), - remap = false - ) - private static void registerCarpetExtension(CallbackInfo ci) { - IvanCarpetAdditionServer.getInstance().registerExtension(); - } -} diff --git a/src/main/resources/ivan-carpet-addition.mixins.json b/src/main/resources/ivan-carpet-addition.mixins.json index 3090d9c9..e8de9aab 100644 --- a/src/main/resources/ivan-carpet-addition.mixins.json +++ b/src/main/resources/ivan-carpet-addition.mixins.json @@ -5,7 +5,6 @@ "plugin": "me.ivan.ivancarpetaddition.utils.mixin.ICAMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ - "carpet.CarpetServerMixin", "carpet.HUDControllerMixin", "carpet.SettingsManagerMixin", "command.xpcounter.ExperienceOrbEntityAccessor",