Wiki 9Minecraft Forge Config API Port Mod Wiki

Forge Config API Port Mod — Guide

Mechanics

The mod operates by implementing the Forge configuration specification within the Fabric environment. It relies on the NightConfig library to handle the reading and writing of configuration files.

Configuration Files

All configurations generated by this API use the TOML (Tom's Obvious, Minimal Language) format. These files are typically stored in the .minecraft/config/ directory. The API ensures that comments, default values, and range constraints defined in the code are correctly reflected in the generated TOML files.

Synchronization

The API handles the complex task of synchronizing configuration values between the server and the client. This is crucial for gameplay-altering settings (Server-side configs) that must be consistent for all players on a server to prevent desynchronization or cheating.

Developer Integration

For developers, the mod provides a familiar workflow identical to the native Forge environment. The core components used are ForgeConfigSpec and ModLoadingContext.

Registration Process

To register a configuration, a developer typically creates a ForgeConfigSpec using a Builder and then registers it during the mod's initialization phase.

Example Registration Structure: 1. Define the Spec: Use ForgeConfigSpec.Builder to define values, ranges, and comments. 2. Register: Call ModLoadingContext.registerConfig with the appropriate ModConfig.Type. 3. Access: Use the defined ConfigValue objects to retrieve settings during runtime.

Package Parity

To ensure maximum compatibility, the mod uses the exact same package paths as the original API: * net.minecraftforge.common.ForgeConfigSpec * net.minecraftforge.fml.config.ModConfig * net.neoforged.fml.config.IConfigSpec (in newer versions)

Technical Specifications

Requirements

To function correctly on the Fabric loader, the following dependencies must be present: * Fabric API: The standard library for Fabric mods.

Compatibility

The mod is designed to be "invisible" on Forge and NeoForge. If a mod using this library is installed on Forge, the library detects the native Forge Config API and stays dormant, allowing the native system to take over. This ensures that a single mod JAR can be distributed for all loaders without causing conflicts.

Items, Blocks, and Mobs

As a technical library mod, the Forge Config API Port does not add any gameplay content. It contains: * No Mobs or Creatures * No Items or Tools * No Blocks or Structures * No Biomes or Dimensions

Its sole purpose is to provide the underlying framework that other mods use to create their own configurable items, blocks, and mechanics.