Class GuiHelpers

java.lang.Object
org.cyclops.cyclopscore.helper.GuiHelpers

public class GuiHelpers extends Object
Helpers related to guis.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Represents the direction of a progress bar.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    The default item slot size.
    static int
    The default inner item slot size.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    drawTooltip(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, List<net.minecraft.network.chat.Component> lines, int x, int y)
    Draw a tooltip.
    static void
    drawTooltipBackground(com.mojang.blaze3d.vertex.PoseStack poseStack, int xStart, int yStart, int tooltipWidth, int tooltipHeight)
    Draw the background box for a tooltip.
    static void
    fillGradient(com.mojang.blaze3d.vertex.PoseStack poseStack, int left, int top, int right, int bottom, int startColor, int endColor, float zLevel)
    Render a rectangle.
    static String
    quantityToScaledString(long quantity)
    Stringify a (potentially large) quantity to a scaled string.
    static void
    renderFluidSlot(net.minecraft.client.gui.GuiGraphics gui, net.neoforged.neoforge.fluids.FluidStack fluidStack, int x, int y)
    Render the given fluid in a standard slot.
    static void
    renderFluidTank(net.minecraft.client.gui.GuiGraphics gui, net.neoforged.neoforge.fluids.FluidStack fluidStack, int capacity, int x, int y, int width, int height)
    Render a fluid tank in a gui.
    static void
    renderOverlayedFluidTank(net.minecraft.client.gui.GuiGraphics gui, net.neoforged.neoforge.fluids.FluidStack fluidStack, int capacity, int x, int y, int width, int height, net.minecraft.resources.ResourceLocation textureOverlay, int overlayTextureX, int overlayTextureY)
    Render a fluid tank in a gui with a tank overlay.
    static void
    renderProgressBar(net.minecraft.client.gui.GuiGraphics gui, net.minecraft.resources.ResourceLocation texture, int x, int y, int width, int height, int textureX, int textureY, GuiHelpers.ProgressDirection direction, int progress, int progressMax)
    Render a progress bar in a certain direction.
    static void
    renderTooltip(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, int x, int y, int width, int height, int mouseX, int mouseY, Supplier<List<net.minecraft.network.chat.Component>> linesSupplier)
    Render a tooltip if the mouse if in the bounding box defined by the given position, width and height.
    static void
    renderTooltipOptional(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, int x, int y, int width, int height, int mouseX, int mouseY, Supplier<Optional<List<net.minecraft.network.chat.Component>>> linesSupplier)
    Render a tooltip if the mouse if in the bounding box defined by the given position, width and height.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SLOT_SIZE

      public static int SLOT_SIZE
      The default item slot size. Width and height are equal.
    • SLOT_SIZE_INNER

      public static int SLOT_SIZE_INNER
      The default inner item slot size. Width and height are equal.
  • Constructor Details

    • GuiHelpers

      public GuiHelpers()
  • Method Details

    • renderFluidTank

      public static void renderFluidTank(net.minecraft.client.gui.GuiGraphics gui, @Nullable net.neoforged.neoforge.fluids.FluidStack fluidStack, int capacity, int x, int y, int width, int height)
      Render a fluid tank in a gui.
      Parameters:
      gui - The gui to render in.
      fluidStack - The fluid to render.
      capacity - The tank capacity.
      x - The gui x position, including gui left.
      y - The gui y position, including gui top.
      width - The tank width.
      height - The tank height.
    • renderFluidSlot

      public static void renderFluidSlot(net.minecraft.client.gui.GuiGraphics gui, @Nullable net.neoforged.neoforge.fluids.FluidStack fluidStack, int x, int y)
      Render the given fluid in a standard slot.
      Parameters:
      gui - The gui to render in.
      fluidStack - The fluid to render.
      x - The slot X position.
      y - The slot Y position.
    • renderOverlayedFluidTank

      public static void renderOverlayedFluidTank(net.minecraft.client.gui.GuiGraphics gui, @Nullable net.neoforged.neoforge.fluids.FluidStack fluidStack, int capacity, int x, int y, int width, int height, net.minecraft.resources.ResourceLocation textureOverlay, int overlayTextureX, int overlayTextureY)
      Render a fluid tank in a gui with a tank overlay. This assumes that the tank overlay has the provided width and height.
      Parameters:
      gui - The gui to render in.
      fluidStack - The fluid to render.
      capacity - The tank capacity.
      x - The gui x position, including gui left.
      y - The gui y position, including gui top.
      width - The tank width.
      height - The tank height.
      textureOverlay - The texture of the tank overlay.
      overlayTextureX - The overlay x texture position.
      overlayTextureY - The overlay y texture position.
    • renderProgressBar

      public static void renderProgressBar(net.minecraft.client.gui.GuiGraphics gui, net.minecraft.resources.ResourceLocation texture, int x, int y, int width, int height, int textureX, int textureY, GuiHelpers.ProgressDirection direction, int progress, int progressMax)
      Render a progress bar in a certain direction. The currently bound texture will be used to render the progress bar.
      Parameters:
      gui - The gui to render in.
      texture - The texture.
      x - The gui x position, including gui left.
      y - The gui y position, including gui top.
      width - The progress bar width.
      height - The progress bar height.
      textureX - The texture x position.
      textureY - The texture y position.
      direction - The direction to progress in.
      progress - The current progress.
      progressMax - The maximum progress.
    • drawTooltip

      public static void drawTooltip(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, List<net.minecraft.network.chat.Component> lines, int x, int y)
      Draw a tooltip.
      Parameters:
      gui - The gui to draw in.
      poseStack - The pose stack.
      lines - A list of lines.
      x - Tooltip X.
      y - Tooltip Y.
    • drawTooltipBackground

      public static void drawTooltipBackground(com.mojang.blaze3d.vertex.PoseStack poseStack, int xStart, int yStart, int tooltipWidth, int tooltipHeight)
      Draw the background box for a tooltip.
      Parameters:
      poseStack - The pose stack.
      xStart - X
      yStart - Y
      tooltipWidth - Width
      tooltipHeight - Height
    • fillGradient

      public static void fillGradient(com.mojang.blaze3d.vertex.PoseStack poseStack, int left, int top, int right, int bottom, int startColor, int endColor, float zLevel)
      Render a rectangle. Public variant of GuiGraphics#fillGradient.
      Parameters:
      poseStack - The pose stack.
      left - Left X.
      top - Top Y.
      right - Right X.
      bottom - Bottom Y.
      startColor - Start gradient color.
      endColor - End gradient color.
      zLevel - The Z level to render at.
    • renderTooltipOptional

      public static void renderTooltipOptional(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, int x, int y, int width, int height, int mouseX, int mouseY, Supplier<Optional<List<net.minecraft.network.chat.Component>>> linesSupplier)
      Render a tooltip if the mouse if in the bounding box defined by the given position, width and height. The tooltip lines supplier can return an optional list.
      Parameters:
      poseStack - The pose stack.
      gui - The gui to render in.
      x - The gui x position, excluding gui left.
      y - The gui y position, excluding gui top.
      width - The area width.
      height - The area height.
      mouseX - The mouse x position.
      mouseY - The mouse y position.
      linesSupplier - A supplier for the optional tooltip lines to render. No tooltip will be rendered when the optional value is absent. This will only be called when needed.
    • renderTooltip

      public static void renderTooltip(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen gui, com.mojang.blaze3d.vertex.PoseStack poseStack, int x, int y, int width, int height, int mouseX, int mouseY, Supplier<List<net.minecraft.network.chat.Component>> linesSupplier)
      Render a tooltip if the mouse if in the bounding box defined by the given position, width and height.
      Parameters:
      gui - The gui to render in.
      poseStack - The pose stack.
      x - The gui x position, excluding gui left.
      y - The gui y position, excluding gui top.
      width - The area width.
      height - The area height.
      mouseX - The mouse x position.
      mouseY - The mouse y position.
      linesSupplier - A supplier for the tooltip lines to render. This will only be called when needed.
    • quantityToScaledString

      public static String quantityToScaledString(long quantity)
      Stringify a (potentially large) quantity to a scaled string. For example, 123765 will be converted as 1.23M.
      Parameters:
      quantity - A quantity.
      Returns:
      A scaled quantity string.