stewbeet.plugins.check_unused_textures

The check_unused_textures plugin analyzes texture usage in resource packs.
It scans all PNG files in the textures folder, compares them with texture references
in the generated resource pack, and provides warnings for unused texture files
to help optimize resource pack size and identify orphaned assets.

Required: meta.stewbeet.textures_folder configuration
Required: Beet context with resource pack assets
Position: Must run after all texture-generating plugins
Related: Works with any plugins that generate textures

Feature Showcase

Warning message in terminal:

Source Code: stewbeet/plugins/check_unused_textures/__init__.py

What it does

  • Identifies unused texture files in the resource pack
  • Analyzes texture references across all generated assets
  • Provides warnings for orphaned texture files
  • Helps optimize resource pack size by finding unused assets
  • Generates detailed reports of unused texture paths
  • Assists in resource pack cleanup and maintenance

Configuration

Basic Example Configuration

yaml
pipeline:
  - ...
  - stewbeet.plugins.check_unused_textures  # Should run after all texture-generating plugins
  - ...

meta:
  stewbeet:
    textures_folder: "assets/textures"  # Required: path to textures folder

Configuration Options

OptionTypeDefaultDescription
textures_folderstringRequiredPath to the folder containing PNG texture files
Warning OutputautomaticEnabledShows warnings for unused textures in console
File Extensionconstant.pngOnly PNG files are analyzed for texture usage
Path ComparisonautomaticRelativeCompares relative paths from textures folder

Features

Texture Discovery System

Scans the textures folder for all PNG files:

  • πŸ“ Recursively searches the configured textures folder
  • πŸ–ΌοΈ Identifies all PNG files using glob pattern *.png
  • πŸ“ Calculates relative paths from the textures folder root
  • πŸ“Š Builds a texture inventory for analysis

Usage Analysis Engine

Compares texture files with resource pack references:

  • πŸ”— Checks each texture against ctx.assets.textures collection
  • 🎯 Handles both Texture objects and string references
  • βœ‚οΈ Removes file extensions for accurate path matching
  • πŸ” Uses endswith() matching for flexible path comparison

Unused Texture Detection

Identifies orphaned texture files not referenced in the pack:

  • 🚫 Detects textures with no matching references in the resource pack
  • πŸ“ Collects unused texture paths in a dedicated set
  • 🎯 Supports both direct texture objects and string path references
  • βœ… Ensures accurate detection through path matching

Warning Report Generation

Provides detailed warnings for unused textures:

  • πŸ“Š Sorts unused texture paths alphabetically for organized output
  • πŸ“ Shows complete file paths relative to textures folder
  • ⚠️ Generates multi-line warning messages with clear formatting
  • 🎨 Uses structured warning format for easy identification

Next steps