Package net.uku3lig.ukulib.config.screen
Class BaseConfigScreen<T extends Serializable>
java.lang.Object
net.minecraft.client.gui.components.events.AbstractContainerEventHandler
net.minecraft.client.gui.screens.Screen
net.uku3lig.ukulib.config.screen.CloseableScreen
net.uku3lig.ukulib.config.screen.BaseConfigScreen<T>
- Type Parameters:
T- The type of the config class
- 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:
AbstractConfigScreen,TabbedConfigScreen
Simple abstract class which provides utilities for config screens
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.client.gui.screens.Screen
net.minecraft.client.gui.screens.Screen.NarratableSearchResult -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected net.minecraft.client.gui.components.ButtonDone button, closes the screenprotected final org.slf4j.LoggerSLF4J Loggerprotected final ConfigManager<T> The config managerprotected net.minecraft.client.gui.components.ButtonReset button, resets the config to its default stateFields inherited from class net.uku3lig.ukulib.config.screen.CloseableScreen
parentFields inherited from class net.minecraft.client.gui.screens.Screen
FADE_IN_TIME, font, FOOTER_SEPARATOR, HEADER_SEPARATOR, height, INWORLD_FOOTER_SEPARATOR, INWORLD_HEADER_SEPARATOR, MENU_BACKGROUND, minecraft, narratorButton, screenExecutor, title, width -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseConfigScreen(String key, net.minecraft.client.gui.screens.Screen parent, ConfigManager<T> manager) Constructs the screen -
Method Summary
Modifier and TypeMethodDescriptionprotected <R> RapplyConfigChecked(Function<T, R> mapper, R defaultValue) Tries to apply the current config to a function (eg.protected Collection<net.minecraft.client.gui.components.AbstractWidget> Finds invalid options in the config screen.protected voidinit()voidremoved()voidtick()Methods inherited from class net.uku3lig.ukulib.config.screen.CloseableScreen
onCloseMethods inherited from class net.minecraft.client.gui.screens.Screen
added, addRenderableOnly, addRenderableWidget, addWidget, afterKeyboardAction, afterMouseAction, afterMouseMove, canInterruptWithAnotherScreen, changeFocus, children, clearFocus, clearWidgets, clickCommandAction, clickUrlAction, defaultHandleClickEvent, defaultHandleGameClickEvent, fadeWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleDelayedNarration, init, insertText, isAllowedInPortal, isInGameUi, isMouseOver, isPauseScreen, isValidCharacterForName, keyPressed, onFilesDrop, panoramaShouldSpin, rebuildWidgets, removeWidget, render, renderBackground, renderBlurredBackground, renderMenuBackground, renderMenuBackground, renderMenuBackgroundTexture, renderPanorama, renderTransparentBackground, renderWithTooltipAndSubtitles, repositionElements, resize, setInitialFocus, setInitialFocus, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, 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, mouseMoved, shouldTakeFocusAfterInteractionMethods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
manager
The config manager -
log
protected final org.slf4j.Logger logSLF4J Logger -
doneButton
protected net.minecraft.client.gui.components.Button doneButtonDone button, closes the screen -
resetButton
protected net.minecraft.client.gui.components.Button resetButtonReset button, resets the config to its default state
-
-
Constructor Details
-
BaseConfigScreen
protected BaseConfigScreen(String key, net.minecraft.client.gui.screens.Screen parent, ConfigManager<T> manager) Constructs the screen- Parameters:
key- The translation key of the titleparent- The parent screenmanager- The config manager
-
-
Method Details
-
applyConfigChecked
Tries to apply the current config to a function (eg.getWidgets). If an exception is thrown, the config is first reset and applied again, and if it fails a second time, a notice is shown to the end user. This is mainly useful to preventNullPointerExceptions.Example:
buttonList.addAll(applyConfigChecked(this::getWidgets, new WidgetCreator[0]))- Type Parameters:
R- The type of the return value of the applied function- Parameters:
mapper- The function that needs a configdefaultValue- The default value, in case the config is broken. Only here to avoid returning null.- Returns:
- The result of the function, if the config is working
-
init
protected void init()- Overrides:
initin classnet.minecraft.client.gui.screens.Screen
-
tick
public void tick()- Overrides:
tickin classnet.minecraft.client.gui.screens.Screen
-
getInvalidOptions
Finds invalid options in the config screen. Called once every tick.- Returns:
- The collection of invalid options.
-
removed
public void removed()- Overrides:
removedin classnet.minecraft.client.gui.screens.Screen
-