Class CharacterUtils

java.lang.Object
net.glasslauncher.mods.api.gcapi.api.CharacterUtils

public class CharacterUtils extends Object
Some utility methods copied over from r1.2.5 for use in ExtensibleTextFieldWidget. This should be useful for other things.
  • 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()).textRenderer for 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

      public static int getIntFromColour(Color colour)
      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

      public static boolean isInteger(String str)
      Susceptible to overflows, but honestly, I am not too concerned. StackOverflow Source
    • isFloat

      public static boolean isFloat(String str)
      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

      public static String stripInvalidChars(String string)
    • setClipboardText

      public static void setClipboardText(String string)
      Tries to set the given string as clipboard text. Silently fails.
      Parameters:
      string - the text to set.
    • getClipboardText

      public static String 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.