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(@NotNull @NotNull GuiParent<?> parent)
      Parameters:
      parent - parent GuiParent.
    • GuiText

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

      public GuiText(@NotNull @NotNull GuiParent<?> parent, @NotNull @NotNull 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(@NotNull @NotNull Supplier<@Nullable net.minecraft.network.chat.Component> textSupplier)
    • setText

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

      public GuiText setText(@NotNull @NotNull String text)
    • setTranslatable

      public GuiText setTranslatable(@NotNull @NotNull 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(@NotNull @NotNull 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.
    • getForegroundDepth

      public double getForegroundDepth()
      Description copied from interface: ForegroundRender
      Specifies the z depth of the foreground content. Used when calculating the total depth of this gui element. Recommended minimum depth is 0.01 or 0.035 if this element renders text. (text shadows are rendered with a 0.03 offset)
      Specified by:
      getForegroundDepth in interface ForegroundRender
      Returns:
      the z height of the background content.
    • renderForeground

      public void renderForeground(GuiRender render, 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 GuiRender Where applicable, always use push/pop to ensure the stack is returned to its original state after your rendering is complete.
      Specified by:
      renderForeground in interface ForegroundRender
      Parameters:
      render - Contains gui context information as well as essential render methods/utils including the PoseStack.