Package org.cyclops.cyclopscore.helper
Class RenderHelpers
java.lang.Object
org.cyclops.cyclopscore.helper.RenderHelpers
A helper for rendering.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Runnable forrenderFluidContext(FluidStack, PoseStack, IFluidContextRender)
}}. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final com.google.common.base.Function<net.minecraft.resources.ResourceLocation,
net.minecraft.client.renderer.texture.TextureAtlasSprite> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.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
isPointInRegion
(Rectangle region, Point point) 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.
-
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 graphicsfontRenderer
- The font rendererstring
- The string to drawx
- The center Xy
- The center Yscale
- The scale to render the string by.color
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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 stackfontRenderer
- The font renderermultiBufferSource
- The buffer sourcestring
- The string to drawx
- The center Xy
- The center Yscale
- The scale to render the string by.color
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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 graphicsfontRenderer
- The font rendererstring
- The string to drawx
- The center Xy
- The center YmaxWidth
- The maximum width to scale tocolor
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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 stackfontRenderer
- The font renderermultiBufferSource
- The buffer sourcestring
- The string to drawx
- The center Xy
- The center YmaxWidth
- The maximum width to scale tocolor
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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 graphicsfontRenderer
- The font rendererstring
- The string to drawx
- The center Xy
- The center Ywidth
- The scaled widthoriginalScale
- The original scalemaxWidth
- The maximum width to scale toshadow
- If a shadow should be drawndisplayMode
- 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 stackfontRenderer
- The font renderermultiBufferSource
- The buffer sourcestring
- The string to drawx
- The center Xy
- The center Ywidth
- The scaled widthoriginalScale
- The original scalemaxWidth
- The maximum width to scale toshadow
- If a shadow should be drawndisplayMode
- 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 graphicsfontRenderer
- The font rendererstring
- The string to drawx
- The center Xy
- The center Ywidth
- The scaled widthscale
- The desired scalecolor
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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 stackmultiBufferSource
- The buffer sourcefontRenderer
- The font rendererstring
- The string to drawx
- The center Xy
- The center Ywidth
- The scaled widthscale
- The desired scalecolor
- The color to drawshadow
- If a shadow should be drawndisplayMode
- 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, getFluidVertexBufferColorFloat> (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 xtop
- Left-top corner ywidth
- The widthheight
- The heightpointX
- The point xpointY
- The point y- Returns:
- If the point is inside the region.
-
isPointInRegion
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 xpointY
- 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)
-