From 69071c041d5d91fbbb7b9b66dcd63edab2bad878 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sat, 23 Dec 2023 00:17:44 +0800 Subject: [PATCH] fixing the TemplateMod class --- .../template_mod/TemplateMod.java | 57 +++++++++---------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/src/main/java/me/fallenbreath/template_mod/TemplateMod.java b/src/main/java/me/fallenbreath/template_mod/TemplateMod.java index eb9bc6c..4d674be 100644 --- a/src/main/java/me/fallenbreath/template_mod/TemplateMod.java +++ b/src/main/java/me/fallenbreath/template_mod/TemplateMod.java @@ -33,7 +33,17 @@ import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.metadata.ModMetadata; -public class TemplateMod implements ModInitializer +//#elseif FORGE +//$$ import net.minecraftforge.fml.ModList; +//$$ import net.minecraftforge.fml.common.Mod; +//$$ import net.minecraftforge.forgespi.language.IModInfo; +//$$ +//$$ @Mod(TemplateMod.MOD_ID) +//#endif +public class TemplateMod + //#if FABRIC + implements ModInitializer + //#endif { public static final Logger LOGGER = //#if MC >= 11800 @@ -46,40 +56,29 @@ public class TemplateMod implements ModInitializer public static String MOD_VERSION = "unknown"; public static String MOD_NAME = "unknown"; + //#if FABRIC @Override public void onInitialize() { ModMetadata metadata = FabricLoader.getInstance().getModContainer(MOD_ID).orElseThrow(RuntimeException::new).getMetadata(); MOD_NAME = metadata.getName(); MOD_VERSION = metadata.getVersion().getFriendlyString(); - LOGGER.info("Hello {} v{} from fabric!", MOD_NAME, MOD_VERSION); + this.init(); + } + //#elseif FORGE + //$$ public TemplateMod() + //$$ { + //$$ IModInfo modInfo = ModList.get().getModContainerById(MOD_ID).orElseThrow(RuntimeException::new).getModInfo(); + //$$ MOD_NAME = modInfo.getDisplayName(); + //$$ MOD_VERSION = modInfo.getVersion().toString(); + //$$ LOGGER.info("Hello {} v{} from forge!", MOD_NAME, MOD_VERSION); + //$$ this.init(); + //$$ } + //#endif + + private void init() + { + // common init here } } -//#elseif FORGE -//$$ import net.minecraftforge.fml.ModList; -//$$ import net.minecraftforge.fml.common.Mod; -//$$ import net.minecraftforge.forgespi.language.IModInfo; -//$$ -//$$ @Mod(TemplateMod.MOD_ID) -//$$ public class TemplateMod -//$$ { -//$$ public static final Logger LOGGER = -//$$ //#if MC >= 11800 -//$$ //$$ LogUtils.getLogger(); -//$$ //#else -//$$ LogManager.getLogger(); -//$$ //#endif -//$$ public static final String MOD_ID = "template_mod"; -//$$ public static String MOD_VERSION = "unknown"; -//$$ public static String MOD_NAME = "unknown"; -//$$ -//$$ public TemplateMod() -//$$ { -//$$ IModInfo modInfo = ModList.get().getModContainerById(MOD_ID).orElseThrow(RuntimeException::new).getModInfo(); -//$$ MOD_NAME = modInfo.getDisplayName(); -//$$ MOD_VERSION = modInfo.getVersion().toString(); -//$$ LOGGER.info("Hello {} v{} from forge!", MOD_NAME, MOD_VERSION); -//$$ } -//$$ } -//#endif