Class RenderHelpers

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

public class RenderHelpers extends Object
A helper for rendering.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final com.google.common.base.Function<net.minecraft.resources.ResourceLocation,net.minecraft.client.renderer.texture.TextureAtlasSprite>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addBlockHitEffects(net.minecraft.client.particle.ParticleEngine particleManager, net.minecraft.client.multiplayer.ClientLevel world, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
    A custom way of spawning block hit effects.
    static void
    bindTexture(net.minecraft.resources.ResourceLocation texture)
    Bind a texture to the rendering engine.
    static void
    blitColored(net.minecraft.client.gui.GuiGraphics guiGraphics, int x, int y, int z, float u, float v, int width, int height, float r, float g, float b, float a)
     
    static void
    blitColored(net.minecraft.client.gui.GuiGraphics guiGraphics, int x, int y, int z, int width, int height, float u0, float u1, float v0, float v1, float r, float g, float b, float a)
     
    static void
    drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Deprecated.
    static void
    drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float originalScale, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Deprecated.
    static void
    drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Deprecated.
    static void
    drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Draw the given text with the given width and desired scale.
    static void
    drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float originalScale, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Draw the given text and scale it to the max width.
    static void
    drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Draw the given text and scale it to the max width.
    static void
    drawScaledString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Deprecated.
    static void
    drawScaledString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
    Draw the given text with the given scale with a shadow.
    static void
    emitParticle(net.minecraft.client.particle.Particle particle)
    Add a particle to the world.
    static net.minecraft.client.resources.model.BakedModel
    getBakedModel(net.minecraft.world.level.block.state.BlockState blockState)
    Retrieve the baked model from a given block state.
    static net.minecraft.client.renderer.texture.TextureAtlasSprite
    getBlockIcon(net.minecraft.world.level.block.Block block)
    Get the default icon from a block.
    static net.minecraft.client.resources.model.BakedModel
    getDynamicBakedModel(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
    Retrieve the potentially dynamic baked model for a position.
    static int
    getFluidBakedQuadColor(net.minecraftforge.fluids.FluidStack fluidStack)
    Get the fluid color to use in a baked quad.
    static net.minecraft.client.renderer.texture.TextureAtlasSprite
    getFluidIcon(net.minecraft.world.level.material.Fluid fluid, net.minecraft.core.Direction side)
    Get the icon of a fluid for a side in a safe way.
    static net.minecraft.client.renderer.texture.TextureAtlasSprite
    getFluidIcon(net.minecraftforge.fluids.FluidStack fluid, net.minecraft.core.Direction side)
    Get the icon of a fluid for a side in a safe way.
    static org.apache.commons.lang3.tuple.Triple<Float,Float,Float>
    getFluidVertexBufferColor(net.minecraftforge.fluids.FluidStack fluidStack)
    Get the fluid color to use in buffer rendering.
    static boolean
    isPointInButton(net.minecraft.client.gui.components.Button button, int pointX, int pointY)
    Check if a point is inside a button's region.
    static boolean
    isPointInRegion(int left, int top, int width, int height, double pointX, double pointY)
    Check if a point is inside a region.
    static boolean
    Check if a point is inside a region.
    static void
    renderFluidContext(net.minecraftforge.fluids.FluidStack fluid, com.mojang.blaze3d.vertex.PoseStack matrixStack, RenderHelpers.IFluidContextRender render)
    Prepare a render system context for rendering fluids.

    Methods inherited from class java.lang.Object

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

    • SLOT_SIZE

      public static final int SLOT_SIZE
      See Also:
    • TEXTURE_GETTER

      public static final com.google.common.base.Function<net.minecraft.resources.ResourceLocation,net.minecraft.client.renderer.texture.TextureAtlasSprite> TEXTURE_GETTER
  • Constructor Details

    • RenderHelpers

      public RenderHelpers()
  • Method Details

    • bindTexture

      public static void bindTexture(net.minecraft.resources.ResourceLocation texture)
      Bind a texture to the rendering engine.
      Parameters:
      texture - The texture to bind.
    • emitParticle

      public static void emitParticle(net.minecraft.client.particle.Particle particle)
      Add a particle to the world.
      Parameters:
      particle - A particle.
    • drawScaledString

      public static void drawScaledString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Draw the given text with the given scale with a shadow.
      Parameters:
      guiGraphics - The gui graphics
      fontRenderer - The font renderer
      string - The string to draw
      x - The center X
      y - The center Y
      scale - The scale to render the string by.
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledString

      @Deprecated public static void drawScaledString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Deprecated.
      Draw the given text with the given scale with a shadow.
      Parameters:
      matrixStack - The matrix stack
      fontRenderer - The font renderer
      multiBufferSource - The buffer source
      string - The string to draw
      x - The center X
      y - The center Y
      scale - The scale to render the string by.
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledCenteredString

      public static void drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Draw the given text and scale it to the max width.
      Parameters:
      guiGraphics - The gui graphics
      fontRenderer - The font renderer
      string - The string to draw
      x - The center X
      y - The center Y
      maxWidth - The maximum width to scale to
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledCenteredString

      @Deprecated public static void drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Deprecated.
      Draw the given text and scale it to the max width.
      Parameters:
      matrixStack - The matrix stack
      fontRenderer - The font renderer
      multiBufferSource - The buffer source
      string - The string to draw
      x - The center X
      y - The center Y
      maxWidth - The maximum width to scale to
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledCenteredString

      public static void drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float originalScale, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Draw the given text and scale it to the max width. The given string may already be scaled and its width must be passed in that case.
      Parameters:
      guiGraphics - The gui graphics
      fontRenderer - The font renderer
      string - The string to draw
      x - The center X
      y - The center Y
      width - The scaled width
      originalScale - The original scale
      maxWidth - The maximum width to scale to
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledCenteredString

      @Deprecated public static void drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float originalScale, int maxWidth, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Deprecated.
      Draw the given text and scale it to the max width. The given string may already be scaled and its width must be passed in that case.
      Parameters:
      matrixStack - The matrix stack
      fontRenderer - The font renderer
      multiBufferSource - The buffer source
      string - The string to draw
      x - The center X
      y - The center Y
      width - The scaled width
      originalScale - The original scale
      maxWidth - The maximum width to scale to
      shadow - If a shadow should be drawn
      displayMode - The display mode
    • drawScaledCenteredString

      public static void drawScaledCenteredString(net.minecraft.client.gui.GuiGraphics guiGraphics, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Draw the given text with the given width and desired scale.
      Parameters:
      guiGraphics - The gui graphics
      fontRenderer - The font renderer
      string - The string to draw
      x - The center X
      y - The center Y
      width - The scaled width
      scale - The desired scale
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The font display mode
    • drawScaledCenteredString

      @Deprecated public static void drawScaledCenteredString(com.mojang.blaze3d.vertex.PoseStack matrixStack, net.minecraft.client.renderer.MultiBufferSource multiBufferSource, net.minecraft.client.gui.Font fontRenderer, String string, int x, int y, int width, float scale, int color, boolean shadow, net.minecraft.client.gui.Font.DisplayMode displayMode)
      Deprecated.
      Draw the given text with the given width and desired scale.
      Parameters:
      matrixStack - The matrix stack
      multiBufferSource - The buffer source
      fontRenderer - The font renderer
      string - The string to draw
      x - The center X
      y - The center Y
      width - The scaled width
      scale - The desired scale
      color - The color to draw
      shadow - If a shadow should be drawn
      displayMode - The font display mode
    • getBakedModel

      public static net.minecraft.client.resources.model.BakedModel getBakedModel(net.minecraft.world.level.block.state.BlockState blockState)
      Retrieve the baked model from a given block state.
      Parameters:
      blockState - The block state.
      Returns:
      The corresponding baked model.
    • getDynamicBakedModel

      public static net.minecraft.client.resources.model.BakedModel getDynamicBakedModel(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos pos)
      Retrieve the potentially dynamic baked model for a position. This will automatically take into account smart block models.
      Parameters:
      world - The world.
      pos - The position.
      Returns:
      The baked model.
    • addBlockHitEffects

      public static void addBlockHitEffects(net.minecraft.client.particle.ParticleEngine particleManager, net.minecraft.client.multiplayer.ClientLevel world, net.minecraft.world.level.block.state.BlockState blockState, net.minecraft.core.BlockPos pos, net.minecraft.core.Direction side)
      A custom way of spawning block hit effects.
      Parameters:
      particleManager - The effect renderer.
      world - The world.
      blockState - The blockstate to render particles for.
      pos - The position.
      side - The hit side.
    • getBlockIcon

      public static net.minecraft.client.renderer.texture.TextureAtlasSprite getBlockIcon(net.minecraft.world.level.block.Block block)
      Get the default icon from a block.
      Parameters:
      block - The block.
      Returns:
      The icon.
    • getFluidIcon

      public static net.minecraft.client.renderer.texture.TextureAtlasSprite getFluidIcon(net.minecraft.world.level.material.Fluid fluid, net.minecraft.core.Direction side)
      Get the icon of a fluid for a side in a safe way.
      Parameters:
      fluid - The fluid.
      side - The side to get the icon from, UP if null.
      Returns:
      The icon.
    • getFluidIcon

      public static net.minecraft.client.renderer.texture.TextureAtlasSprite getFluidIcon(net.minecraftforge.fluids.FluidStack fluid, net.minecraft.core.Direction side)
      Get the icon of a fluid for a side in a safe way.
      Parameters:
      fluid - The fluid stack.
      side - The side to get the icon from, UP if null.
      Returns:
      The icon.
    • renderFluidContext

      public static void renderFluidContext(net.minecraftforge.fluids.FluidStack fluid, com.mojang.blaze3d.vertex.PoseStack matrixStack, RenderHelpers.IFluidContextRender render)
      Prepare a render system context for rendering fluids.
      Parameters:
      fluid - The fluid stack.
      matrixStack - The matrix stack.
      render - The actual fluid renderer.
    • getFluidVertexBufferColor

      public static org.apache.commons.lang3.tuple.Triple<Float,Float,Float> getFluidVertexBufferColor(net.minecraftforge.fluids.FluidStack fluidStack)
      Get the fluid color to use in buffer rendering.
      Parameters:
      fluidStack - The fluid stack.
      Returns:
      The RGB colors.
    • getFluidBakedQuadColor

      public static int getFluidBakedQuadColor(net.minecraftforge.fluids.FluidStack fluidStack)
      Get the fluid color to use in a baked quad.
      Parameters:
      fluidStack - The fluid stack.
      Returns:
      The BGR colors.
    • isPointInRegion

      public static boolean isPointInRegion(int left, int top, int width, int height, double pointX, double pointY)
      Check if a point is inside a region.
      Parameters:
      left - Left-top corner x
      top - Left-top corner y
      width - The width
      height - The height
      pointX - The point x
      pointY - The point y
      Returns:
      If the point is inside the region.
    • isPointInRegion

      public static boolean isPointInRegion(Rectangle region, Point point)
      Check if a point is inside a region.
      Parameters:
      region - The region.
      point - The point.
      Returns:
      If the point is inside the region.
    • isPointInButton

      public static boolean isPointInButton(net.minecraft.client.gui.components.Button button, int pointX, int pointY)
      Check if a point is inside a button's region.
      Parameters:
      button - The button.
      pointX - The point x
      pointY - The point y
      Returns:
      If the point is inside the button's region.
    • blitColored

      public static void blitColored(net.minecraft.client.gui.GuiGraphics guiGraphics, int x, int y, int z, float u, float v, int width, int height, float r, float g, float b, float a)
    • blitColored

      public static void blitColored(net.minecraft.client.gui.GuiGraphics guiGraphics, int x, int y, int z, int width, int height, float u0, float u1, float v0, float v1, float r, float g, float b, float a)