diff --git a/forge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java b/forge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java deleted file mode 100644 index 577e85e..0000000 --- a/forge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kotori316.scala_lib.example; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.level.LevelEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@Mod(JavaModClass.MOD_ID) -public class JavaModClass { - public static final String MOD_ID = "scala-library-java"; - public static final Logger LOGGER = LogManager.getLogger(JavaModClass.class); - - public JavaModClass() { - // Registering init method. - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init); - MinecraftForge.EVENT_BUS.register(EventHandlers.class); - } - - /** - * Mod initialize method. Called via Mod Event bus, which is registered in {@link JavaModClass#JavaModClass()}. - */ - public void init(FMLCommonSetupEvent event) { - LOGGER.info("Hello from java init method. " + event); - } - - /** - * Please avoid the use of {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber}, as it causes strange compile errors. - * Register via {@link net.minecraftforge.eventbus.api.IEventBus#register(Object)} is fine. - */ - // @Mod.EventBusSubscriber(modid = MOD_ID) - public static class EventHandlers { - /** - * Methods that handles event must be static. - * - * @see net.minecraftforge.eventbus.api.IEventBus#register(Object) - */ - @SubscribeEvent - public static void load(LevelEvent.Load event) { - LOGGER.info("Caught " + event); - } - - @SubscribeEvent - public static void unload(LevelEvent.Unload event) { - LOGGER.info("Caught " + event); - } - } -} diff --git a/forge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala b/forge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala deleted file mode 100644 index d7fa097..0000000 --- a/forge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala +++ /dev/null @@ -1,64 +0,0 @@ -package com.kotori316.scala_lib.example - -import cats._ -import cats.implicits.toShow -import net.minecraftforge.event.level.LevelEvent -import net.minecraftforge.eventbus.api.SubscribeEvent -import net.minecraftforge.fml.ModList -import net.minecraftforge.fml.common.Mod -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext -import org.apache.logging.log4j.{LogManager, Logger} - -/** - * Mod class representing `scala-library`. - */ -@Mod(ScalaModObject.modId) -object ScalaModObject { - final val modId = "scala-library-object" - val LOGGER: Logger = LogManager.getLogger(modId) - - require(Class.forName("scala.Option").getMethod("empty").invoke(null) == None) - - // A way to get mod event bus. - FMLJavaModLoadingContext.get().getModEventBus.addListener(this.init) - - /** - * Initialization method of mods. - */ - def init(event: FMLCommonSetupEvent): Unit = { - LOGGER.info("Hello from ScalaModObject#init") - LOGGER.info(s"Mod($modId) is loaded. " + event) - LOGGER.info(ModID(modId).show) - } - - case class ModID(id: String) - - // Example of Cats instance. - implicit val showId: Show[ModID] = (t: ModID) => { - val name = ModList.get().getModObjectById[AnyRef](t.id).map[String](o => o.getClass.getName).orElse("None") - s"ID: ${t.id}, Class: $name" - } - - /** - * Automatic subscribing of events is NOT supported due to limitation of compiling. - * Use [[net.minecraftforge.eventbus.api.IEventBus]]#`register` to register event handlers. - * Registering this object via [[net.minecraftforge.eventbus.api.IEventBus]]#`register` will work fine. - */ - // @Mod.EventBusSubscriber(bus = Bus.FORGE, modid = modId) - object BadEventHandler { - @SubscribeEvent - def worldLogin(worldEvent: LevelEvent): Unit = { - LOGGER.fatal("NEVER HAPPENED " + worldEvent) - } - } - -} - -/** - * Dummy class. - * This class is never loaded by forge unless you call method or try to initialize. - */ -class ScalaModObject { - throw new java.lang.AssertionError("Mod class (not object) must not be loaded by forge. The companion object is mod instance.") -} diff --git a/neoforge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java b/neoforge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java deleted file mode 100644 index 577e85e..0000000 --- a/neoforge/src/main/scala/com/kotori316/scala_lib/example/JavaModClass.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.kotori316.scala_lib.example; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.level.LevelEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -@Mod(JavaModClass.MOD_ID) -public class JavaModClass { - public static final String MOD_ID = "scala-library-java"; - public static final Logger LOGGER = LogManager.getLogger(JavaModClass.class); - - public JavaModClass() { - // Registering init method. - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init); - MinecraftForge.EVENT_BUS.register(EventHandlers.class); - } - - /** - * Mod initialize method. Called via Mod Event bus, which is registered in {@link JavaModClass#JavaModClass()}. - */ - public void init(FMLCommonSetupEvent event) { - LOGGER.info("Hello from java init method. " + event); - } - - /** - * Please avoid the use of {@link net.minecraftforge.fml.common.Mod.EventBusSubscriber}, as it causes strange compile errors. - * Register via {@link net.minecraftforge.eventbus.api.IEventBus#register(Object)} is fine. - */ - // @Mod.EventBusSubscriber(modid = MOD_ID) - public static class EventHandlers { - /** - * Methods that handles event must be static. - * - * @see net.minecraftforge.eventbus.api.IEventBus#register(Object) - */ - @SubscribeEvent - public static void load(LevelEvent.Load event) { - LOGGER.info("Caught " + event); - } - - @SubscribeEvent - public static void unload(LevelEvent.Unload event) { - LOGGER.info("Caught " + event); - } - } -} diff --git a/neoforge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala b/neoforge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala deleted file mode 100644 index 5df2c51..0000000 --- a/neoforge/src/main/scala/com/kotori316/scala_lib/example/ScalaModObject.scala +++ /dev/null @@ -1,64 +0,0 @@ -package com.kotori316.scala_lib.example - -import cats.* -import cats.implicits.toShow -import net.neoforged.neoforge.event.level.LevelEvent -import net.neoforged.bus.api.SubscribeEvent -import net.neoforged.fml.ModList -import net.neoforged.fml.common.Mod -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent -import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext -import org.apache.logging.log4j.{LogManager, Logger} - -/** - * Mod class representing `scala-library`. - */ -@Mod(ScalaModObject.modId) -object ScalaModObject { - final val modId = "scala-library-object" - val LOGGER: Logger = LogManager.getLogger(modId) - - require(Class.forName("scala.Option").getMethod("empty").invoke(null) == None) - - // A way to get mod event bus. - FMLJavaModLoadingContext.get().getModEventBus.addListener(this.init) - - /** - * Initialization method of mods. - */ - def init(event: FMLCommonSetupEvent): Unit = { - LOGGER.info("Hello from ScalaModObject#init") - LOGGER.info(s"Mod($modId) is loaded. " + event) - LOGGER.info(ModID(modId).show) - } - - case class ModID(id: String) - - // Example of Cats instance. - implicit val showId: Show[ModID] = (t: ModID) => { - val name = ModList.get().getModObjectById[AnyRef](t.id).map[String](o => o.getClass.getName).orElse("None") - s"ID: ${t.id}, Class: $name" - } - - /** - * Automatic subscribing of events is NOT supported due to limitation of compiling. - * Use [[net.minecraftforge.eventbus.api.IEventBus]]#`register` to register event handlers. - * Registering this object via [[net.minecraftforge.eventbus.api.IEventBus]]#`register` will work fine. - */ - // @Mod.EventBusSubscriber(bus = Bus.FORGE, modid = modId) - object BadEventHandler { - @SubscribeEvent - def worldLogin(worldEvent: LevelEvent): Unit = { - LOGGER.fatal("NEVER HAPPENED " + worldEvent) - } - } - -} - -/** - * Dummy class. - * This class is never loaded by forge unless you call method or try to initialize. - */ -class ScalaModObject { - throw new java.lang.AssertionError("Mod class (not object) must not be loaded by forge. The companion object is mod instance.") -}