Class ConfigurationScreen
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
- All Implemented Interfaces:
ContainerEventHandler,GuiEventListener,Renderable,TabOrderedElement
A generic configuration UI.
For extending the system, see the documentation on
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.Typeto 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
ModConfigSpecsystem and don't do anything overly weird with it.
ConfigurationScreen(ModContainer, Screen, Function4) and return your own screen from the Function4. 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 Function4.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));
}
}
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA UI screen that presents a list-type configuration value and allows the user to edit it, including an unlimited undo system and reset to default.static classA 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.private static final classstatic classstatic final classA class representing an undo/redo buffer.Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
Screen.NarratableSearchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanstatic final intprivate static final Stringstatic final ComponentThe breadcrumb separator.private static final MutableComponentA literal to create an empty line in a tooltip.private static final StringHow the filename will be added to the tooltip.private static final ChatFormattingstatic final Componentstatic final Componentstatic final Componentprivate static final StringPrefix for static keys the configuration screens use internally.private static final StringThe label of list elements.static final Componentprotected final net.neoforged.fml.ModContainerstatic final Componentstatic final Componentstatic final Componentprivate static final StringHow the range will be added to the tooltip when using translated tooltips.private static final ChatFormattingstatic final Componentstatic final Componentstatic final Componentstatic final Componentstatic final Componentstatic final Componentstatic final Componentprivate static final StringA wrapper for the labels of buttons that open a new screen.private static final StringA default for the labels of buttons that open a new screen.private final com.mojang.datafixers.util.Function4<ConfigurationScreen, net.neoforged.fml.config.ModConfig.Type, net.neoforged.fml.config.ModConfig, Component, Screen> static final Componentstatic final Componentstatic final Componentstatic final Componentstatic final Componentprotected static final ConfigurationScreen.TranslationCheckerstatic final Componentstatic final Componentstatic final ComponentFields inherited from class net.minecraft.client.gui.screens.options.OptionsSubScreen
lastScreen, layout, list, optionsFields inherited from class net.minecraft.client.gui.screens.Screen
CUBE_MAP, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, PANORAMA, renderables, screenExecutor, title, widthFields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationScreen(net.neoforged.fml.ModContainer mod, Screen parent) ConfigurationScreen(net.neoforged.fml.ModContainer mod, Screen parent, com.mojang.datafixers.util.Function4<ConfigurationScreen, net.neoforged.fml.config.ModConfig.Type, net.neoforged.fml.config.ModConfig, Component, Screen> sectionScreen) ConfigurationScreen(net.neoforged.fml.ModContainer mod, Screen parent, ConfigurationScreen.ConfigurationSectionScreen.Filter filter) -
Method Summary
Modifier and TypeMethodDescriptionvoidadded()protected voidvoidonClose()private voidtranslatableConfig(net.neoforged.fml.config.ModConfig modConfig, String suffix, String fallback) Methods inherited from class net.minecraft.client.gui.screens.options.OptionsSubScreen
addContents, addFooter, addTitle, init, removed, repositionElementsMethods inherited from class net.minecraft.client.gui.screens.Screen
addRenderableOnly, addRenderableWidget, addWidget, afterKeyboardAction, afterMouseAction, afterMouseMove, changeFocus, children, clearFocus, clearTooltipForNextRenderPass, clearWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getMinecraft, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleComponentClicked, handleDelayedNarration, hasAltDown, hasControlDown, hasShiftDown, init, insertText, isCopy, isCut, isMouseOver, isPaste, isPauseScreen, isSelectAll, isValidCharacterForName, keyPressed, onFilesDrop, rebuildWidgets, removeWidget, render, renderBackground, renderBlurredBackground, renderMenuBackground, renderMenuBackground, renderMenuBackgroundTexture, renderPanorama, renderTransparentBackground, renderWithTooltip, resize, setInitialFocus, setInitialFocus, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, setTooltipForNextRenderPass, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, tick, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatusMethods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocusedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, setFocusedMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getBorderForArrowNavigation, mouseMovedMethods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
LANG_PREFIX
Prefix for static keys the configuration screens use internally.- See Also:
-
SECTION
A wrapper for the labels of buttons that open a new screen. Default: "%s..."- See Also:
-
SECTION_TEXT
A default for the labels of buttons that open a new screen. Default: "Edit"- See Also:
-
CRUMB_SEPARATOR
The breadcrumb separator. Default: "%s > %s" -
CRUMB
- See Also:
-
LIST_ELEMENT
The label of list elements. Will be supplied the index into the list. Default: "%s:"- See Also:
-
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
-
FILENAME_TOOLTIP
How the filename will be added to the tooltip.- See Also:
-
FILENAME_TOOLTIP_STYLE
-
EMPTY_LINE
A literal to create an empty line in a tooltip. -
TOOLTIP_CANNOT_EDIT_THIS_WHILE_ONLINE
-
TOOLTIP_CANNOT_EDIT_THIS_WHILE_OPEN_TO_LAN
-
TOOLTIP_CANNOT_EDIT_NOT_LOADED
-
NEW_LIST_ELEMENT
-
MOVE_LIST_ELEMENT_UP
-
MOVE_LIST_ELEMENT_DOWN
-
REMOVE_LIST_ELEMENT
-
UNSUPPORTED_ELEMENT
-
LONG_STRING
-
GAME_RESTART_TITLE
-
GAME_RESTART_MESSAGE
-
GAME_RESTART_YES
-
SERVER_RESTART_TITLE
-
SERVER_RESTART_MESSAGE
-
RETURN_TO_MENU
-
SAVING_LEVEL
-
RESTART_NO
-
RESTART_NO_TOOLTIP
-
UNDO
-
UNDO_TOOLTIP
-
RESET
-
RESET_TOOLTIP
-
BIG_BUTTON_WIDTH
public static final int BIG_BUTTON_WIDTH- See Also:
-
translationChecker
-
mod
protected final net.neoforged.fml.ModContainer mod -
sectionScreen
private final com.mojang.datafixers.util.Function4<ConfigurationScreen,net.neoforged.fml.config.ModConfig.Type, sectionScreennet.neoforged.fml.config.ModConfig, Component, Screen> -
needsRestart
-
autoClose
private boolean autoClose
-
-
Constructor Details
-
ConfigurationScreen
-
ConfigurationScreen
public ConfigurationScreen(net.neoforged.fml.ModContainer mod, Screen parent, ConfigurationScreen.ConfigurationSectionScreen.Filter filter) -
ConfigurationScreen
public ConfigurationScreen(net.neoforged.fml.ModContainer mod, Screen parent, com.mojang.datafixers.util.Function4<ConfigurationScreen, net.neoforged.fml.config.ModConfig.Type, net.neoforged.fml.config.ModConfig, Component, Screen> sectionScreen)
-
-
Method Details
-
addOptions
protected void addOptions()- Specified by:
addOptionsin classOptionsSubScreen
-
translatableConfig
-
added
public void added() -
onClose
public void onClose()- Overrides:
onClosein classOptionsSubScreen
-
onDisconnect
private void onDisconnect()
-