Class Ukutils

java.lang.Object
net.uku3lig.ukulib.utils.Ukutils

public class Ukutils extends Object
Simple class for various utilities.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    Simple 2-tuple.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.text.Text
    Placeholder for button text.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.client.option.Option
    createButton(String key, Object value, Consumer<net.minecraft.client.gui.screen.Screen> callback)
    Creates a Option which acts as a simple button.
    static net.minecraft.client.option.Option
    createButton(String key, Consumer<net.minecraft.client.gui.screen.Screen> callback)
    Creates a Option which acts as a simple button.
    static net.minecraft.client.option.Option
    createButton(String key, net.minecraft.text.Text text, Consumer<net.minecraft.client.gui.screen.Screen> callback)
    Creates a Option which acts as a simple button.
    static net.minecraft.client.option.Option
    createOpenButton(String key, Object value, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
    Creates an Option which acts as a simple button that opens a screen when clicked.
    static net.minecraft.client.option.Option
    createOpenButton(String key, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
    Creates a Option which acts as a simple that opens a screen when clicked.
    static net.minecraft.client.option.Option
    createOpenButton(String key, net.minecraft.text.Text text, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
    Creates a Option which acts as a simple button that opens a screen when clicked.
    static net.minecraft.client.gui.widget.ButtonWidget
    doneButton(int width, int height, net.minecraft.client.gui.screen.Screen parent)
    Creates a done button.
    getTextCoords(net.minecraft.text.Text text, int screenWidth, net.minecraft.client.font.TextRenderer textRenderer, int x, int y)
    Makes text coordinates based on the position of a standard 16x16 icon.
    getTextCoords(net.minecraft.text.Text text, int screenWidth, net.minecraft.client.font.TextRenderer textRenderer, int x, int y, int width, int height)
    Makes text coordinates based on the position of an icon.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BUTTON_PLACEHOLDER

      public static final net.minecraft.text.Text BUTTON_PLACEHOLDER
      Placeholder for button text.
  • Method Details

    • createButton

      public static net.minecraft.client.option.Option createButton(String key, Object value, Consumer<net.minecraft.client.gui.screen.Screen> callback)
      Creates a Option which acts as a simple button. Equivalent to createButton(key, Text.of(String.valueOf(value)), callback).
      Parameters:
      key - The translation key of the button text
      value - The value to be displayed after the colon
      callback - The action to be performed when the button is clicked
      Returns:
      The generated option
      See Also:
    • createButton

      public static net.minecraft.client.option.Option createButton(String key, Consumer<net.minecraft.client.gui.screen.Screen> callback)
      Creates a Option which acts as a simple button.
      Parameters:
      key - The translation key of the button text
      callback - The action to be performed when the button is clicked
      Returns:
      The generated option
      See Also:
    • createButton

      public static net.minecraft.client.option.Option createButton(String key, net.minecraft.text.Text text, Consumer<net.minecraft.client.gui.screen.Screen> callback)
      Creates a Option which acts as a simple button.
      Parameters:
      key - The translation key of the button text
      text - The text to be displayed after the colon
      callback - The action to be performed when the button is clicked
      Returns:
      The generated option
    • createOpenButton

      public static net.minecraft.client.option.Option createOpenButton(String key, Object value, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
      Creates an Option which acts as a simple button that opens a screen when clicked. Equivalent to createOpenButton(key, Text.of(String.valueOf(value)), callback).
      Parameters:
      key - The translation key of the button text
      value - The value to be displayed after the colon
      callback - The getter for the screen to be opened when the button is clicked
      Returns:
      The generated option
      See Also:
    • createOpenButton

      public static net.minecraft.client.option.Option createOpenButton(String key, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
      Creates a Option which acts as a simple that opens a screen when clicked.
      Parameters:
      key - The translation key of the button text
      callback - The getter for the screen to be opened when the button is clicked
      Returns:
      The generated option
      See Also:
    • createOpenButton

      public static net.minecraft.client.option.Option createOpenButton(String key, net.minecraft.text.Text text, UnaryOperator<net.minecraft.client.gui.screen.Screen> callback)
      Creates a Option which acts as a simple button that opens a screen when clicked.
      Parameters:
      key - The translation key of the button text
      text - The text to be displayed after the colon
      callback - The getter for the screen to be opened when the button is clicked
      Returns:
      The generated option
    • doneButton

      public static net.minecraft.client.gui.widget.ButtonWidget doneButton(int width, int height, net.minecraft.client.gui.screen.Screen parent)
      Creates a done button.
      Parameters:
      width - The width of the screen
      height - The height of the screen
      parent - The parent screen
      Returns:
      The generated button
    • getTextCoords

      public static Ukutils.Tuple2<Integer,Integer> getTextCoords(net.minecraft.text.Text text, int screenWidth, net.minecraft.client.font.TextRenderer textRenderer, int x, int y, int width, int height)
      Makes text coordinates based on the position of an icon.
      Parameters:
      text - The text to be drawn
      screenWidth - The width of the screen
      textRenderer - The text renderer
      x - The x coordinate of the icon
      y - The y coordinate of the icon
      width - The width of the icon
      height - The height of the icon
      Returns:
      The tuple of coordinates
    • getTextCoords

      public static Ukutils.Tuple2<Integer,Integer> getTextCoords(net.minecraft.text.Text text, int screenWidth, net.minecraft.client.font.TextRenderer textRenderer, int x, int y)
      Makes text coordinates based on the position of a standard 16x16 icon.
      Parameters:
      text - The text to be drawn
      screenWidth - The width of the screen
      textRenderer - The text renderer
      x - The x coordinate of the icon
      y - The y coordinate of the icon
      Returns:
      The tuple of coordinates
      See Also: