scoreboard players set *temp temp 0
execute unless data block ~ ~ ~ Items[{Slot:$Xb}] run loot replace block ~ ~ ~ container.$X loot piyo:technical/machine_blank 
execute unless data block ~ ~ ~ Items[{Slot:$Xb,tag:{machine_ui:1}}] store success score *temp temp run item replace block 0 0 0 container.0 from block ~ ~ ~ container.$X
execute if score *temp temp matches 1 run loot replace block ~ ~ ~ container.$X loot piyo:technical/machine_blank
execute if score *temp temp matches 1 as @p run function piyo:player/inventory/give_item