
# -> Decrease stamina
scoreboard players remove @s OverlyRealistic.Player.Stats.Stamina 10

# -> Sound
playsound block.wood.place block @a ~ ~ ~ 0.5 1

# --> Extend beam

# -> Get how many beam-dependent blocks the player has
scoreboard players set #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 0
execute store result score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData \
    if items entity @s container.* acacia_fence

# -> If the player is in creative then set count to infinite
execute if entity @s[gamemode=creative] run \
    scoreboard players set #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 999

# -> If the player has no required blocks then return
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        scoreboard players set #or.support_beam_should_break OverlyRealistic.General.ArbitraryData 1

# -> Extension 1
setblock ~ ~ ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 1

# -> Extension 2
execute unless block ~ ~1 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 1
setblock ~ ~1 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 2

# -> Extension 3
execute unless block ~ ~2 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 2
setblock ~ ~2 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 3

# -> Extension 4
execute unless block ~ ~3 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 3
setblock ~ ~3 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 4

# -> Extension 5
execute unless block ~ ~4 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 4
setblock ~ ~4 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 5

# -> Extension 6
execute unless block ~ ~5 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 5
setblock ~ ~5 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 6

# -> Extension 7
execute unless block ~ ~6 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 6
setblock ~ ~6 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 7

# -> Extension 8
execute unless block ~ ~7 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 7
setblock ~ ~7 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 8

# -> Extension 9
execute unless block ~ ~8 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 8
setblock ~ ~8 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
scoreboard players remove #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData 1
execute if score #or.player_beam_dependent_blocks OverlyRealistic.General.ArbitraryData matches ..0 run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 9

# -> Extension 10
execute unless block ~ ~9 ~ #overly_realistic:support_beams/support_beam_can_replace run \
    return run \
        clear @s[gamemode=!creative] acacia_fence 9
setblock ~ ~9 ~ acacia_fence[east=false,north=false,south=false,west=false] strict
clear @s[gamemode=!creative] acacia_fence 10
