Wiki 9Minecraft Wiki 9Minecraft
Librarianlib Wiki › Guides › Use Sprite Sheets for Clean GUI Textures

Use Sprite Sheets for Clean GUI Textures

Data-Driven Sprite Sheet System

LibrarianLib lets you define sprite sheets declaratively, keeping texture coordinates out of your GUI code.

Setting Up a Sprite Sheet

1. Create a sprite sheet definition (usually in JSON or through code) that maps named sprites to regions of your texture file

2. Reference sprites by name in your GUI components instead of calculating UV coordinates manually

3. The library handles texture binding and coordinate math automatically during rendering

Benefits

When you need to adjust a sprite's position or size in your texture atlas, update the definition once—all GUI elements using that sprite update automatically. This prevents the common mistake of hardcoding texture coordinates that break when you reorganize your texture file.

Implementation

Define sprites for buttons, backgrounds, icons, and other UI elements. In your GUI class, reference them by name when creating visual components. The system scales sprites correctly for different GUI scales and resolutions.