#take UUID part 1, divide by 9 and take the remainder to get a random number between 0 and 8. Subtract 4 to shift the number range from -4 to +4. Then get the current X coord and subtract the random number from it.
execute at @s run execute store result score @s KyuDummy run data get entity @s UUID[0] .1
scoreboard players set @s KyuDummy2 9
scoreboard players operation @s KyuDummy %= @s KyuDummy2
scoreboard players remove @s KyuDummy 4
execute at @s run execute store result score @s PosX run data get entity @s Pos[0] 1
execute as @s run scoreboard players operation @s PosX -= @s KyuDummy
execute as @s run execute store result entity @s Pos[0] double 1 run scoreboard players get @s PosX



#same as before, but with the Z coord this time
execute at @s run execute store result score @s KyuDummy run data get entity @s UUID[2] .1
scoreboard players set @s KyuDummy2 9
scoreboard players operation @s KyuDummy %= @s KyuDummy2
scoreboard players remove @s KyuDummy 4
execute at @s run execute store result score @s PosZ run data get entity @s Pos[2] 1
execute as @s run scoreboard players operation @s PosZ -= @s KyuDummy
execute as @s run execute store result entity @s Pos[2] double 1 run scoreboard players get @s PosZ

#center the marker on the current block
execute at @s run tp @s ~.5 ~ ~.5

#try to find solid ground with air above it by moving up a few blocks
execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s[tag=MoveUp] run tp @s ~ ~1 ~
tag @s remove MoveUp

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s[tag=MoveUp] run tp @s ~ ~1 ~
tag @s remove MoveUp

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s[tag=MoveUp] run tp @s ~ ~1 ~
tag @s remove MoveUp

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s[tag=MoveUp] run tp @s ~ ~1 ~
tag @s remove MoveUp

##if it hasn't found air yet, move back down to the start
execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveBackDown
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveBackDown
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveBackDown
execute at @s[tag=MoveBackDown] run tp @s ~ ~-4 ~
#tag @s remove MoveBackDown




##same thing, but move down if it fails to find a spot by moving up. If all fails, die.
execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s[tag=MoveDown] run tp @s ~ ~-1 ~
tag @s remove MoveDown

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s[tag=MoveDown] run tp @s ~ ~-1 ~
tag @s remove MoveDown

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s[tag=MoveDown] run tp @s ~ ~-1 ~
tag @s remove MoveDown

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveDown
execute at @s[tag=MoveDown] run tp @s ~ ~-1 ~
tag @s remove MoveDown

execute at @s run execute unless block ~ ~1 ~ #suhc:bloodboltpassthrough run tag @s add MoveBackUp
execute at @s run execute unless block ~ ~ ~ #suhc:bloodboltpassthrough run tag @s add MoveBackUp
execute at @s run execute if block ~ ~-1 ~ #suhc:bloodboltpassthrough run tag @s add MoveBackUp
execute as @s[tag=MoveBackUp] run kill @s
