From 03379dea274fba774b828d9625d11adbf6403f0a Mon Sep 17 00:00:00 2001 From: SizableShrimp Date: Tue, 1 Mar 2022 14:59:27 -0600 Subject: [PATCH] Update to 1.18.2 Co-authored-by: sciwhiz12 Co-authored-by: Marc Hermans Co-authored-by: LexManos Co-authored-by: Curle Signed-off-by: SizableShrimp --- .../com/example/examplemod/ExampleMod.java | 31 +++++++++++-------- src/main/resources/pack.mcmeta | 2 +- 2 files changed, 19 insertions(+), 14 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 blockRegistryEvent) { - // register a new block here + public static void onBlocksRegistry(final RegistryEvent.Register blockRegistryEvent) + { + // Register a new block here LOGGER.info("HELLO from Register Block"); } } diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index b18e3cd..f335b9f 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "examplemod resources", - "pack_format": 8 + "pack_format": 9 } }