Patchouli

Patchouli

167M Downloads

[Request] Dynamic icons

chimericdream opened this issue ยท 0 comments

commented

Describe the feature

Similar to how we can use flags to dynamically show or hide categories or entries based on some runtime configuration, I'd like to be able to do something similar for icons. Here's a real-world example based on my current needs:

I have a category called "Furniture" which has a number of entries underneath it, including:

  • Tables
  • Chairs
  • Stools
  • Display Cases
  • etc.

I have recently added config to allow users to enable or disable certain item groups. Based on these configs, I can easily hide individual entries in the category, but the category icon is problematic. By default, I use an ItemStack string for one of my mod's tables, but if tables are disabled, I'd like to use a chair instead, or a stool, or display case, and so on...

What I'd like to be able to do is something like the following (exact syntax not important, just the core functionality):

categories/furniture.json

{
    "name": "Furniture",
    "description": "...",
    "icon": "provider!minekea:furniture_icon"
}

Mod init code

MinekeaConfig config = ConfigManager.getConfig();
IPatchouliAPI patchouli = PatchouliAPI.get();

patchouli.addIconProvider(
    "minekea:furniture_icon",
    () -> {
        // do some logic here, checking configs, etc
        return "minekea:some_id...";
        // OR
        // return "minekea:blocks/some/path/icon.png";
    }
);

Additional context

I'd be happy to take a stab at contributing this change myself if people think it'd be worthwhile.