OptiGUI icon indicating copy to clipboard operation
OptiGUI copied to clipboard

[BUG, FEATURE REQUEST] GUI sprites support

Open Vi-Tul opened this issue 10 months ago • 1 comments

Feature description

Since version 3.0 uses the advanced json format, it would be great to be able to change sprites depending on the GUI. As I understand, there is already some movement in this direction. F.e. using inspector in villager GUI, it allows to change this textures:

{
  "textures": {
    "minecraft:textures/gui/container/villager.png": "example:path/to/changed/texture.png",
    "minecraft:widget/button": "example:path/to/changed/texture.png",
    "minecraft:container/villager/scroller": "example:path/to/changed/texture.png",
    "minecraft:container/villager/trade_arrow": "example:path/to/changed/texture.png",
    "minecraft:container/villager/experience_bar_background": "example:path/to/changed/texture.png",
    "minecraft:container/villager/experience_bar_current": "example:path/to/changed/texture.png"
  },
}

The issue is that you can't really change them, because it results in a missing textures, hence the BUG in the title Image

Another usecase could be to independently change sprites in Inventory, Smithing table and Enchanting table GUIs, since in vanilla they are all using sprites from sprites\container\slot and intersect with each other

Vi-Tul avatar Mar 01 '25 18:03 Vi-Tul

Indeed this is a bug.

I spent way too much time trying to figure out sprites with my other mod. Sprites are compiled into an atlas from the resource packs' <namespace>:textures/gui/sprites folders, and don't have the PNG extension (that's why you see minecraft:widget/button instead of minecraft:textures/gui/sprites/widget/button.png).

OptiGUI checks for the presence of the replacement textures, so the workaround is to do something like this:

  • Place the texture to /assets/example/textures/gui/sprites/path/to/texture.png
  • Set the replacement sprite to example:path/to/texture
  • Place an empty file to /assets/example/path/to/texture

I reckon I should split "textures": {} into "change_textures": {} and "change_sprites": {}, as well as document this to clear up confusion among resource pack creators.

Renaming if to load_if and match to match_nbt could also be beneficial.

opekope2 avatar Mar 02 '25 13:03 opekope2