2013-11-17 18:21:24 -06:00
|
|
|
package com.example.examplemod;
|
|
|
|
|
|
2018-09-30 14:29:03 -04:00
|
|
|
import net.minecraft.block.Block;
|
2013-12-28 13:44:37 -05:00
|
|
|
import net.minecraft.init.Blocks;
|
2018-09-30 14:29:03 -04:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
|
|
|
|
import net.minecraftforge.event.RegistryEvent;
|
|
|
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
2014-09-22 22:01:24 -07:00
|
|
|
import net.minecraftforge.fml.common.Mod;
|
2019-01-14 22:32:43 -05:00
|
|
|
import net.minecraftforge.fml.event.FMLInitializationEvent;
|
|
|
|
|
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
|
|
|
|
import net.minecraftforge.fml.event.FMLServerStartingEvent;
|
2018-09-30 14:29:03 -04:00
|
|
|
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
2018-01-12 23:54:29 -08:00
|
|
|
import org.apache.logging.log4j.Logger;
|
2013-11-17 18:21:24 -06:00
|
|
|
|
2018-09-30 14:29:03 -04:00
|
|
|
// The value here should match an entry in the META-INF/mods.toml file
|
|
|
|
|
@Mod("examplemod")
|
2013-11-17 18:21:24 -06:00
|
|
|
public class ExampleMod
|
|
|
|
|
{
|
2018-09-30 14:29:03 -04:00
|
|
|
// Directly reference a log4j logger.
|
|
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2018-01-12 23:54:29 -08:00
|
|
|
|
2018-09-30 14:29:03 -04:00
|
|
|
public ExampleMod() {
|
|
|
|
|
// Register the preInit method for modloading
|
|
|
|
|
FMLModLoadingContext.get().getModEventBus().addListener(this::preInit);
|
|
|
|
|
// Register the init method for modloading
|
|
|
|
|
FMLModLoadingContext.get().getModEventBus().addListener(this::init);
|
2018-01-12 23:54:29 -08:00
|
|
|
|
2018-09-30 14:29:03 -04:00
|
|
|
// Register ourselves for server, registry and other game events we are interested in
|
|
|
|
|
MinecraftForge.EVENT_BUS.register(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void preInit(final FMLPreInitializationEvent event)
|
2018-01-12 23:54:29 -08:00
|
|
|
{
|
2018-09-30 14:29:03 -04:00
|
|
|
// some preinit code
|
|
|
|
|
LOGGER.info("HELLO FROM PREINIT");
|
2018-01-12 23:54:29 -08:00
|
|
|
}
|
|
|
|
|
|
2018-09-30 14:29:03 -04:00
|
|
|
private void init(final FMLInitializationEvent event)
|
2013-11-17 18:21:24 -06:00
|
|
|
{
|
2016-05-18 18:06:41 -07:00
|
|
|
// some example code
|
2018-09-30 14:29:03 -04:00
|
|
|
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
|
|
|
|
|
// register a new block here
|
|
|
|
|
LOGGER.info("HELLO from Register Block");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SubscribeEvent
|
|
|
|
|
public void onServerStarting(FMLServerStartingEvent event) {
|
|
|
|
|
// do something when the server starts
|
|
|
|
|
LOGGER.info("HELLO from server starting");
|
2013-11-17 18:21:24 -06:00
|
|
|
}
|
|
|
|
|
}
|