# entity:automaton/summon
# called by: <dev>

## Errors
execute store result score #maddons.shared.difficulty maddons.temp run difficulty
execute if score #maddons.shared.difficulty maddons.temp matches 0 run return run tellraw @s ["",{"text":"This entity cannot be summoned in peaceful difficulty!","color":"red"}]

## Summon
summon husk ~ ~ ~ {PersistenceRequired:1b,Health:300.0,Silent:1,CustomName:{"translate":"entity.magical_addons.automaton"},DeathLootTable:"magical_addons:entities/automaton",attributes:[{id:knockback_resistance,base:1.0d},{id:movement_speed,base:0.23d},{id:fall_damage_multiplier,base:0.0},{id:max_health,base:300.0},{id:scale,base:4d},{id:burning_time,base:0.0},{id:attack_damage,base:0.0}],active_effects:[{id:"invisibility",amplifier:-1,duration:-1,show_particles:0b},{id:"fire_resistance",amplifier:-1,duration:-1,show_particles:0b}],Tags:["maddons.automaton","maddons.custom_step_sound","maddons.vehicle","maddons.entity.boss","maddons.entity"],data:{magical_addons:{sound:"execute on passengers on passengers as @s[tag=maddons.entity.brain] if entity @s[tag=maddons.entity.ai] on vehicle on vehicle at @s as @a run playsound magical_addons:entity.automaton.step hostile @s ~ ~ ~",sound_time:5}},                                                                            Passengers:[{id:"item_display",Tags:["maddons.entity","maddons.root","maddons.automaton"],                                                                            Passengers:[{id:"item_display",item_display:"head",data:{magical_addons:{brain_cmd:"function magical_addons:entity/automaton/brain",tick_cmd:"execute on vehicle on passengers unless score @s maddons.cooldown matches 0.. store result entity @s item.components.\"minecraft:custom_model_data\".floats[1] float 1 run data get storage magical_addons:tick data.entity.automaton.animations.walk.frame"}},teleport_duration:3,shadow_strength:1.5,shadow_radius:1.0,item:{id:"potion",components:{item_model:"magical_addons:entity/automaton/head",custom_model_data:{flags:[0b],floats:[0f,0f]}}},Tags:["maddons.automaton","maddons.bone","maddons.bone.head","maddons.entity","maddons.entity.ai","maddons.entity.brain","maddons.entity.tickable"]},                                                                            {id:"item_display",item_display:"head",teleport_duration:3,item:{id:"potion",components:{item_model:"magical_addons:entity/automaton/torso",custom_model_data:{flags:[0b],floats:[0f,0f]}}},Tags:["maddons.automaton","maddons.bone","maddons.entity","maddons.bone.torso"]},                                                                            {id:"item_display",item_display:"head",teleport_duration:3,item:{id:"potion",components:{item_model:"magical_addons:entity/automaton/arms",custom_model_data:{flags:[0b],floats:[0f,0f]}}},Tags:["maddons.automaton","maddons.bone","maddons.entity","maddons.bone.arms"]},                                                                            {id:"item_display",item_display:"head",teleport_duration:3,item:{id:"potion",components:{item_model:"magical_addons:entity/automaton/legs",custom_model_data:{flags:[0b],floats:[0f,0f]}}},Tags:["maddons.automaton","maddons.entity","maddons.bone","maddons.bone.legs"]}]}]}

## NBT
$execute as @n[type=husk,tag=maddons.vehicle,tag=maddons.automaton,tag=!maddons.entity.summoned] at @s run function magical_addons:entity/automaton/set_nbt {nbt:$(nbt)}