
execute unless data storage sgrave:temp graves_list[] run return fail

scoreboard players add @s sgrave.del_num 1

execute store result storage sgrave:temp gid int 1 run data get storage sgrave:temp graves_list[-1].gid
data modify storage sgrave:temp dimension set from storage sgrave:temp graves_list[-1].dimension
execute store result storage sgrave:temp x int 1 run data get storage sgrave:temp graves_list[-1].pos[0]
execute store result storage sgrave:temp y int 1 run data get storage sgrave:temp graves_list[-1].pos[1]
execute store result storage sgrave:temp z int 1 run data get storage sgrave:temp graves_list[-1].pos[2]

data merge storage sgrave:temp {grave:{gid:0,x:0,y:0,z:0,dimension:""}}
data modify storage sgrave:temp grave.gid set from storage sgrave:temp gid
data modify storage sgrave:temp grave.dimension set from storage sgrave:temp dimension
data modify storage sgrave:temp grave.x set from storage sgrave:temp x
data modify storage sgrave:temp grave.y set from storage sgrave:temp y
data modify storage sgrave:temp grave.z set from storage sgrave:temp z

execute store result storage sgrave:temp del_num int 1 run scoreboard players get @s sgrave.del_num

function snapgrave:dialog/actions with storage sgrave:temp

data remove storage sgrave:temp graves_list[-1]

execute if data storage sgrave:temp graves_list[] run function snapgrave:dialog/get_grave