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

public abstract class BaseConfigScreen<T extends Serializable> extends CloseableScreen
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

    Fields
    Modifier and Type
    Field
    Description
    protected net.minecraft.client.gui.components.Button
    Done button, closes the screen
    protected final org.slf4j.Logger
    SLF4J Logger
    protected final ConfigManager<T>
    The config manager
    protected net.minecraft.client.gui.components.Button
    Reset button, resets the config to its default state

    Fields inherited from class CloseableScreen

    parent

    Fields 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

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseConfigScreen(String key, net.minecraft.client.gui.screens.Screen parent, ConfigManager<T> manager)
    Constructs the screen
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <R> R
    applyConfigChecked(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 void
     
    void
     
    void
     

    Methods inherited from class CloseableScreen

    onClose

    Methods 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, extractBackground, extractBlurredBackground, extractMenuBackground, extractMenuBackground, extractMenuBackgroundTexture, extractPanorama, extractRenderState, extractRenderStateWithTooltipAndSubtitles, extractTransparentBackground, fadeWidgets, fillCrashDetails, findNarratableWidget, getBackgroundMusic, getFont, getNarrationMessage, getRectangle, getTitle, getTooltipFromItem, getUsageNarration, handleDelayedNarration, init, insertText, isAllowedInPortal, isInGameUi, isMouseOver, isPauseScreen, isValidCharacterForName, keyPressed, onFilesDrop, panoramaShouldSpin, rebuildWidgets, removeWidget, repositionElements, resize, setInitialFocus, setInitialFocus, shouldCloseOnEsc, shouldNarrateNavigation, showsActiveEffects, triggerImmediateNarration, updateNarratedWidget, updateNarrationState, updateNarratorStatus

    Methods inherited from class net.minecraft.client.gui.components.events.AbstractContainerEventHandler

    getFocused, isDragging, setDragging, setFocused

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraft.client.gui.components.events.ContainerEventHandler

    charTyped, getBorderForArrowNavigation, getChildAt, getCurrentFocusPath, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, nextFocusPath, preeditUpdated, setFocused

    Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener

    mouseMoved, shouldTakeFocusAfterInteraction

    Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement

    getTabOrderGroup
  • Field Details

    • manager

      protected final ConfigManager<T extends Serializable> manager
      The config manager
    • log

      protected final org.slf4j.Logger log
      SLF4J Logger
    • doneButton

      protected net.minecraft.client.gui.components.Button doneButton
      Done button, closes the screen
    • resetButton

      protected net.minecraft.client.gui.components.Button resetButton
      Reset 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 title
      parent - The parent screen
      manager - The config manager
  • Method Details

    • applyConfigChecked

      protected <R> R applyConfigChecked(Function<T,R> mapper, R defaultValue)
      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 prevent NullPointerExceptions.

      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 config
      defaultValue - 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:
      init in class net.minecraft.client.gui.screens.Screen
    • tick

      public void tick()
      Overrides:
      tick in class net.minecraft.client.gui.screens.Screen
    • getInvalidOptions

      protected Collection<net.minecraft.client.gui.components.AbstractWidget> getInvalidOptions()
      Finds invalid options in the config screen. Called once every tick.
      Returns:
      The collection of invalid options.
    • removed

      public void removed()
      Overrides:
      removed in class net.minecraft.client.gui.screens.Screen