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:
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
public final class ConfigurationScreen
extends net.minecraft.client.gui.screens.options.OptionsSubScreen
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.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.
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 class
A 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 class
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.private static final class
static class
static final class
A class representing an undo/redo buffer.Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
net.minecraft.client.gui.screens.Screen.NarratableSearchResult
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
static final int
private static final String
static final net.minecraft.network.chat.Component
The breadcrumb separator.private static final net.minecraft.network.chat.MutableComponent
A literal to create an empty line in a tooltip.private static final String
How the filename will be added to the tooltip.private static final net.minecraft.ChatFormatting
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
private static final String
Prefix for static keys the configuration screens use internally.private static final String
The label of list elements.static final net.minecraft.network.chat.Component
protected final net.neoforged.fml.ModContainer
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
private static final String
How the range will be added to the tooltip when using translated tooltips.private static final net.minecraft.ChatFormatting
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
private static final String
A wrapper for the labels of buttons that open a new screen.private static final String
A 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, net.minecraft.network.chat.Component, net.minecraft.client.gui.screens.Screen> static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
protected static final ConfigurationScreen.TranslationChecker
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
static final net.minecraft.network.chat.Component
Fields inherited from class net.minecraft.client.gui.screens.options.OptionsSubScreen
lastScreen, layout, list, options
Fields 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, width
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
ConstructorsConstructorDescriptionConfigurationScreen
(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent) ConfigurationScreen
(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent, com.mojang.datafixers.util.Function4<ConfigurationScreen, net.neoforged.fml.config.ModConfig.Type, net.neoforged.fml.config.ModConfig, net.minecraft.network.chat.Component, net.minecraft.client.gui.screens.Screen> sectionScreen) ConfigurationScreen
(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent, ConfigurationScreen.ConfigurationSectionScreen.Filter filter) -
Method Summary
Modifier and TypeMethodDescriptionvoid
added()
protected void
void
onClose()
private void
net.minecraft.network.chat.Component
translatableConfig
(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, repositionElements
Methods 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, updateNarratorStatus
Methods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler
getFocused, isDragging, setDragging, setFocused
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler
charTyped, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, setFocused
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getBorderForArrowNavigation, mouseMoved
Methods 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
public static final net.minecraft.network.chat.Component CRUMB_SEPARATORThe 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
private static final net.minecraft.ChatFormatting RANGE_TOOLTIP_STYLE -
FILENAME_TOOLTIP
How the filename will be added to the tooltip.- See Also:
-
FILENAME_TOOLTIP_STYLE
private static final net.minecraft.ChatFormatting FILENAME_TOOLTIP_STYLE -
EMPTY_LINE
private static final net.minecraft.network.chat.MutableComponent EMPTY_LINEA literal to create an empty line in a tooltip. -
TOOLTIP_CANNOT_EDIT_THIS_WHILE_ONLINE
public static final net.minecraft.network.chat.Component TOOLTIP_CANNOT_EDIT_THIS_WHILE_ONLINE -
TOOLTIP_CANNOT_EDIT_THIS_WHILE_OPEN_TO_LAN
public static final net.minecraft.network.chat.Component TOOLTIP_CANNOT_EDIT_THIS_WHILE_OPEN_TO_LAN -
TOOLTIP_CANNOT_EDIT_NOT_LOADED
public static final net.minecraft.network.chat.Component TOOLTIP_CANNOT_EDIT_NOT_LOADED -
NEW_LIST_ELEMENT
public static final net.minecraft.network.chat.Component NEW_LIST_ELEMENT -
MOVE_LIST_ELEMENT_UP
public static final net.minecraft.network.chat.Component MOVE_LIST_ELEMENT_UP -
MOVE_LIST_ELEMENT_DOWN
public static final net.minecraft.network.chat.Component MOVE_LIST_ELEMENT_DOWN -
REMOVE_LIST_ELEMENT
public static final net.minecraft.network.chat.Component REMOVE_LIST_ELEMENT -
UNSUPPORTED_ELEMENT
public static final net.minecraft.network.chat.Component UNSUPPORTED_ELEMENT -
LONG_STRING
public static final net.minecraft.network.chat.Component LONG_STRING -
GAME_RESTART_TITLE
public static final net.minecraft.network.chat.Component GAME_RESTART_TITLE -
GAME_RESTART_MESSAGE
public static final net.minecraft.network.chat.Component GAME_RESTART_MESSAGE -
GAME_RESTART_YES
public static final net.minecraft.network.chat.Component GAME_RESTART_YES -
SERVER_RESTART_TITLE
public static final net.minecraft.network.chat.Component SERVER_RESTART_TITLE -
SERVER_RESTART_MESSAGE
public static final net.minecraft.network.chat.Component SERVER_RESTART_MESSAGE -
RETURN_TO_MENU
public static final net.minecraft.network.chat.Component RETURN_TO_MENU -
SAVING_LEVEL
public static final net.minecraft.network.chat.Component SAVING_LEVEL -
RESTART_NO
public static final net.minecraft.network.chat.Component RESTART_NO -
RESTART_NO_TOOLTIP
public static final net.minecraft.network.chat.Component RESTART_NO_TOOLTIP -
UNDO
public static final net.minecraft.network.chat.Component UNDO -
UNDO_TOOLTIP
public static final net.minecraft.network.chat.Component UNDO_TOOLTIP -
RESET
public static final net.minecraft.network.chat.Component RESET -
RESET_TOOLTIP
public static final net.minecraft.network.chat.Component 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, net.minecraft.network.chat.Component, net.minecraft.client.gui.screens.Screen> -
needsRestart
-
autoClose
private boolean autoClose
-
-
Constructor Details
-
ConfigurationScreen
public ConfigurationScreen(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent) -
ConfigurationScreen
public ConfigurationScreen(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent, ConfigurationScreen.ConfigurationSectionScreen.Filter filter) -
ConfigurationScreen
public ConfigurationScreen(net.neoforged.fml.ModContainer mod, net.minecraft.client.gui.screens.Screen parent, com.mojang.datafixers.util.Function4<ConfigurationScreen, net.neoforged.fml.config.ModConfig.Type, net.neoforged.fml.config.ModConfig, net.minecraft.network.chat.Component, net.minecraft.client.gui.screens.Screen> sectionScreen)
-
-
Method Details
-
addOptions
protected void addOptions()- Specified by:
addOptions
in classnet.minecraft.client.gui.screens.options.OptionsSubScreen
-
translatableConfig
-
added
public void added()- Overrides:
added
in classnet.minecraft.client.gui.screens.Screen
-
onClose
public void onClose()- Overrides:
onClose
in classnet.minecraft.client.gui.screens.options.OptionsSubScreen
-
onDisconnect
private void onDisconnect()
-