Class BaseConfigScreen<T extends Serializable>

java.lang.Object
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.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.Drawable, net.minecraft.client.gui.Element, net.minecraft.client.gui.navigation.Navigable, net.minecraft.client.gui.ParentElement
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.screen.Screen

    net.minecraft.client.gui.screen.Screen.SelectedElementNarrationData
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.slf4j.Logger
    SLF4J Logger
    protected final ConfigManager<T>
    The config manager

    Fields inherited from class net.uku3lig.ukulib.config.screen.CloseableScreen

    parent

    Fields inherited from class net.minecraft.client.gui.screen.Screen

    client, executor, FOOTER_SEPARATOR_TEXTURE, HEADER_SEPARATOR_TEXTURE, height, INWORLD_FOOTER_SEPARATOR_TEXTURE, INWORLD_HEADER_SEPARATOR_TEXTURE, MENU_BACKGROUND_TEXTURE, narratorToggleButton, PANORAMA_RENDERER, ROTATING_PANORAMA_RENDERER, textRenderer, title, width

    Fields inherited from interface net.minecraft.client.gui.Element

    MAX_DOUBLE_CLICK_INTERVAL
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    BaseConfigScreen(String key, net.minecraft.client.gui.screen.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.widget.ClickableWidget>
    Finds invalid options in the config screen.
    protected void
     
    void
     
    void
     

    Methods inherited from class net.uku3lig.ukulib.config.screen.CloseableScreen

    close

    Methods inherited from class net.minecraft.client.gui.screen.Screen

    addDrawable, addDrawableChild, addElementNarrations, addScreenNarrations, addSelectableChild, applyBlur, applyKeyPressNarratorDelay, applyMouseMoveNarratorDelay, applyMousePressScrollNarratorDelay, blur, children, clearAndInit, clearChildren, clearTooltip, filesDragged, findSelectedElementData, getMusic, getNarratedTitle, getNavigationFocus, getTitle, getTooltipFromItem, getUsageNarrationText, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, hasUsageText, init, initTabNavigation, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, keyPressed, narrateScreenIfNarrationEnabled, onDisplayed, refreshNarrator, remove, render, renderBackground, renderBackgroundTexture, renderDarkening, renderDarkening, renderInGameBackground, renderPanoramaBackground, renderWithTooltip, resize, setInitialFocus, setInitialFocus, setTooltip, setTooltip, setTooltip, setTooltip, shouldCloseOnEsc, shouldPause, switchFocus, updateNarrator, wrapScreenError

    Methods inherited from class net.minecraft.client.gui.AbstractParentElement

    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.Element

    mouseMoved

    Methods inherited from interface net.minecraft.client.gui.navigation.Navigable

    getNavigationOrder

    Methods inherited from interface net.minecraft.client.gui.ParentElement

    charTyped, getFocusedPath, getNavigationPath, hoveredElement, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, setFocused
  • Field Details

    • manager

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

      protected final org.slf4j.Logger log
      SLF4J Logger
  • Constructor Details

    • BaseConfigScreen

      protected BaseConfigScreen(String key, net.minecraft.client.gui.screen.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.screen.Screen
    • tick

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

      protected Collection<net.minecraft.client.gui.widget.ClickableWidget> 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.screen.Screen