Class ConfigurationScreen.ConfigurationSectionScreen

java.lang.Object
net.minecraft.client.gui.components.events.AbstractContainerEventHandler
net.minecraft.client.gui.screens.Screen
net.minecraft.client.gui.screens.options.OptionsSubScreen
net.neoforged.neoforge.client.gui.ConfigurationScreen.ConfigurationSectionScreen
All Implemented Interfaces:
net.minecraft.client.gui.components.events.ContainerEventHandler, net.minecraft.client.gui.components.events.GuiEventListener, net.minecraft.client.gui.components.Renderable, net.minecraft.client.gui.components.TabOrderedElement
Direct Known Subclasses:
ConfigurationScreen.ConfigurationListScreen
Enclosing class:
ConfigurationScreen

public static class ConfigurationScreen.ConfigurationSectionScreen extends net.minecraft.client.gui.screens.options.OptionsSubScreen
A UI screen that presents a single section of configuration values and allows the user to edit them, including an unlimited undo system and reset to default.

This class is automatically used if you use NeoForge's generic configuration UI, see ConfigurationScreen.

If you have special needs, you can subclass this class to achieve the desired behaviour. For example:

  • To filter out values that should not be displayed, override the matching create*Value() method and return null when the key matches.
  • To use another UI element, override the matching create*Value() method and return your new UI element wrapped in a ConfigurationScreen.ConfigurationSectionScreen.Element.
  • To change the way lists work, override createList(String, ListValueSpec, ConfigValue) and return a subclassed ConfigurationScreen.ConfigurationListScreen.
  • To add additional (synthetic) config values, override createSyntheticValues().
  • To be notified on each changed value instead of getting one ModConfigEvent at the end, override onChanged(String). Note that onChanged(String) will be called on every change (e.g. each typed character for Strings) if the new value is valid and different.
  • To re-arrange your config values, declare them in the appropriate order.
  • To change which values a config value can accept, supply the ModConfigSpec.Builder with a validator and/or a range.
  • To have your config values display with readable names, add their translations to your language file. When running in a development environment, missing translations are printed out to the log by default. However, you need to visit every configuration screen manually for those to be collected.
    Tooltips are also taken from the language file, but if there's no translation, the comment will be used instead.
Note: This class subclasses vanilla's OptionsSubScreen and inherits some behaviour that is not needed. For example, we need to pass the vanilla options to our superclass' constructor.