net.minecraftforge.fml.config.ModConfig Java Examples
The following examples show how to use
net.minecraftforge.fml.config.ModConfig.
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 |
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: ConfigManager.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SubscribeEvent public static void modConfig(ModConfig.ModConfigEvent event) { ModConfig config = event.getConfig(); if (config.getSpec() != SERVER_SPEC) return; Config axeLevels = SERVER.axeLevels.get(); for (Config.Entry e : axeLevels.entrySet()) { Matcher m = AXE_LEVEL_ENTRY_PATTERN.matcher(e.getKey()); if (m.matches()) { String numberPart = m.group("level"); int levelNumber = Integer.parseInt(numberPart); axeLevelMap.put(levelNumber, e.getIntOrElse(1 + levelNumber)); } } }
Example #3
Source File: SurvivalistMod.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #4
Source File: LifecycleEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public static void handleServerAboutToStart(final MinecraftServer server) { ServerLifecycleHooks.currentServer = server; LogicalSidedProvider.setServer(() -> server); ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.SERVER, getServerConfigPath(server)); // TODO: ResourcePackLoader.loadResourcePacks(currentServer.getDataPackManager(), ServerLifecycleHooks::buildPackFinder); MinecraftForge.EVENT_BUS.post(new FMLServerAboutToStartEvent(server)); }
Example #5
Source File: BetterSprintingConfig.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
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 #6
Source File: XRay.java From XRay-Mod with GNU General Public License v3.0 | 5 votes |
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 #7
Source File: ModLoadingContext.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec) { getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer())); }
Example #8
Source File: ModLoadingContext.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public void registerConfig(ModConfig.Type type, ForgeConfigSpec spec, String fileName) { getActiveContainer().addConfig(new ModConfig(type, spec, getActiveContainer(), fileName)); }
Example #9
Source File: ModContainer.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public ModContainer(String modId) { this.modId = modId; // TODO: Currently not reading namespace from configuration.. this.namespace = modId; this.configs = new EnumMap<>(ModConfig.Type.class); }
Example #10
Source File: ModContainer.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public void addConfig(final ModConfig modConfig) { configs.put(modConfig.getType(), modConfig); }
Example #11
Source File: Config.java From MiningGadgets with MIT License | 4 votes |
@SubscribeEvent public static void onReload(final ModConfig.Reloading configEvent) { }
Example #12
Source File: BetterSprintingMod.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
@SubscribeEvent public static void onConfigLoading(final ModConfig.Loading e){ config = new BetterSprintingConfig(e.getConfig()); config.migrate(); }
Example #13
Source File: ClientSettings.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
static void register(ModLoadingContext ctx){ BetterSprintingConfig.register(ctx, ModConfig.Type.CLIENT, configSpec, "client"); }
Example #14
Source File: ServerSettings.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
static void register(ModLoadingContext ctx){ BetterSprintingConfig.register(ctx, ModConfig.Type.COMMON, configSpec, "server"); }
Example #15
Source File: BetterSprintingConfig.java From Better-Sprinting with Mozilla Public License 2.0 | 4 votes |
BetterSprintingConfig(ModConfig config){ this.config = config; }
Example #16
Source File: Config.java From MiningGadgets with MIT License | 2 votes |
@SubscribeEvent public static void onLoad(final ModConfig.Loading configEvent) { }