Skip to content

Commit

Permalink
fixing the TemplateMod class
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 22, 2023
1 parent 85ebc0f commit 69071c0
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions src/main/java/me/fallenbreath/template_mod/TemplateMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 69071c0

Please sign in to comment.