BarrelGUI Return Misplaced Item
I am making a barrel gui. The function of it doesn't matter at the moment. It sets the gui with
Continue to help postitem replace block ~ ~ ~ container.0 with structure_void[custom_model_data=0,max_stack_size=1,hide_tooltip={},custom_data={"tag":"trade_station_ui"}] 1
repeated for every slot that should be "locked".
To keep it locked, I run a function every tick as the custom item display. The function checks those slots with execute unless items block ~ ~ ~ container.0 minecraft:structure_void[minecraft:custom_data={"tag":"trade_station_ui"}] run function mcrossing:resource_trade_base/gui/fix_ui
repeated for every slot that should be "locked".
fix_ui currently just clears any gui element from all inventories, and then redoes the set grid function. This works, fine except for one thing.
If you misplace an item into the grid, the item gets deleted forever. I simply want to find out how to detect if an item is in the wrong slot as opposed to it being empty, as well as what command would automatically put the item back into your inventory, so that if you accidentally put a gold bar in a slot, it gets returned to you.