
# --> Menu Operation: Iron chestplate confirmation

# -> Reset costs
function overly_realistic:general/custom_blocks/lay_figure/menu_interactions/reset_resource_requirements

# -> Set base cost
scoreboard players set @s OverlyRealistic.World.LayFigure_ResourceRequirement_0 3
tag @s add OverlyRealistic.Block.LayFigure_ResourceRequirement_NeedsIronPlates


# --> Set additional costs

# -> Iron mail
execute if score #or.lay_figure_data_button_1 OverlyRealistic.General.ArbitraryData matches 1 run \
    scoreboard players add @s OverlyRealistic.World.LayFigure_ResourceRequirement_1 3
execute if score #or.lay_figure_data_button_1 OverlyRealistic.General.ArbitraryData matches 1 run \
    tag @s add OverlyRealistic.Block.LayFigure_ResourceRequirement_NeedsIronChainMesh

# -> Pouldron
execute if score #or.lay_figure_data_button_2 OverlyRealistic.General.ArbitraryData matches 1 run \
    scoreboard players add @s OverlyRealistic.World.LayFigure_ResourceRequirement_0 2

# -> Pouldron and vambrance
execute if score #or.lay_figure_data_button_3 OverlyRealistic.General.ArbitraryData matches 1 run \
    scoreboard players add @s OverlyRealistic.World.LayFigure_ResourceRequirement_0 5

# -> Iron gauntlet
execute if score #or.lay_figure_data_button_5 OverlyRealistic.General.ArbitraryData matches 1 run \
    scoreboard players add @s OverlyRealistic.World.LayFigure_ResourceRequirement_0 2



# -> Create cost display
summon minecraft:text_display ~ ~ ~ {Tags:["OverlyRealistic.Block.LayFigure_TempCostDisplay","OverlyRealistic.Block.LayFigure_CostDisplay"], alignment: "center", background: 1694497530, billboard: "vertical", default_background: 0b, line_width: 200, see_through: 0b, shadow: 0b, text: {color: "black", extra: [{color: "black", text: "COST:\n", font:"overlyrealistic:small_caps"},{color: "black", text: "\u0041", font:"overlyrealistic:icons"},{color: "black", text: " 0/0", font:"overlyrealistic:small_caps"}], text: ""}, text_opacity: -1b, transformation: {left_rotation: [0.0f, 0.0f, 0.0f, 1.0f], right_rotation: [0.0f, 0.0f, 0.0f, 1.0f], scale: [1.0f, 1.0f, 1.0f], translation: [0.0f, 0.3f, 0.0f]}}

# -> Attach cost display
execute align xyz run \
    ride @n[type=text_display,tag=OverlyRealistic.Block.LayFigure_TempCostDisplay,dx=0,dy=1,dz=0,sort=arbitrary] mount @s

# -> Operate on cost display
execute on passengers \
    if entity @s[tag=OverlyRealistic.Block.LayFigure_TempCostDisplay] run \
        function overly_realistic:general/custom_blocks/lay_figure/menu_interactions/operate_from_confirmation/sub_ops/sub_op_1001
