A5b84 / armor-chroma-fabric

Fabric fork of the original Armor Chroma mod by jobicade, adds different icons in the armor bar depending on the material and can display glint for enchanted items.
https://www.curseforge.com/minecraft/mc-mods/armor-chroma-for-fabric
GNU General Public License v3.0
13 stars 3 forks source link

[Suggestion] Make sprites for armors data-driven #8

Closed ejektaflex closed 2 years ago

ejektaflex commented 2 years ago

It would be nice if armor sprites were each defined in their own PNG files, and JSON files could define what texture is associated with a given piece of armor. This way, users can add their own custom armor looks via resource packs.

Thanks!

A5b84 commented 2 years ago

You can already change them using resource packs, see this :)

This doesn't allow changing individual icons though, it ~overwrites all icons for materials with the same namespace (minecraft in this case), and I feel like having multiple conflicting resource packs each changing one specific icon from the same namespace may be too rare/specific to be worth it

ejektaflex commented 2 years ago

Yeah, that's exactly why it would be nice to make them data driven. With the current way it is, other mods can not specify their own armor data for armor chroma, because any data they specify would be an overwrite of the main spritesheet :'(

I'm using an armor set from Additional Additions, for example, and the game thinks that the set is made up of two different pieces that don't connect icon-wise, which is a bit of a bummer.

Instead, it would be more useful to have definitions, e.g. if a mod adds copper:

{
  "texture": "mymod:copper_heart", // or some such
  "pieces": {
    "helmet": "mymod:copper_helmet",
    "chestplate": "mymod:copper_chestplate",
    "leggings": "mymod:copper_leggings",
    "boots": "mymod:copper_boots"
  }
}

Then, have a separate file at the resource location of mymod:copper_heart in the textures folder. It probably would just need to be 32x32.

This way, anybody can specify their own armors that are associated with specific textures.

I actually don't understand how to apply your current system to other mods - you do it for the Minecraft namespace, but what about any other mod? E.g. Additional Additions? You put a sprite sheet somewhere - sure, but where on the sheet does it pull the icons from? Probably the top left, but in what order? If AA has several armor sets, how do I know which order to place the icons in?

A5b84 commented 2 years ago

Looking back on my example it's definitely not the best one so here is another one, TLDR: example resource pack at the bottom

I actually don't understand how to apply your current system to other mods - you do it for the Minecraft namespace, but what about any other mod?

Currently, each namespace/mod ID has its own json file defining the location of materials in a spritesheet. The json file is located at assets/<modid>/textures/gui/armor_chroma.json and the spritesheet at assets/<modid>/textures/gui/armor_chroma.png, for instance to add icons to Additional Additions, you would replace <modid> you would replace <modid> with additionaladditions (meaning the files will only be overwritten if another resource pack also adds icons for Additional Additions).

You can get the namespace of an item by enabling advanced tooltips (by pressing F3+H): image

You put a sprite sheet somewhere - sure, but where on the sheet does it pull the icons from? Probably the top left, but in what order?

The json file should look something like this (the example in my first comment didn't have it since it didn't need to overwrite the default one):

{
    "items": { // items that don't have materials (i.e. aren't armor pieces) but still add armor
        "wrench": 0, // `additionaladditions:wrench` (the orange icon, requires attribute modifiers)
        "music_disc_*": -1 // any item whose ID starts with `additionaladditions:music_disc_`
        // (the black icon at the bottom right, requires attribute modifiers too)
    },
    "materials": {
        "rose_gold": 2 // armor pieces with namespace `additionaladditions` and material `rose_gold` (the pink icon)
    },
    "special": {
        "default": 3 // If an item adds armor and it's not assigned an icon in the `materials` and `items` section,
        // it will use this icon (the gray/light blue one). If this icon is not specified (by removing this line),
        // it will use the default default icon (the vanilla iron icon).
    }
}

and the spreadsheet like this: armor_chroma

The numbers refer to the location of the corresponding icon in the spritesheet

You can use the same number multiple times (all entries with the same number will use the one icon at the corresponding location), you can skip numbers (1 in this example, though it's not really useful), and negative numbers have no other meaning than looking for icons starting at the bottom right instead of the top left.

Note that currently icons need to have the same shape as vanilla icons, and the item-specific icons don't work because of a bug I introduced when porting the mod (fixed in ed72db4).

If AA has several armor sets, how do I know which order to place the icons in?

The order in the json file doesn't matter, you just need to make sure the numbers match their icon. If a mod has multiple armor materials, you can add one line per material:

    ...
    "materials": {
        "rose_gold": 2,
        "gilded_netherite": 3
    },
    ...

Result with:

Example Armor Chroma Pack.zip

ejektaflex commented 2 years ago

This looks great and is very helpful - thank you much! This is what I was looking for - I missed the fact that armor chroma had it's own json definition for the spritesheet. 👍