Clean up the mod loading context objects. There is only one ThreadLocal now.

**BREAKING CHANGE** FMLModLoadingContext is renamed to FMLJavaModLoadingContext.
LanguageProviders can setup additional contextual data.

Signed-off-by: cpw <cpw+github@weeksfamily.ca>
This commit is contained in:
cpw 2019-02-13 22:13:59 -05:00
parent e4bfca53af
commit f71f347082

View file

@ -12,7 +12,7 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent; import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent; import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -27,13 +27,13 @@ public class ExampleMod
public ExampleMod() { public ExampleMod() {
// Register the setup method for modloading // Register the setup method for modloading
FMLModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading // Register the enqueueIMC method for modloading
FMLModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading // Register the processIMC method for modloading
FMLModLoadingContext.get().getModEventBus().addListener(this::processIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
// Register the doClientStuff method for modloading // Register the doClientStuff method for modloading
FMLModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register ourselves for server, registry and other game events we are interested in // Register ourselves for server, registry and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
@ -66,18 +66,18 @@ public class ExampleMod
} }
// 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 onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { public static void onServerStarting(FMLServerStartingEvent event) {
// register a new block here // do something when the server starts
LOGGER.info("HELLO from Register Block"); LOGGER.info("HELLO from server starting");
} }
// You can use EventBusSubscriber to automatically subscribe events on the contained class // You can use EventBusSubscriber to automatically subscribe events on the contained class (this is subscribing to the MOD event bus
@Mod.EventBusSubscriber @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
public static class ServerEvents { public static class RegistryEvents {
@SubscribeEvent @SubscribeEvent
public static void onServerStarting(FMLServerStartingEvent event) { public void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
// do something when the server starts // register a new block here
LOGGER.info("HELLO from server starting"); LOGGER.info("HELLO from Register Block");
} }
} }
} }