oldstuffs / SmartInventory

Moved to https://github.com/Infumia/InfumiaLib
MIT License
15 stars 1 forks source link

Updating icon item when clicked #112

Open gkhaavik opened 3 years ago

gkhaavik commented 3 years ago

I am trying to change the icon item that is clicked, and change it back once pressed again. How would I go about doing that? and also, how does blacklistPattern() work?

portlek commented 3 years ago

in the client event, there is an inventory content instance, so you can use it to put an icon to change the slot. and idk i didn't use the blacklist pattern im not sure.

gkhaavik commented 3 years ago
contents.set(SlotPos.of(1, 0), Icon.click(combatItem, clickEvent -> {
            // ENABLE

            // Make item glowing
            clickEvent.icon().item(ItemStackBuilder.from(combatItem.clone()).glow().itemStack())
                    .whenClick(clickEvent1 -> {
                        // DISABLE

                        // Make item not glowing
                        clickEvent1.icon().item(combatItem);
                    });
        }));

Like that?

portlek commented 3 years ago

uhm, not exactly, you have to make it in a method that is recursive. also, use the set method, don't change the item itself

gkhaavik commented 3 years ago

Can you give me an example?