Skip to content
Edit this page

Texture Info

Added: 1.0.0

An interface representing textures. It is designed to make it easier to draw textures anywhere on the screen.

Use the static factory method create() to instantiate a new definition.


Methods

Return Type Signature
TextureInfo static create(@NotNull ResourceLocation texture, @Nullable Rectangle region)
ResourceLocation getTexture()
int getAtlasWidth()
int getAtlasHeight()
int getWidth()
int getHeight()
TextureUV getUV()
boolean isPixelSolid(int x, int y)
void render(PoseStack poseStack, int x, int y, Color color)

create

Added: 1.0.0

static TextureInfo create(@NotNull ResourceLocation texture, @Nullable Rectangle region)

Static factory method that instantiates a new instance pointing to a resource location and a region for cropping a sub-texture.

  • Texture: The resource location to the texture file.
  • Region: The region defining the cropped sub-texture. Pass null to use the whole texture.

getTexture

Added: 1.0.0

ResourceLocation getTexture()

Returns the ResourceLocation identifier pointing to the texture file.


getAtlasWidth

Added: 1.0.0

int getAtlasWidth()

Returns the width of the entire texture.


getAtlasHeight

Added: 1.0.0

int getAtlasHeight()

Returns the height of the entire texture.


getWidth

Added: 1.0.0

int getWidth()

Returns the width of the cropped sub-texture. Same as getAtlasWidth() if region was null.


getHeight

Added: 1.0.0

int getHeight()

Returns the height of the cropped sub-texture. Same as getAtlasHeight() if region was null.


getUV

Added: 1.0.0

TextureUV getUV()

Returns the TextureUV object that is used by the rendering methods.


isPixelSolid

Added: 1.0.0

boolean isPixelSolid(int x, int y)

Returns true if the pixel at the given local coordinates is solid (opaque).

The first time isPixelSolid() is called, it calculates and caches a bit mask to speed up consecutive checks.


render

Added: 1.0.0

void render(PoseStack poseStack, int x, int y, Color color)

Renders the texture onto the screen at the specified coordinates.

  • poseStack: The pose stack.
  • x: The GUI scaled screen X coordinate to be used as the left-most coordinate.
  • y: The GUI scaled screen Y coordinate to be used as the top-most coordinate.
  • color: The Color to tint the texture. Pass white for normal rendering.