
# -> If 'disable genetics' is enabled then return and tag the player
execute if score #or.setting.disable_genetics OverlyRealistic.Settings.ArbitrarySetting matches 1 run \
    return run \
        function overly_realistic:players/custom_data/disabled_genetics_add_player

# -> Spawn protection
execute if score #or.setting.spawn_protection OverlyRealistic.Settings.ArbitrarySetting matches 1 run \
    effect give @s resistance 8 250 true

# -> Apply data holder
item replace entity @s armor.body with poisonous_potato\
    [\
        custom_data=\
            {\
                overly_realistic_data_holder: 1b, \
                last_version_modified: "v3.0.3", \
                last_version_modified_id: 15i, \
                attribute_modifiers_on_death: [] \
            },\
        enchantments=\
            {\
                binding_curse: 1, \
                "overly_realistic:or_internal_dataholder": 1 \
            },\
        equippable=\
            {\
                slot:"body", \
                damage_on_hurt:false, \
                equip_sound:"intentionally_empty", \
                swappable:false \
            }\
    ]

# -> Apply data
function overly_realistic:players/custom_data/apply_general_data

# -> Apply random data
function overly_realistic:players/custom_data/get_random_data

# -> Apply scale balances
function overly_realistic:players/custom_data/scale_balance

# -> Function tag
function #overly_realistic:mechanics/player_spawn_data

# -> Advancements
advancement grant @s only overly_realistic:advancements/livelyhood/evolutionary_encoding

advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/husbandry/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/archery/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/mining/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/equitation/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/healthcare/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/combat/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/fishing/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/cookery/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/building/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/blacksmithing/level_0
advancement grant @s only overly_realistic:advancements/livelyhood/wisdom_children/scribing/level_0

# -> Remove physical traumas
function overly_realistic:main/debug/stats/remove_physical_trauma

# -> Set stamina to max stamina
scoreboard players operation @s OverlyRealistic.Player.Stats.Stamina = @s OverlyRealistic.Player.Stats.MaxStamina

# -> If available slots are full then return and spawn as ghost
execute if score #or.setting.current_player_slots OverlyRealistic.General.ArbitraryData >= #or.setting.max_available_player_slots OverlyRealistic.Settings.ArbitrarySetting run \
    return run \
        function overly_realistic:players/custom_data/spawn_as_ghost

# -> Add onto global value
scoreboard players add #or.setting.current_player_slots OverlyRealistic.General.ArbitraryData 1
