Update to 1.18.2
Co-authored-by: sciwhiz12 <arnoldnunag12@gmail.com> Co-authored-by: Marc Hermans <marc.hermans@ldtteam.com> Co-authored-by: LexManos <LexManos@gmail.com> Co-authored-by: Curle <curle@gemwire.uk> Signed-off-by: SizableShrimp <sizableshrimp@sizableshrimp.me>
This commit is contained in:
parent
7f65352e09
commit
03379dea27
2 changed files with 19 additions and 14 deletions
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "examplemod resources",
|
||||
"pack_format": 8
|
||||
"pack_format": 9
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue