Class ColorSelectScreen

java.lang.Object
net.minecraft.client.gui.AbstractParentElement
net.minecraft.client.gui.screen.Screen
All Implemented Interfaces:
net.minecraft.client.gui.Drawable, net.minecraft.client.gui.Element, net.minecraft.client.gui.navigation.Navigable, net.minecraft.client.gui.ParentElement

public class ColorSelectScreen extends TextInputScreen<Integer>
A color selection screen.
  • 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
    static final int
    Constant for full alpha (255) with no color.

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

    parent

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

    client, executor, height, OPTIONS_BACKGROUND_TEXTURE, textRenderer, title, width

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

    MAX_DOUBLE_CLICK_INTERVAL
  • Constructor Summary

    Constructors
    Constructor
    Description
    ColorSelectScreen(net.minecraft.text.Text title, net.minecraft.client.gui.screen.Screen parent, Consumer<Integer> callback, int last, ConfigManager<?> manager)
    Creates a color selection screen.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    Sets if alpha is allowed along with the RGB color.
    convert(String value)
    Converts the contents of the text field to the type needed.
    protected byte
    The default alpha value for the color.
    format(Integer value)
    Formats the raw value to a String.
    protected void
     
    void
    render(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float delta)
     
    protected void
    renderColor(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float delta, int color)
    Renders the selected color on the screen

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

    getTextField, onTextChange, removed

    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, applyKeyPressNarratorDelay, applyMouseMoveNarratorDelay, applyMousePressScrollNarratorDelay, applyNarratorModeChangeDelay, children, clearAndInit, clearChildren, filesDragged, findSelectedElementData, getMusic, getNarratedTitle, getNavigationFocus, getTitle, getTooltipFromItem, handleTextClick, hasAltDown, hasControlDown, hasShiftDown, hasUsageText, hide, init, initTabNavigation, insertText, isCopy, isCut, isMouseOver, isPaste, isSelectAll, isValidCharacterForName, keyPressed, narrateScreenIfNarrationEnabled, onDisplayed, remove, renderBackground, renderBackgroundTexture, renderWithTooltip, resize, setInitialFocus, setTooltip, setTooltip, setTooltip, setTooltip, shouldCloseOnEsc, shouldPause, switchFocus, tick, 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, focusOn, getFocusedPath, getNavigationPath, hoveredElement, isFocused, keyReleased, mouseClicked, mouseDragged, mouseReleased, mouseScrolled, setFocused
  • Field Details

    • FULL_ALPHA

      public static final int FULL_ALPHA
      Constant for full alpha (255) with no color.
      Can be used like this: color |= FULL_ALPHA.
      See Also:
  • Constructor Details

    • ColorSelectScreen

      public ColorSelectScreen(net.minecraft.text.Text title, net.minecraft.client.gui.screen.Screen parent, Consumer<Integer> callback, int last, ConfigManager<?> manager)
      Creates a color selection screen.
      Parameters:
      title - The title of the screen
      parent - The parent screen
      callback - The action to be done after the screen is closed
      last - The last known color
      manager - The config manager
  • Method Details

    • init

      protected void init()
      Overrides:
      init in class TextInputScreen<Integer>
    • render

      public void render(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float delta)
      Specified by:
      render in interface net.minecraft.client.gui.Drawable
      Overrides:
      render in class TextInputScreen<Integer>
    • renderColor

      protected void renderColor(net.minecraft.client.gui.DrawContext drawContext, int mouseX, int mouseY, float delta, int color)
      Renders the selected color on the screen
      Parameters:
      drawContext - The drawable helper
      mouseX - The x position of the mouse
      mouseY - The y position of the mouse
      delta - The time delta
      color - The chosen color
    • allowAlpha

      protected boolean allowAlpha()
      Sets if alpha is allowed along with the RGB color.
      Returns:
      true if allowed, false otherwise
    • defaultAlpha

      protected byte defaultAlpha()
      The default alpha value for the color. Default disables alpha.
      Returns:
      The default alpha value
    • convert

      public Optional<Integer> convert(String value)
      Description copied from class: TextInputScreen
      Converts the contents of the text field to the type needed.
      Specified by:
      convert in class TextInputScreen<Integer>
      Parameters:
      value - The value of the text field, given by the user
      Returns:
      An empty optional is the value is incorrect, else the converted value
    • format

      public String format(Integer value)
      Description copied from class: TextInputScreen
      Formats the raw value to a String. Useful when String#valueOf doesn't yield the correct result.
      Overrides:
      format in class TextInputScreen<Integer>
      Parameters:
      value - The value to format
      Returns:
      A string representation of the value