Class GuiGraphics

java.lang.Object
net.minecraft.client.gui.GuiGraphics
All Implemented Interfaces:
IGuiGraphicsExtension

public class GuiGraphics extends Object implements IGuiGraphicsExtension
  • Field Details

    • EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE

      private static final int EXTRA_SPACE_AFTER_FIRST_TOOLTIP_LINE
      See Also:
    • minecraft

      private final Minecraft minecraft
    • pose

      private final Matrix3x2fStack pose
    • scissorStack

      private final GuiGraphics.ScissorStack scissorStack
    • sprites

      private final SpriteGetter sprites
    • guiSprites

      private final TextureAtlas guiSprites
    • guiRenderState

      private final GuiRenderState guiRenderState
    • pendingCursor

      private CursorType pendingCursor
    • mouseX

      private final int mouseX
    • mouseY

      private final int mouseY
    • deferredTooltip

      private @Nullable Runnable deferredTooltip
    • hoveredTextStyle

      private @Nullable Style hoveredTextStyle
    • clickableTextStyle

      private @Nullable Style clickableTextStyle
    • tooltipStack

      private ItemStack tooltipStack
  • Constructor Details

  • Method Details

    • requestCursor

      public void requestCursor(CursorType cursorType)
    • applyCursor

      public void applyCursor(Window window)
    • guiWidth

      public int guiWidth()
    • guiHeight

      public int guiHeight()
    • nextStratum

      public void nextStratum()
    • blurBeforeThisStratum

      public void blurBeforeThisStratum()
    • pose

      public Matrix3x2fStack pose()
    • hLine

      public void hLine(int x0, int x1, int y, int col)
      Draws a horizontal line from minX to maxX at the specified y-coordinate with the given color.
      Parameters:
      x0 - the x-coordinate of the start point.
      x1 - the x-coordinate of the end point.
      y - the y-coordinate of the line.
      col - the color of the line.
    • vLine

      public void vLine(int x, int y0, int y1, int col)
      Draws a vertical line from minY to maxY at the specified x-coordinate with the given color.
      Parameters:
      x - the x-coordinate of the line.
      y0 - the y-coordinate of the start point.
      y1 - the y-coordinate of the end point.
      col - the color of the line.
    • enableScissor

      public void enableScissor(int x0, int y0, int x1, int y1)
      Enables scissoring with the specified screen coordinates.
      Parameters:
      x0 - the minimum x-coordinate of the scissor region.
      y0 - the minimum y-coordinate of the scissor region.
      x1 - the maximum x-coordinate of the scissor region.
      y1 - the maximum y-coordinate of the scissor region.
    • disableScissor

      public void disableScissor()
    • containsPointInScissor

      public boolean containsPointInScissor(int x, int y)
    • fill

      public void fill(int x0, int y0, int x1, int y1, int col)
      Fills a rectangle with the specified color using the given coordinates as the boundaries.
      Parameters:
      x0 - the minimum x-coordinate of the rectangle.
      y0 - the minimum y-coordinate of the rectangle.
      x1 - the maximum x-coordinate of the rectangle.
      y1 - the maximum y-coordinate of the rectangle.
      col - the color to fill the rectangle with.
    • fill

      public void fill(RenderPipeline pipeline, int x0, int y0, int x1, int y1, int col)
    • fillGradient

      public void fillGradient(int x0, int y0, int x1, int y1, int col1, int col2)
      Fills a rectangle with a gradient color from colorFrom to colorTo using the given coordinates as the boundaries.
      Parameters:
      x0 - the x-coordinate of the first corner of the rectangle.
      y0 - the y-coordinate of the first corner of the rectangle.
      x1 - the x-coordinate of the second corner of the rectangle.
      y1 - the y-coordinate of the second corner of the rectangle.
      col1 - the starting color of the gradient.
      col2 - the ending color of the gradient.
    • fill

      public void fill(RenderPipeline renderPipeline, TextureSetup textureSetup, int x0, int y0, int x1, int y1)
    • submitColoredRectangle

      private void submitColoredRectangle(RenderPipeline renderPipeline, TextureSetup textureSetup, int x0, int y0, int x1, int y1, int color1, @Nullable Integer color2)
    • textHighlight

      public void textHighlight(int x0, int y0, int x1, int y1, boolean invertText)
    • drawCenteredString

      public void drawCenteredString(Font font, String str, int x, int y, int color)
      Draws a centered string at the specified coordinates using the given font, text, and color.
      Parameters:
      font - the font to use for rendering.
      str - the text to draw.
      x - the x-coordinate of the center of the string.
      y - the y-coordinate of the string.
      color - the color of the string.
    • drawCenteredString

      public void drawCenteredString(Font font, Component text, int x, int y, int color)
      Draws a centered string at the specified coordinates using the given font, text component, and color.
      Parameters:
      font - the font to use for rendering.
      text - the text component to draw.
      x - the x-coordinate of the center of the string.
      y - the y-coordinate of the string.
      color - the color of the string.
    • drawCenteredString

      public void drawCenteredString(Font font, FormattedCharSequence text, int x, int y, int color)
      Draws a centered string at the specified coordinates using the given font, formatted character sequence, and color.
      Parameters:
      font - the font to use for rendering.
      text - the formatted character sequence to draw.
      x - the x-coordinate of the center of the string.
      y - the y-coordinate of the string.
      color - the color of the string.
    • drawString

      public void drawString(Font font, @Nullable String str, int x, int y, int color)
    • drawString

      public void drawString(Font font, @Nullable String str, int x, int y, int color, boolean dropShadow)
    • drawString

      public void drawString(Font font, FormattedCharSequence str, int x, int y, int color)
    • drawString

      public void drawString(Font font, FormattedCharSequence str, int x, int y, int color, boolean dropShadow)
    • drawString

      public void drawString(Font font, Component str, int x, int y, int color)
    • drawString

      public void drawString(Font font, Component str, int x, int y, int color, boolean dropShadow)
    • drawWordWrap

      public void drawWordWrap(Font font, FormattedText string, int x, int y, int w, int col)
      Draws a formatted text with word wrapping at the specified coordinates using the given font, text, line width, and color.
      Parameters:
      font - the font to use for rendering.
      string - the formatted text to draw.
      x - the x-coordinate of the starting position.
      y - the y-coordinate of the starting position.
      w - the maximum width of each line before wrapping.
      col - the color of the text.
    • drawWordWrap

      public void drawWordWrap(Font font, FormattedText string, int x, int y, int w, int col, boolean dropShadow)
    • drawStringWithBackdrop

      public void drawStringWithBackdrop(Font font, Component str, int textX, int textY, int textWidth, int textColor)
    • renderOutline

      public void renderOutline(int x, int y, int width, int height, int color)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, Identifier location, int x, int y, int width, int height)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, Identifier location, int x, int y, int width, int height, float alpha)
    • getSpriteScaling

      private static GuiSpriteScaling getSpriteScaling(TextureAtlasSprite sprite)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, Identifier location, int x, int y, int width, int height, int color)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, Identifier location, int spriteWidth, int spriteHeight, int textureX, int textureY, int x, int y, int width, int height)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, Identifier location, int spriteWidth, int spriteHeight, int textureX, int textureY, int x, int y, int width, int height, int color)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, TextureAtlasSprite sprite, int x, int y, int width, int height)
    • blitSprite

      public void blitSprite(RenderPipeline renderPipeline, TextureAtlasSprite sprite, int x, int y, int width, int height, int color)
    • blitSprite

      private void blitSprite(RenderPipeline renderPipeline, TextureAtlasSprite sprite, int spriteWidth, int spriteHeight, int textureX, int textureY, int x, int y, int width, int height, int color)
    • blitNineSlicedSprite

      private void blitNineSlicedSprite(RenderPipeline renderPipeline, TextureAtlasSprite sprite, GuiSpriteScaling.NineSlice nineSlice, int x, int y, int width, int height, int color)
    • blitNineSliceInnerSegment

      private void blitNineSliceInnerSegment(RenderPipeline renderPipeline, GuiSpriteScaling.NineSlice nineSlice, TextureAtlasSprite sprite, int x, int y, int width, int height, int textureX, int textureY, int textureWidth, int textureHeight, int spriteWidth, int spriteHeight, int color)
    • blitTiledSprite

      private void blitTiledSprite(RenderPipeline renderPipeline, TextureAtlasSprite sprite, int x, int y, int width, int height, int textureX, int textureY, int tileWidth, int tileHeight, int spriteWidth, int spriteHeight, int color)
    • blit

      public void blit(RenderPipeline renderPipeline, Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight, int color)
    • blit

      public void blit(RenderPipeline renderPipeline, Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight)
    • blit

      public void blit(RenderPipeline renderPipeline, Identifier texture, int x, int y, float u, float v, int width, int height, int srcWidth, int srcHeight, int textureWidth, int textureHeight)
    • blit

      public void blit(RenderPipeline renderPipeline, Identifier texture, int x, int y, float u, float v, int width, int height, int srcWidth, int srcHeight, int textureWidth, int textureHeight, int color)
    • blit

      public void blit(Identifier location, int x0, int y0, int x1, int y1, float u0, float u1, float v0, float v1)
    • blit

      public void blit(GpuTextureView textureView, GpuSampler sampler, int x0, int y0, int x1, int y1, float u0, float u1, float v0, float v1)
    • innerBlit

      private void innerBlit(RenderPipeline renderPipeline, Identifier location, int x0, int x1, int y0, int y1, float u0, float u1, float v0, float v1, int color)
    • submitBlit

      private void submitBlit(RenderPipeline pipeline, GpuTextureView textureView, GpuSampler sampler, int x0, int y0, int x1, int y1, float u0, float u1, float v0, float v1, int color)
    • submitTiledBlit

      private void submitTiledBlit(RenderPipeline pipeline, GpuTextureView textureView, GpuSampler sampler, int tileWidth, int tileHeight, int x0, int y0, int x1, int y1, float u0, float u1, float v0, float v1, int color)
    • renderItem

      public void renderItem(ItemStack itemStack, int x, int y)
      Renders an item stack at the specified coordinates.
      Parameters:
      itemStack - the item stack to render.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
    • renderItem

      public void renderItem(ItemStack itemStack, int x, int y, int seed)
      Renders an item stack at the specified coordinates with a random seed.
      Parameters:
      itemStack - the item stack to render.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
      seed - the random seed.
    • renderFakeItem

      public void renderFakeItem(ItemStack itemStack, int x, int y)
      Renders a fake item stack at the specified coordinates.
      Parameters:
      itemStack - the fake item stack to render.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
    • renderFakeItem

      public void renderFakeItem(ItemStack itemStack, int x, int y, int seed)
    • renderItem

      public void renderItem(LivingEntity owner, ItemStack itemStack, int x, int y, int seed)
      Renders an item stack for a living entity at the specified coordinates with a random seed.
      Parameters:
      owner - the living entity.
      itemStack - the item stack to render.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
      seed - the random seed.
    • renderItem

      private void renderItem(@Nullable LivingEntity owner, @Nullable Level level, ItemStack itemStack, int x, int y, int seed)
      Renders an item stack for a living entity in a specific level at the specified coordinates with a random seed.
      Parameters:
      owner - the living entity. Can be null.
      level - the level in which the rendering occurs. Can be null.
      itemStack - the item stack to render.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
      seed - the random seed.
    • renderItemDecorations

      public void renderItemDecorations(Font font, ItemStack itemStack, int x, int y)
      Renders additional decorations for an item stack at the specified coordinates.
      Parameters:
      font - the font used for rendering text.
      itemStack - the item stack to decorate.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
    • renderItemDecorations

      public void renderItemDecorations(Font font, ItemStack itemStack, int x, int y, @Nullable String countText)
      Renders additional decorations for an item stack at the specified coordinates with optional custom text.
      Parameters:
      font - the font used for rendering text.
      itemStack - the item stack to decorate.
      x - the x-coordinate of the rendering position.
      y - the y-coordinate of the rendering position.
      countText - the custom text to display. Can be null.
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Component component, int x, int y)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(List<FormattedCharSequence> formattedCharSequences, int x, int y)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, ItemStack itemStack, int xo, int yo)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, ItemStack stack, int mouseX, int mouseY)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<Component> textComponents, Optional<TooltipComponent> tooltipComponent, ItemStack stack, int mouseX, int mouseY, @Nullable Identifier backgroundTexture)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, int xo, int yo)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<Component> texts, Optional<TooltipComponent> optionalImage, int xo, int yo, @Nullable Identifier style)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<FormattedCharSequence> tooltip, Optional<TooltipComponent> component, ClientTooltipPositioner positioner, int xo, int yo, boolean replaceExisting, @Nullable Identifier style)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, Component text, int xo, int yo)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, Component text, int xo, int yo, @Nullable Identifier style)
    • setComponentTooltipForNextFrame

      public void setComponentTooltipForNextFrame(Font font, List<Component> lines, int xo, int yo)
    • setComponentTooltipForNextFrame

      public void setComponentTooltipForNextFrame(Font font, List<Component> lines, int xo, int yo, @Nullable Identifier style)
    • setComponentTooltipForNextFrame

      public void setComponentTooltipForNextFrame(Font font, List<? extends FormattedText> tooltips, int mouseX, int mouseY, ItemStack stack)
    • setComponentTooltipForNextFrame

      public void setComponentTooltipForNextFrame(Font font, List<? extends FormattedText> tooltips, int mouseX, int mouseY, ItemStack stack, @Nullable Identifier backgroundTexture)
    • setComponentTooltipFromElementsForNextFrame

      public void setComponentTooltipFromElementsForNextFrame(Font font, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> elements, int mouseX, int mouseY, ItemStack stack)
    • setComponentTooltipFromElementsForNextFrame

      public void setComponentTooltipFromElementsForNextFrame(Font font, List<com.mojang.datafixers.util.Either<FormattedText, TooltipComponent>> elements, int mouseX, int mouseY, ItemStack stack, @Nullable Identifier backgroundTexture)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<? extends FormattedCharSequence> lines, int xo, int yo)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<? extends FormattedCharSequence> lines, int xo, int yo, @Nullable Identifier style)
    • setTooltipForNextFrame

      public void setTooltipForNextFrame(Font font, List<FormattedCharSequence> tooltip, ClientTooltipPositioner positioner, int xo, int yo, boolean replaceExisting)
    • setTooltipForNextFrameInternal

      private void setTooltipForNextFrameInternal(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style, boolean replaceExisting)
    • renderTooltip

      public void renderTooltip(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style)
    • renderTooltip

      public void renderTooltip(Font font, List<ClientTooltipComponent> lines, int xo, int yo, ClientTooltipPositioner positioner, @Nullable Identifier style, ItemStack tooltipStack)
    • renderDeferredElements

      public void renderDeferredElements()
    • renderItemBar

      private void renderItemBar(ItemStack itemStack, int x, int y)
    • renderItemCount

      private void renderItemCount(Font font, ItemStack itemStack, int x, int y, @Nullable String countText)
    • renderItemCooldown

      private void renderItemCooldown(ItemStack itemStack, int x, int y)
    • renderComponentHoverEffect

      public void renderComponentHoverEffect(Font font, @Nullable Style hoveredStyle, int xMouse, int yMouse)
      Renders a hover effect for a text component at the specified mouse coordinates.
      Parameters:
      font - the font used for rendering text.
      hoveredStyle - the style of the text component. Can be null.
      xMouse - the x-coordinate of the mouse position.
      yMouse - the y-coordinate of the mouse position.
    • submitMapRenderState

      public void submitMapRenderState(MapRenderState mapRenderState)
    • submitEntityRenderState

      public void submitEntityRenderState(EntityRenderState renderState, float scale, Vector3f translation, Quaternionf rotation, @Nullable Quaternionf overrideCameraAngle, int x0, int y0, int x1, int y1)
    • submitSkinRenderState

      public void submitSkinRenderState(PlayerModel playerModel, Identifier texture, float scale, float rotationX, float rotationY, float pivotY, int x0, int y0, int x1, int y1)
    • submitBookModelRenderState

      public void submitBookModelRenderState(BookModel bookModel, Identifier texture, float scale, float open, float flip, int x0, int y0, int x1, int y1)
    • submitBannerPatternRenderState

      public void submitBannerPatternRenderState(BannerFlagModel flag, DyeColor baseColor, BannerPatternLayers resultBannerPatterns, int x0, int y0, int x1, int y1)
    • submitSignRenderState

      public void submitSignRenderState(Model.Simple signModel, float scale, WoodType woodType, int x0, int y0, int x1, int y1)
    • submitProfilerChartRenderState

      public void submitProfilerChartRenderState(List<ResultField> chartData, int x0, int y0, int x1, int y1)
    • submitGuiElementRenderState

      public void submitGuiElementRenderState(GuiElementRenderState renderState)
      Neo: Submit a custom GuiElementRenderState for rendering
    • submitPictureInPictureRenderState

      public void submitPictureInPictureRenderState(PictureInPictureRenderState renderState)
      Neo: Submit a custom PictureInPictureRenderState for rendering
      See Also:
    • peekScissorStack

      public @Nullable ScreenRectangle peekScissorStack()
      Neo: Returns the top-most scissor rectangle, if present, for use with custom GuiElementRenderStates and PictureInPictureRenderStates
    • getSprite

      public TextureAtlasSprite getSprite(SpriteId sprite)
    • textRendererForWidget

      public ActiveTextCollector textRendererForWidget(AbstractWidget owner, GuiGraphics.HoveredTextEffects hoveredTextEffects)
    • textRenderer

      public ActiveTextCollector textRenderer()
    • textRenderer

      public ActiveTextCollector textRenderer(GuiGraphics.HoveredTextEffects hoveredTextEffects)
    • textRenderer

      public ActiveTextCollector textRenderer(GuiGraphics.HoveredTextEffects hoveredTextEffects, @Nullable Consumer<Style> additionalHoverStyleConsumer)
    • createDefaultTextParameters

      private ActiveTextCollector.Parameters createDefaultTextParameters(float opacity)