ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Server specific. When joining a MP server, Client configs are kept but Server configs are synced from the server. Using serialization attributes such as [DefaultValue(5)] or [JsonIgnore] are critical for proper usage of ModConfig. tModLoader also provides its own attributes such as ReloadRequiredAttribute and LabelAttribute.
More...
Inherits ILocalizedModType.
|
virtual bool | AcceptClientChanges (ModConfig pendingConfig, int whoAmI, ref NetworkText message) |
| Called on the Server for ServerSide configs to determine if the changes asked for by the Client will be accepted. Useful for enforcing permissions. Called after a check for NeedsReload. More...
|
|
virtual bool | AcceptClientChanges (ModConfig pendingConfig, int whoAmI, ref string message) |
|
virtual bool | Autoload (ref string name) |
|
virtual ModConfig | Clone () |
| tModLoader will call Clone on ModConfig to facilitate proper implementation of the ModConfig user interface and detecting when a reload is required. Modders need to override this method if their config contains reference types. Failure to do so will lead to bugs. See ModConfigShowcaseDataTypes.Clone for examples and explanations. More...
|
|
virtual bool | NeedsReload (ModConfig pendingConfig) |
| Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute. Unlike the other ModConfig hooks, this method is called on a clone of the ModConfig that was saved during mod loading. The pendingConfig has values that are about to take effect. Neither of these instances necessarily match the instance used in OnLoaded. More...
|
|
virtual void | OnChanged () |
| This hook is called anytime new config values have been set and are ready to take effect. This will always be called right after OnLoaded and anytime new configuration values are ready to be used. The hook won't be called with values that violate NeedsReload. Use this hook to integrate with other code in your Mod to apply the effects of the configuration values. If your NeedsReload is correctly implemented, you should be able to apply the settings without error in this hook. Be aware that this hook can be called in-game and in the main menu, as well as in single player and multiplayer situations.
|
|
virtual void | OnLoaded () |
| This method is called when the ModConfig has been loaded for the first time. This happens before regular Autoloading and Mod.Load. You can use this hook to assign a static reference to this instance for easy access. tModLoader will automatically assign (and later unload) this instance to a static field named Instance in the class prior to calling this method, if it exists.
|
|
|
virtual LocalizedText | DisplayName [get] |
|
string | FullName [get] |
| => $"{Mod.Name}/{Name}" More...
|
|
virtual string | LocalizationCategory [get] |
| The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
|
|
Mod | Mod [get, set] |
| The mod this belongs to. More...
|
|
abstract ConfigScope | Mode [get] |
|
string | Name [get, set] |
| The internal name of this instance. More...
|
|
abstract string | LocalizationCategory [get] |
| The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this. More...
|
|
string | FullName [get] |
| => $"{Mod.Name}/{Name}" More...
|
|
Mod | Mod [get] |
| The mod this belongs to. More...
|
|
string | Name [get] |
| The internal name of this instance. More...
|
|
ModConfig provides a way for mods to be configurable. ModConfigs can either be Client specific or Server specific. When joining a MP server, Client configs are kept but Server configs are synced from the server. Using serialization attributes such as [DefaultValue(5)] or [JsonIgnore] are critical for proper usage of ModConfig. tModLoader also provides its own attributes such as ReloadRequiredAttribute and LabelAttribute.
◆ AcceptClientChanges()
virtual bool ModConfig.AcceptClientChanges |
( |
ModConfig |
pendingConfig, |
|
|
int |
whoAmI, |
|
|
ref NetworkText |
message |
|
) |
| |
|
virtual |
Called on the Server for ServerSide configs to determine if the changes asked for by the Client will be accepted. Useful for enforcing permissions. Called after a check for NeedsReload.
- Parameters
-
pendingConfig | An instance of the ModConfig with the attempted changes |
whoAmI | The client whoAmI |
message | A message that will be returned to the client, set this to the reason the server rejects the changes. |
- Returns
- Return false to reject client changes
◆ Clone()
tModLoader will call Clone on ModConfig to facilitate proper implementation of the ModConfig user interface and detecting when a reload is required. Modders need to override this method if their config contains reference types. Failure to do so will lead to bugs. See ModConfigShowcaseDataTypes.Clone for examples and explanations.
- Returns
◆ NeedsReload()
virtual bool ModConfig.NeedsReload |
( |
ModConfig |
pendingConfig | ) |
|
|
virtual |
Whether or not a reload is required. The default implementation compares properties and fields annotated with the ReloadRequiredAttribute. Unlike the other ModConfig hooks, this method is called on a clone of the ModConfig that was saved during mod loading. The pendingConfig has values that are about to take effect. Neither of these instances necessarily match the instance used in OnLoaded.
- Parameters
-
pendingConfig | The other instance of ModConfig to compare against, it contains the values that are pending to take effect |
- Returns
◆ FullName
string ModConfig.FullName |
|
get |
=> $"{Mod.Name}/{Name}"
Implements IModType.
◆ LocalizationCategory
virtual string ModConfig.LocalizationCategory |
|
get |
The category used by this modded content for use in localization keys. Localization keys follow the pattern of "Mods.{ModName}.{Category}.{ContentName}.{DataName}". The Localization wiki pageexplains how custom ModType classes can utilize this.
Implements ILocalizedModType.
◆ Mod
The mod this belongs to.
Implements IModType.
◆ Name
The internal name of this instance.
Implements IModType.