#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#
#  This Datapack was generated for private distribution only  #
# ----------------------------------------------------------- #
#                         DATAPACK INFO                       #
# ----------------------------------------------------------- #
#     Author: GenMode                                         #
#     Twitter: @DatapackGen                                   #
#     URL: https://github.com/GenMode/Minecraft/wiki          #
#                                                             #
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#


# Init
scoreboard objectives add temp.data_api.store dummy
execute positioned ^ ^ ^-0.1 as @n[type=minecraft:marker, tag=temp.data_api.raycast] run tp @s ~ ~ ~

# Calculate
execute store result score *height temp.data_api.store run data get entity @s Pos[1] 100
function data_api:command/calculate {args:{operation:"divide", input:{score:{name:"*height", objective:"temp.data_api.store"}}, input2:100, output:{score:{name:"*height2", objective:"temp.data_api.store"}}}}
function data_api:command/calculate {args:{operation:"multiply", input:{score:{name:"*height2", objective:"temp.data_api.store"}}, input2:100, output:{score:{name:"*height2", objective:"temp.data_api.store"}}}}
scoreboard players operation *height temp.data_api.store -= *height2 temp.data_api.store
$execute store result score *width temp.data_api.store run data get entity @s Pos[$(mode)] 100
function data_api:command/calculate {args:{operation:"divide", input:{score:{name:"*width", objective:"temp.data_api.store"}}, input2:100, output:{score:{name:"*width2", objective:"temp.data_api.store"}}}}
function data_api:command/calculate {args:{operation:"multiply", input:{score:{name:"*width2", objective:"temp.data_api.store"}}, input2:100, output:{score:{name:"*width2", objective:"temp.data_api.store"}}}}
scoreboard players operation *width temp.data_api.store -= *width2 temp.data_api.store

# If Score
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 51..100 if score *width temp.data_api.store matches $(rangeA) run function data_api:item/tags/book/check_hand {slot:"0"}
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 51..100 if score *width temp.data_api.store matches $(rangeB) run function data_api:item/tags/book/check_hand {slot:"1"}
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 51..100 if score *width temp.data_api.store matches $(rangeC) run function data_api:item/tags/book/check_hand {slot:"2"}
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 0..50 if score *width temp.data_api.store matches $(rangeA) run function data_api:item/tags/book/check_hand {slot:"3"}
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 0..50 if score *width temp.data_api.store matches $(rangeB) run function data_api:item/tags/book/check_hand {slot:"4"}
$execute as @p[tag=temp.data_api.user] if score *height temp.data_api.store matches 0..50 if score *width temp.data_api.store matches $(rangeC) run function data_api:item/tags/book/check_hand {slot:"5"}

# Close
scoreboard objectives remove temp.data_api.store
