# entity:sculk_spider/summon_baby
# called by: entity:sculk_spider/spawn, entity:sculk_spider/hit

## 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 ["",{"translate":"arguments.magical_addons.summon.invalid","color":"red"}]

## Summon
summon cave_spider ~ ~ ~ {Silent:1,CustomName:{"translate":"entity.magical_addons.sculk_spider"},DeathLootTable:"magical_addons:entities/sculk_spider",Health:64.0,attributes:[{id:follow_range,base:99.0d},{id:movement_speed,base:0.36d},{id:jump_strength,base:0.5d},{id:fall_damage_multiplier,base:0.0},{id:max_health,base:64.0},{id:scale,base:0.6d},{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.sculk_spider","maddons.entity","maddons.custom_step_sound","maddons.vehicle"],data:{magical_addons:{sound:"execute at @s as @a run playsound entity.spider.step hostile @a ~ ~ ~ 0.25",sound_time:3}},                                                                                                                         Passengers:[{id:"item_display",Tags:[maddons.root,maddons.entity,maddons.sculk_spider],                                                                                                                        Passengers:[{id:"item_display",data:{magical_addons:{tick_cmd:"function magical_addons:entity/sculk_spider/tick",brain_cmd:"function magical_addons:entity/sculk_spider/brain"}},item_display:"head",teleport_duration:3,shadow_strength:1.5,shadow_radius:0.75,item:{id:"potion",components:{item_model:"magical_addons:entity/sculk_spider_baby",custom_model_data:{strings:["body"],flags:[0b],floats:[0f]}}},view_range:300f,Tags:["maddons.entity.baby","maddons.entity.brain","maddons.entity.ai","maddons.entity","maddons.entity.tickable","maddons.sculk_spider","maddons.bone.body","maddons.bone"]},                                                                                                                         {id:"item_display",item_display:"head",item:{id:"potion",components:{item_model:"magical_addons:entity/sculk_spider_baby",custom_model_data:{strings:["head"],flags:[0b]}}},view_range:300f,teleport_duration:3,Tags:["maddons.sculk_spider","maddons.entity","maddons.bone.head","maddons.bone"]}]}]}

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