Class CharacterUtils
java.lang.Object
net.glasslauncher.mods.api.gcapi.api.CharacterUtils
Some utility methods copied over from r1.2.5 for use in ExtensibleTextFieldWidget.
This should be useful for other things.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGets the current text on clipboard.static intgetIntFromColour(Color colour) Custom function for converting an JWJGL colour into minecraft's weird ARGB system.static StringgetRenderableString(String string, int maxPixelWidth, boolean flag, net.minecraft.client.font.TextRenderer textRenderer) Processes string colours.static booleanisCharacterValid(char c) static booleanSusceptible to overflows, but honestly, I am not too concerned.static booleanSusceptible to overflows, but honestly, I am not too concerned.static voidrenderTooltip(net.minecraft.client.font.TextRenderer textRenderer, List<String> tooltip, int x, int y, net.minecraft.client.gui.screen.Screen screen) Renders a tooltip on screen at the provided place, handling flipping of the tooltip where required.static voidsetClipboardText(String string) Tries to set the given string as clipboard text.static StringstripInvalidChars(String string)
-
Constructor Details
-
CharacterUtils
public CharacterUtils()
-
-
Method Details
-
renderTooltip
public static void renderTooltip(net.minecraft.client.font.TextRenderer textRenderer, List<String> tooltip, int x, int y, net.minecraft.client.gui.screen.Screen screen) Renders a tooltip on screen at the provided place, handling flipping of the tooltip where required.- Parameters:
textRenderer- the text renderer to use. You can use((Minecraft) FabricLoader.getInstance().getGameInstance()).textRendererfor this.tooltip- the tooltip to render. Can be multiline using multiple elements on the list.x- the X position where the tooltip should be. Typically mouseX.y- the Y position where the tooltip should be. Typically mouseY.screen- the screen where the tooltip is being rendered.
-
getIntFromColour
Custom function for converting an JWJGL colour into minecraft's weird ARGB system. Uses AWT's Colour class because LWJGL's one doesn't exist on server, so it saves me a headache. -
isInteger
Susceptible to overflows, but honestly, I am not too concerned. StackOverflow Source -
isFloat
Susceptible to overflows, but honestly, I am not too concerned. Modified to look for floats instead. StackOverflow Source -
isCharacterValid
public static boolean isCharacterValid(char c) -
stripInvalidChars
-
setClipboardText
Tries to set the given string as clipboard text. Silently fails.- Parameters:
string- the text to set.
-
getClipboardText
Gets the current text on clipboard. Strips formatting.- Returns:
- the current text of the clipboard. Can be empty, but never null. Fails silently.
-
getRenderableString
public static String getRenderableString(String string, int maxPixelWidth, boolean flag, net.minecraft.client.font.TextRenderer textRenderer) Processes string colours. I think. I have no idea, honestly.
-