#Detecting when items are changed

1 messages · Page 1 of 1 (latest)

lone horizon
#

Hi! Previously, I had been trying to create a custom GUI, but I decided to simplify it to just be a dropper with no button items. Players will place a wand in an item frame on top, and the custom block (which I have decided to call a Spell Altar) will display all the spells within that wand to be added to and removed at will. When the player is done, they will remove the wand and the block will be cleared, so the spells only exist inside the wand. This is a great idea in theory, but it's a lot of checks and functions, and I was wondering if I could make the updating functions only run when the items within the dropper are changed.

Tl;dr I need a way to detect when the items within a container are changed :3

broken steppeBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1733867017:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

lone horizon
#

This might be a lil more advanced lol

small cradle
#

I don't think there's any reasonable way to do something when the items in the dropper change that wouldn't itself just be more checks, essentially like standard custom GUI buttons

zenith nexus
#

it'll still work on the same basic principles as (probably) either of the gui tutorials sent in the other thread. you need to store the current items and previous items and then run the rest of the functions if there's a difference

small cradle
#

Should probably find some other way action to trigger the checks/updates. Can just be something like whenever the player clicks on the dropper, or clicks an Interaction Entity that you summon above it

lone horizon
lone horizon
zenith nexus
#

quick and dirty edit of what cloud wolf does that i'm fairly certain should work for a block entity:

data modify storage ns:ui previous set from entity @s data.previous
execute store success score #bool check run data modify entity @s data.previous set from storage ns:ui current

execute if score #bool check matches 1 run function ns:ui/change```
#

what happens here is: you put the current items into storage, and then you set the previous set of items into the same storage space, storing the success to a score. if it's the same items, the command will fail so the score will be zero

lone horizon
#

:DD

#

Thank you!!! ^^

zenith nexus
#

wait i just realized i pasted the wrong thing, hold on,

#

that should be correct for a block entity, executed as a marker in the same block.

lone horizon
#

Hmmmm

#

I'm going to try some of this later, I might be able to reuse a bunch of code lol

broken steppeBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.

broken steppeBOT
#
Closed for inactivity

This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.

#

Re-opened the channel. Make sure to close it again once you're done.