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;
|
package com.example.examplemod;
|
||||||
|
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
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.fml.event.lifecycle.InterModProcessEvent;
|
||||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.slf4j.Logger;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -21,10 +21,11 @@ import java.util.stream.Collectors;
|
||||||
@Mod("examplemod")
|
@Mod("examplemod")
|
||||||
public class ExampleMod
|
public class ExampleMod
|
||||||
{
|
{
|
||||||
// Directly reference a log4j logger.
|
// Directly reference a slf4j logger
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public ExampleMod() {
|
public ExampleMod()
|
||||||
|
{
|
||||||
// Register the setup method for modloading
|
// Register the setup method for modloading
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||||
// Register the enqueueIMC method for modloading
|
// Register the enqueueIMC method for modloading
|
||||||
|
@ -45,31 +46,35 @@ public class ExampleMod
|
||||||
|
|
||||||
private void enqueueIMC(final InterModEnqueueEvent event)
|
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";});
|
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processIMC(final InterModProcessEvent event)
|
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().
|
LOGGER.info("Got IMC {}", event.getIMCStream().
|
||||||
map(m->m.messageSupplier().get()).
|
map(m->m.messageSupplier().get()).
|
||||||
collect(Collectors.toList()));
|
collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onServerStarting(ServerStartingEvent event) {
|
public void onServerStarting(ServerStartingEvent event)
|
||||||
// do something when the server starts
|
{
|
||||||
|
// Do something when the server starts
|
||||||
LOGGER.info("HELLO from server starting");
|
LOGGER.info("HELLO from server starting");
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
// You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD
|
||||||
// Event bus for receiving Registry Events)
|
// Event bus for receiving Registry Events)
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public static class RegistryEvents {
|
public static class RegistryEvents
|
||||||
|
{
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
|
||||||
// register a new block here
|
{
|
||||||
|
// Register a new block here
|
||||||
LOGGER.info("HELLO from Register Block");
|
LOGGER.info("HELLO from Register Block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"description": "examplemod resources",
|
"description": "examplemod resources",
|
||||||
"pack_format": 8
|
"pack_format": 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue