summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/example/examplemod/ExampleMod.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/main/java/com/example/examplemod/ExampleMod.java b/src/main/java/com/example/examplemod/ExampleMod.java
index 27476be..421fd07 100644
--- a/src/main/java/com/example/examplemod/ExampleMod.java
+++ b/src/main/java/com/example/examplemod/ExampleMod.java
@@ -1,5 +1,6 @@
package com.example.examplemod;
+import com.mojang.logging.LogUtils;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.common.MinecraftForge;
@@ -12,8 +13,7 @@ import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.event.server.ServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
+import org.slf4j.Logger;
import java.util.stream.Collectors;
@@ -21,10 +21,11 @@ import java.util.stream.Collectors;
@Mod("examplemod")
public class ExampleMod
{
- // Directly reference a log4j logger.
- private static final Logger LOGGER = LogManager.getLogger();
+ // Directly reference a slf4j logger
+ private static final Logger LOGGER = LogUtils.getLogger();
- public ExampleMod() {
+ public ExampleMod()
+ {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading
@@ -45,31 +46,35 @@ public class ExampleMod
private void enqueueIMC(final InterModEnqueueEvent event)
{
- // some example code to dispatch IMC to another mod
+ // Some example code to dispatch IMC to another mod
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}
private void processIMC(final InterModProcessEvent event)
{
- // some example code to receive and process InterModComms from other mods
+ // Some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.messageSupplier().get()).
collect(Collectors.toList()));
}
+
// You can use SubscribeEvent and let the Event Bus discover methods to call
@SubscribeEvent
- public void onServerStarting(ServerStartingEvent event) {
- // do something when the server starts
+ public void onServerStarting(ServerStartingEvent event)
+ {
+ // Do something when the server starts
LOGGER.info("HELLO from server starting");
}
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
- @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
- public static class RegistryEvents {
+ @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
+ public static class RegistryEvents
+ {
@SubscribeEvent
- public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
- // register a new block here
+ public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
+ {
+ // Register a new block here
LOGGER.info("HELLO from Register Block");
}
}