Class RenderHelper

java.lang.Object
org.moddingx.libx.render.RenderHelper

public class RenderHelper extends Object
Some utilities for rendering in general.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.resources.Identifier
     
    static final net.minecraft.resources.Identifier
    Identifier of a texture with the size 256x256 that is purely white.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    argb(int color)
    Sets the color to the given ARGB color in format 0xAARRGGBB
    static void
    renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height)
    Same as renderGuiBackground but with pre-set texture.
    static void
    renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height, net.minecraft.resources.Identifier texture)
    static void
    renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height, net.minecraft.resources.Identifier texture, int textureX, int textureY, int minU, int maxU, int minV, int maxV)
    Renders a gui background of any size.
    static void
    renderIconColored(com.mojang.blaze3d.vertex.PoseStack poseStack, com.mojang.blaze3d.vertex.VertexConsumer buffer, float x, float y, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite, float width, float height, float alpha, int color, int light, int overlay)
    Renders a texture colored with a given color.
    static void
    renderItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemDisplayContext displayContext, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource buffer, int packedLight, int packedOverlay)
    Renders an ItemStack into a MultiBufferSource.
    static void
    repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int texWidth, int texHeight, int displayWidth, int displayHeight, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite)
    Repeatedly blits a texture
    static void
    repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int displayWidth, int displayHeight, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite)
    static void
    repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier texture, int x, int y, int texWidth, int texHeight, int displayWidth, int displayHeight, float minU, float maxU, float minV, float maxV)
    Same as repeatBlit(RenderPipeline, GuiGraphicsExtractor, int, int, int, int, int, int, TextureAtlasSprite) but with the u and v values set directly and not with a TextureAtlasSprite.
    static void
    Resets the color to white.
    static void
    rgb(int color)
    Sets the color to the given RGB color in format 0xRRGGBB

    Methods inherited from class Object

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

    • TEXTURE_WHITE

      public static final net.minecraft.resources.Identifier TEXTURE_WHITE
      Identifier of a texture with the size 256x256 that is purely white.
    • TEXTURE_CHEST_GUI

      public static final net.minecraft.resources.Identifier TEXTURE_CHEST_GUI
  • Constructor Details

    • RenderHelper

      public RenderHelper()
  • Method Details

    • repeatBlit

      public static void repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int displayWidth, int displayHeight, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite)
    • repeatBlit

      public static void repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int texWidth, int texHeight, int displayWidth, int displayHeight, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite)
      Repeatedly blits a texture
      Parameters:
      x - x coordinate of top-left corner
      y - y coordinate of top-left corner
      texWidth - width of one texture element. If this is lower than displayWidth the texture is looped.
      texHeight - height of one texture element. If this is lower than displayHeight the texture is looped.
      displayWidth - the width of the blit
      displayHeight - the height of the blit
      sprite - A texture sprite
    • repeatBlit

      public static void repeatBlit(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier texture, int x, int y, int texWidth, int texHeight, int displayWidth, int displayHeight, float minU, float maxU, float minV, float maxV)
      Same as repeatBlit(RenderPipeline, GuiGraphicsExtractor, int, int, int, int, int, int, TextureAtlasSprite) but with the u and v values set directly and not with a TextureAtlasSprite.
    • renderIconColored

      public static void renderIconColored(com.mojang.blaze3d.vertex.PoseStack poseStack, com.mojang.blaze3d.vertex.VertexConsumer buffer, float x, float y, net.minecraft.client.renderer.texture.TextureAtlasSprite sprite, float width, float height, float alpha, int color, int light, int overlay)
      Renders a texture colored with a given color.
      Parameters:
      buffer - A VertexConsumer used to render the sprite.
      x - x coordinate of top-left corner
      y - y coordinate of top-left corner
      sprite - A texture sprite
      width - The width of the icon
      height - The height of the icon
      alpha - The alpha value that should be used.
      color - A color in format 0xRRGGBB
      light - Light value
      overlay - Value on the overlay map.
    • rgb

      public static void rgb(int color)
      Sets the color to the given RGB color in format 0xRRGGBB
    • argb

      public static void argb(int color)
      Sets the color to the given ARGB color in format 0xAARRGGBB
    • resetColor

      public static void resetColor()
      Resets the color to white.
    • renderItem

      public static void renderItem(net.minecraft.world.item.ItemStack stack, net.minecraft.world.item.ItemDisplayContext displayContext, com.mojang.blaze3d.vertex.PoseStack poseStack, net.minecraft.client.renderer.MultiBufferSource buffer, int packedLight, int packedOverlay)
      Renders an ItemStack into a MultiBufferSource. This bridges the 1.21.10 submission-based item rendering (ItemStackRenderState) back to a buffer source, which is needed inside RenderJob.render(PoseStack, MultiBufferSource).
      Parameters:
      stack - The item stack to render.
      displayContext - The display context (e.g. ItemDisplayContext.GUI).
      poseStack - The current pose stack.
      buffer - The buffer source to render into.
      packedLight - Packed light value.
      packedOverlay - Packed overlay value.
    • renderGuiBackground

      public static void renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height)
      Same as renderGuiBackground but with pre-set texture.
    • renderGuiBackground

      public static void renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height, net.minecraft.resources.Identifier texture)
    • renderGuiBackground

      public static void renderGuiBackground(com.mojang.blaze3d.pipeline.RenderPipeline pipeline, net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y, int width, int height, net.minecraft.resources.Identifier texture, int textureX, int textureY, int minU, int maxU, int minV, int maxV)
      Renders a gui background of any size. This is created from the chest GUI texture and should work with texture packs. The width and height must be at least 9.
      Parameters:
      x - The x position for the top left corner.
      y - The y position for the top left corner.
      width - The width of the GUI background
      height - The height of the GUI background
      texture - The texture to use for the GUI background
      textureX - Texture size x
      textureY - Texture size y
      minU - The minimum u position for the filling part of the texture
      maxU - The maximum u position for the filling part of the texture
      minV - The minimum v position for the filling part of the texture
      maxV - The maximum v position for the filling part of the texture