net.minecraftforge.fml.ModLoadingContext Java Examples

The following examples show how to use net.minecraftforge.fml.ModLoadingContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MiningGadgets.java    From MiningGadgets with MIT License 6 votes vote down vote up
public MiningGadgets() {
    IEventBus event = FMLJavaModLoadingContext.get().getModEventBus();

    // Register all of our items, blocks, item blocks, etc
    ModItems.ITEMS.register(event);
    ModItems.UPGRADE_ITEMS.register(event);
    ModBlocks.BLOCKS.register(event);
    ModBlocks.TILES_ENTITIES.register(event);
    ModContainers.CONTAINERS.register(event);

    event.addListener(this::setup);
    event.addListener(this::setupClient);

    ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_CONFIG);
    ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_CONFIG);

    // Register the setup method for modloading
    event.addListener(this::setup);
    MinecraftForge.EVENT_BUS.register(this);

    Config.loadConfig(Config.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MOD_ID + "-client.toml"));
    Config.loadConfig(Config.COMMON_CONFIG, FMLPaths.CONFIGDIR.get().resolve(MOD_ID + "-common.toml"));
}
 
Example #2
Source File: SurvivalistMod.java    From Survivalist with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public SurvivalistMod()
{
    instance = this;

    ModLoadingContext modLoadingContext = ModLoadingContext.get();
    IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

    HELPER.subscribeEvents(modEventBus);
    SurvivalistBlocks.HELPER.subscribeEvents(modEventBus);
    SurvivalistItems.HELPER.subscribeEvents(modEventBus);
    SurvivalistTileEntityTypes.HELPER.subscribeEvents(modEventBus);

    modEventBus.addGenericListener(ContainerType.class, this::registerContainers);
    modEventBus.addGenericListener(IRecipeSerializer.class, this::registerRecipeSerializers);
    modEventBus.addGenericListener(GlobalLootModifierSerializer.class, this::lootModifiers);
    modEventBus.addListener(this::commonSetup);
    modEventBus.addListener(this::clientSetup);
    modEventBus.addListener(this::gatherData);

    MinecraftForge.EVENT_BUS.addListener(this::serverStarting);

    modLoadingContext.registerConfig(ModConfig.Type.SERVER, ConfigManager.SERVER_SPEC);
}
 
Example #3
Source File: Patchwork.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void dispatch(Map<ForgeInitializer, FMLModContainer> mods, Function<ModContainer, Event> provider) {
	for (FMLModContainer container : mods.values()) {
		ModLoadingContext.get().setActiveContainer(container, new FMLJavaModLoadingContext(container));

		container.getEventBus().post(provider.apply(container));

		ModLoadingContext.get().setActiveContainer(null, "minecraft");
	}
}
 
Example #4
Source File: BetterSprintingConfig.java    From Better-Sprinting with Mozilla Public License 2.0 5 votes vote down vote up
public static void register(ModLoadingContext context, ModConfig.Type type, ForgeConfigSpec spec, String suffix){
	String fileName = BetterSprintingMod.id + "-" + suffix + ".toml";
	context.registerConfig(type, spec, fileName);
	
	if (Files.notExists(Paths.get("config", fileName))){
		migrationFile = Paths.get("config", "bettersprinting.cfg").toAbsolutePath();
		isNew = true; // since keybinds are not migrated and first time setup only modifies keybinds, this is fine
	}
}
 
Example #5
Source File: XRay.java    From XRay-Mod with GNU General Public License v3.0 5 votes vote down vote up
public XRay() {
	IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();

	eventBus.addListener(this::onSetup);
	eventBus.addListener(this::onLoadComplete);
	eventBus.addListener(this::onExit);

	ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Configuration.SPEC);

	// Keybindings
	MinecraftForge.EVENT_BUS.register(KeyBindings.class);
}
 
Example #6
Source File: ForgeSparkMod.java    From spark with GNU General Public License v3.0 4 votes vote down vote up
public ForgeSparkMod() {
    FMLJavaModLoadingContext.get().getModEventBus().register(this);
    MinecraftForge.EVENT_BUS.register(this);
    ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST, () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
}
 
Example #7
Source File: ForgeSparkMod.java    From spark with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void setup(FMLCommonSetupEvent e) {
    this.container = ModLoadingContext.get().getActiveContainer();
    this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId());
}
 
Example #8
Source File: BetterSprintingMod.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
public BetterSprintingMod(){
	proxy.onConstructed(ModLoadingContext.get());
}
 
Example #9
Source File: ClientProxy.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onConstructed(ModLoadingContext ctx){
	ClientSettings.register(ctx);
	PacketPipeline.initialize(new ClientNetwork());
}
 
Example #10
Source File: ClientSettings.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
static void register(ModLoadingContext ctx){
	BetterSprintingConfig.register(ctx, ModConfig.Type.CLIENT, configSpec, "client");
}
 
Example #11
Source File: ServerProxy.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void onConstructed(ModLoadingContext ctx){
	ServerSettings.register(ctx);
	PacketPipeline.initialize(new ServerNetwork());
}
 
Example #12
Source File: ServerSettings.java    From Better-Sprinting with Mozilla Public License 2.0 4 votes vote down vote up
static void register(ModLoadingContext ctx){
	BetterSprintingConfig.register(ctx, ModConfig.Type.COMMON, configSpec, "server");
}
 
Example #13
Source File: FMLJavaModLoadingContext.java    From patchwork-api with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Helper to get the right instance from the {@link ModLoadingContext} correctly.
 *
 * @return The FMLJavaMod language specific extension from the ModLoadingContext
 */
public static FMLJavaModLoadingContext get() {
	return ModLoadingContext.get().extension();
}
 
Example #14
Source File: BetterSprintingProxy.java    From Better-Sprinting with Mozilla Public License 2.0 votes vote down vote up
public abstract void onConstructed(ModLoadingContext ctx);