Skip to content

VanillaSpriteTexture

Since 2.2.1

VanillaSpriteTexture renders a sprite that is already registered in Minecraft's vanilla GUI atlas. Use it when you want to draw a vanilla UI sprite such as the recipe-book toast icon or other atlas-backed GUI parts.

Unlike SpriteTexture, this texture does not load a PNG file from your mod's assets/ directory. The sprite value must be the identifier of a sprite available in the vanilla GUI atlas.

Sprite identifiers follow Minecraft's blitSprite convention: they are relative to textures/gui/sprites and do not include the file extension. For example, minecraft:toast/recipe_book points to assets/minecraft/textures/gui/sprites/toast/recipe_book.png. To register and configure GUI sprites, see the NeoForge Screens texture documentation.

Registry name: vanilla_sprite_texture

INFO

Extends TransformTexture - supports rotate(), scale(), transform(), and color tinting.

TIP

Use SpriteTexture for your own image files. Use VanillaSpriteTexture when the image is provided by Minecraft's GUI atlas.


Usage

java
IGuiTexture toastIcon = VanillaSpriteTexture.of("minecraft:toast/recipe_book");

IGuiTexture tinted = VanillaSpriteTexture.of("minecraft:toast/recipe_book")
    .setColor(0xFFFFAA44);

LSS

css
/* Vanilla GUI atlas sprite */
background: vanilla-sprite(minecraft:toast/recipe_book);

/* With transform chain */
background: vanilla-sprite(minecraft:toast/recipe_book) scale(0.8) rotate(15);

/* With color tint */
background: vanilla-sprite(minecraft:toast/recipe_book) color(#FFFFAA44);

Fields

NameTypeDescription
spriteIdentifierIdentifier of the sprite in Minecraft's GUI atlas. Default: minecraft:toast/recipe_book.
colorintARGB color tint. Default: 0xFFFFFFFF (no tint).

Methods

MethodReturnsDescription
VanillaSpriteTexture.of(String)VanillaSpriteTextureStatic factory from a resource-location string.
VanillaSpriteTexture.of(Identifier)VanillaSpriteTextureStatic factory from an Identifier.
setSprite(Identifier)VanillaSpriteTextureChanges the vanilla GUI atlas sprite.
setColor(int)VanillaSpriteTextureSets the ARGB tint color.
copy()VanillaSpriteTextureReturns a deep copy.

Released under the MIT License.