Package net.uku3lig.ukulib.utils
Class Ukutils
java.lang.Object
net.uku3lig.ukulib.utils.Ukutils
Simple class for various utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.client.gui.widget.ButtonWidgetdoneButton(int width, int height, net.minecraft.client.gui.screen.Screen parent) Creates a done button.static PathgetConfigPath(String name) Creates a config path for a file name.static @Nullable net.minecraft.util.IdentifiergetHeadTex(String username) Gets the texture of a player's head.The map of keybindings and their respective actions.static StringgetText(net.minecraft.text.OrderedText text) Retrieves the string text from an ordered text.static org.joml.Vector2icgetTextCoords(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.static org.joml.Vector2icgetTextCoords(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.static voidregisterKeybinding(net.minecraft.client.option.KeyBinding keyBinding, Consumer<net.minecraft.client.MinecraftClient> action) Register a keybinding.static voidregisterToggleBind(net.minecraft.client.option.KeyBinding keyBinding, BooleanSupplier getter, it.unimi.dsi.fastutil.booleans.BooleanConsumer setter, net.minecraft.text.Text message) Register a keybinding for a boolean option that can be toggled.static voidsendToast(net.minecraft.text.Text title, @Nullable net.minecraft.text.Text body) Displays a simple toast message.static booleantextureExists(net.minecraft.util.Identifier texture) Checks if a texture exists and is registered.
-
Method Details
-
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 screenheight- The height of the screenparent- The parent screen- Returns:
- The generated button
-
getTextCoords
public static org.joml.Vector2ic 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 drawnscreenWidth- The width of the screentextRenderer- The text rendererx- The x coordinate of the icony- The y coordinate of the iconwidth- The width of the iconheight- The height of the icon- Returns:
- The tuple of coordinates
-
getTextCoords
public static org.joml.Vector2ic 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 drawnscreenWidth- The width of the screentextRenderer- The text rendererx- The x coordinate of the icony- The y coordinate of the icon- Returns:
- The tuple of coordinates
- See Also:
-
getText
Retrieves the string text from an ordered text.- Parameters:
text- The ordered text- Returns:
- The value of the text
-
getConfigPath
Creates a config path for a file name.- Parameters:
name- The name of the file- Returns:
- The path to the file
-
sendToast
public static void sendToast(net.minecraft.text.Text title, @Nullable @Nullable net.minecraft.text.Text body) Displays a simple toast message.- Parameters:
title- The title of the messagebody- The body of the message
-
textureExists
public static boolean textureExists(net.minecraft.util.Identifier texture) Checks if a texture exists and is registered.- Parameters:
texture- The texture to check- Returns:
- Whether the texture exists
-
getHeadTex
Gets the texture of a player's head.- Parameters:
username- The username of the player- Returns:
- The texture of the player's head
-
registerKeybinding
public static void registerKeybinding(net.minecraft.client.option.KeyBinding keyBinding, Consumer<net.minecraft.client.MinecraftClient> action) Register a keybinding.- Parameters:
keyBinding- The keybindingaction- The action to be performed when the key is pressed
-
registerToggleBind
public static void registerToggleBind(net.minecraft.client.option.KeyBinding keyBinding, BooleanSupplier getter, it.unimi.dsi.fastutil.booleans.BooleanConsumer setter, net.minecraft.text.Text message) Register a keybinding for a boolean option that can be toggled. Warning: for the consumer, make sure NOT to use method reference if you're using ukulib's config; do something likeb -> manager.getConfig().setValue(b)instead.- Parameters:
keyBinding- The keybindinggetter- The boolean value gettersetter- The boolean value settermessage- The message to be displayed to the player when the key is pressed. The new state (ON or OFF) will be appended to this message.
-
getKeybindings
public static Map<net.minecraft.client.option.KeyBinding,Consumer<net.minecraft.client.MinecraftClient>> getKeybindings()The map of keybindings and their respective actions.- Returns:
- The map.
-