Class ConfigurationScreen

All Implemented Interfaces:
ContainerEventHandler, GuiEventListener, Renderable, TabOrderedElement

public final class ConfigurationScreen extends OptionsSubScreen
A generic configuration UI.

This class is the entry point for NeoForge's generic configuration UI. You can use this in two different ways:

  • As an entry point for your custom configuration screen that handles fetching your configs, matching ModConfig.Type to the current game, enforcing level and game restarts, etc.
  • As a ready-made system but extensible that works out of the box with all configs that use the ModConfigSpec system and don't do anything overly weird with it.
For the former one, use the 3-argument constructor
invalid reference
#ConfigurationScreen(ModContainer, Screen, TriFunction)
and return your own screen from the TriFunction. For the latter, use either the 2-argument constructor ConfigurationScreen(ModContainer, Screen) if you don't need to extend the system, or the 3-argument one and return a subclass of ConfigurationScreen.ConfigurationSectionScreen from the TriFunction.

In any case, register your configuration screen in your client mod class like this:

@Mod(value = "examplemod", dist = Dist.CLIENT)
public class ExampleMod {
    public ExampleMod(ModContainer container) {
        container.registerExtensionPoint(IConfigScreenFactory.class, (mc, parent) -> new ConfigurationScreen(container, parent));
    }
}
For extending the system, see the documentation on ConfigurationScreen.ConfigurationSectionScreen.

If you only want to suppress certain elements from being displayed, you can also supply a ConfigurationScreen.ConfigurationSectionScreen.Filter as the third parameter instead of subclassing the whole ConfigurationScreen.ConfigurationSectionScreen.

  • Field Details

    • LANG_PREFIX

      private static final String LANG_PREFIX
      Prefix for static keys the configuration screens use internally.
      See Also:
    • SECTION

      private static final String SECTION
      A wrapper for the labels of buttons that open a new screen. Default: "%s..."
      See Also:
    • SECTION_TEXT

      private static final String SECTION_TEXT
      A default for the labels of buttons that open a new screen. Default: "Edit"
      See Also:
    • CRUMB_SEPARATOR

      public static final Component CRUMB_SEPARATOR
      The breadcrumb separator. Default: "%s > %s"
    • CRUMB

      private static final String CRUMB
      See Also:
    • LIST_ELEMENT

      private static final String LIST_ELEMENT
      The label of list elements. Will be supplied the index into the list. Default: "%s:"
      See Also:
    • RANGE_TOOLTIP

      private static final String RANGE_TOOLTIP
      How the range will be added to the tooltip when using translated tooltips. Mimics what the comment does in ModConfigSpec.
      See Also:
    • RANGE_TOOLTIP_STYLE

      private static final ChatFormatting RANGE_TOOLTIP_STYLE
    • FILENAME_TOOLTIP

      private static final String FILENAME_TOOLTIP
      How the filename will be added to the tooltip.
      See Also:
    • FILENAME_TOOLTIP_STYLE

      private static final ChatFormatting FILENAME_TOOLTIP_STYLE
    • EMPTY_LINE

      private static final MutableComponent EMPTY_LINE
      A literal to create an empty line in a tooltip.
    • TOOLTIP_CANNOT_EDIT_THIS_WHILE_ONLINE

      public static final Component TOOLTIP_CANNOT_EDIT_THIS_WHILE_ONLINE
    • TOOLTIP_CANNOT_EDIT_THIS_WHILE_OPEN_TO_LAN

      public static final Component TOOLTIP_CANNOT_EDIT_THIS_WHILE_OPEN_TO_LAN
    • TOOLTIP_CANNOT_EDIT_NOT_LOADED

      public static final Component TOOLTIP_CANNOT_EDIT_NOT_LOADED
    • NEW_LIST_ELEMENT

      public static final Component NEW_LIST_ELEMENT
    • MOVE_LIST_ELEMENT_UP

      public static final Component MOVE_LIST_ELEMENT_UP
    • MOVE_LIST_ELEMENT_DOWN

      public static final Component MOVE_LIST_ELEMENT_DOWN
    • REMOVE_LIST_ELEMENT

      public static final Component REMOVE_LIST_ELEMENT
    • UNSUPPORTED_ELEMENT

      public static final Component UNSUPPORTED_ELEMENT
    • LONG_STRING

      public static final Component LONG_STRING
    • GAME_RESTART_TITLE

      public static final Component GAME_RESTART_TITLE
    • GAME_RESTART_MESSAGE

      public static final Component GAME_RESTART_MESSAGE
    • GAME_RESTART_YES

      public static final Component GAME_RESTART_YES
    • SERVER_RESTART_TITLE

      public static final Component SERVER_RESTART_TITLE
    • SERVER_RESTART_MESSAGE

      public static final Component SERVER_RESTART_MESSAGE
    • RETURN_TO_MENU

      public static final Component RETURN_TO_MENU
    • SAVING_LEVEL

      public static final Component SAVING_LEVEL
    • RESTART_NO

      public static final Component RESTART_NO
    • RESTART_NO_TOOLTIP

      public static final Component RESTART_NO_TOOLTIP
    • UNDO

      public static final Component UNDO
    • UNDO_TOOLTIP

      public static final Component UNDO_TOOLTIP
    • RESET

      public static final Component RESET
    • RESET_TOOLTIP

      public static final Component RESET_TOOLTIP
    • BIG_BUTTON_WIDTH

      public static final int BIG_BUTTON_WIDTH
      See Also:
    • translationChecker

      protected static final ConfigurationScreen.TranslationChecker translationChecker
    • mod

      protected final net.neoforged.fml.ModContainer mod
    • sectionScreen

      private final PropertyDispatch.QuadFunction<ConfigurationScreen,net.neoforged.fml.config.ModConfig.Type,net.neoforged.fml.config.ModConfig,Component,Screen> sectionScreen
    • needsRestart

      public ModConfigSpec.RestartType needsRestart
    • autoClose

      private boolean autoClose
  • Constructor Details

  • Method Details

    • addOptions

      protected void addOptions()
      Specified by:
      addOptions in class OptionsSubScreen
    • translatableConfig

      public Component translatableConfig(net.neoforged.fml.config.ModConfig modConfig, String suffix, String fallback)
    • added

      public void added()
      Overrides:
      added in class Screen
    • onClose

      public void onClose()
      Overrides:
      onClose in class OptionsSubScreen
    • onDisconnect

      private void onDisconnect()