Class GuiText

All Implemented Interfaces:
ElementEvents, ForegroundRender, GuiParent<GuiText>, TooltipHandler<GuiText>

public class GuiText extends GuiElement<GuiText> implements ForegroundRender
Created by brandon3055 on 31/08/2023
  • Constructor Details

    • GuiText

      public GuiText(GuiParent<?> parent)
      Parameters:
      parent - parent GuiParent.
    • GuiText

      public GuiText(GuiParent<?> parent, @Nullable @Nullable net.minecraft.network.chat.Component text)
      Parameters:
      parent - parent GuiParent.
    • GuiText

      public GuiText(GuiParent<?> parent, Supplier<@Nullable net.minecraft.network.chat.Component> text)
      Parameters:
      parent - parent GuiParent.
  • Method Details

    • autoHeight

      public GuiText autoHeight()
      Apply a dynamic height constraint that sets the height based on text height (accounting for wrapping)
    • autoWidth

      public GuiText autoWidth()
    • setTextSupplier

      public GuiText setTextSupplier(Supplier<@Nullable net.minecraft.network.chat.Component> textSupplier)
    • setText

      public GuiText setText(@Nullable @Nullable net.minecraft.network.chat.Component text)
    • setText

      public GuiText setText(String text)
    • setTranslatable

      public GuiText setTranslatable(String translationKey)
    • getText

      @Nullable public @Nullable net.minecraft.network.chat.Component getText()
    • setAlignment

      public GuiText setAlignment(Align alignment)
    • getAlignment

      public Align getAlignment()
    • setTrim

      public GuiText setTrim(boolean trim)
      If set to true the text will be trimmed if it is too long to fit within the bounds on the element. Default disabled. Setting this to true will automatically disable wrap and scroll ether are enabled.
    • getTrim

      public boolean getTrim()
    • setWrap

      public GuiText setWrap(boolean wrap)
      Set to true the text will be wrapped (rendered as multiple lines of text) if it is too long to fit within the size of the element. Default disabled. Setting this to true will automatically disable trim and scroll ether are enabled.
    • getWrap

      public boolean getWrap()
    • setScroll

      public GuiText setScroll(boolean scroll)
      Set to true the text scroll using the same logic as vanillas widgets if the text is too long to fit within the elements bounds Default enabled. Setting this to true will automatically disable trim and wrap ether are enabled.
    • getScroll

      public boolean getScroll()
    • setShadow

      public GuiText setShadow(Supplier<Boolean> shadow)
    • setShadow

      public GuiText setShadow(boolean shadow)
    • getShadow

      public boolean getShadow()
    • setTextColour

      public GuiText setTextColour(Supplier<Integer> textColour)
    • setTextColour

      public GuiText setTextColour(int textColour)
    • getTextColour

      public int getTextColour()
    • setRotation

      public GuiText setRotation(double rotation)
      Set rotation angle in degrees //TODO, Does not work when text scroll is used
    • setRotation

      public GuiText setRotation(@Nullable @Nullable Supplier<Double> rotation)
      Dynamic rotation control, Set to null to disable rotation. Rotation angle is in degrees //TODO, Does not work when text scroll is used
    • setRotatePoint

      public GuiText setRotatePoint(Position rotatePoint)
      Sets the point around which the text rotates relative to the top left of the element. Default rotation point is a dynamic point set to the dead center of the element.
    • renderInFront

      public void renderInFront(net.minecraft.client.gui.GuiGraphics graphics, double mouseX, double mouseY, float partialTicks)
      Description copied from interface: ForegroundRender
      Used to render content in front of this elements child elements. When rendering element content, always use the PoseStack available via the provided
      invalid reference
      GuiRender
      Where applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete.
      Specified by:
      renderInFront in interface ForegroundRender
      Parameters:
      graphics - Contains gui context information as well as essential render methods/utils including the PoseStack.