execute as @e[type=piglin,tag=!plussed] run data merge entity @s {DeathLootTable:"survivalplus:entities/piglin"}
#execute unless entity @e[tag=piglinmerchant] run execute as @e[type=piglin,predicate=survivalplus:2chance,tag=!plussed,limit=1] run data merge entity @s {CanPickUpLoot:0b,IsBaby:0b,IsImmuneToZombification:1b,CannotHunt:1b,CustomName:{"text":"Piglin Merchant"},Tags:[merchant_face,rare,plussed,spawnmerchant,piglinmerchant,piglinmerc,nopoly],equipment:{mainhand:{id:golden_pickaxe},feet:{id:golden_boots},legs:{id:leather_leggings,components:{dyed_color:11546150}},head:{id:leather_helmet}},DeathLootTable:"survivalplus:entities/merchant"}
#execute at @e[type=piglin,tag=spawnmerchant] run summon villager ~ ~ ~ {CustomName:"Piglin Merchant",VillagerData:{type:plains,profession:nitwit,level:99},Offers:{Recipes:[{maxUses:1,buy:{id:netherite_ingot},sell:{id:"minecraft:netherite_upgrade_smithing_template"}},{maxUses:2,buy:{id:gold_ingot,count:25},sell:{id:golden_pickaxe,components:{enchantments:{efficiency:5,fortune:2,unbreaking:3}}}},{maxUses:8,buy:{id:gold_ingot,count:18},sell:{id:enchanted_book,components:{stored_enchantments:{soul_speed:1}}}},{buy:{id:gold_ingot,count:22},sell:{id:enchanted_book,components:{stored_enchantments:{fire_protection:3}}}},{maxUses:12,buy:{id:gold_ingot,count:5},sell:{id:crimson_stem,count:2}},{maxUses:8,buy:{id:gold_ingot,count:12},sell:{id:crying_obsidian,count:4}},{buy:{id:gold_ingot,count:8},sell:{id:soul_sand,count:4}},{maxUses:8,buy:{id:gold_ingot,count:7},sell:{id:blackstone,count:20}},{maxUses:8,buy:{id:gold_ingot,count:6},sell:{id:quartz,count:12}},{buy:{id:gold_ingot,count:12},buyB:{id:blackstone,count:4},sell:{id:gilded_blackstone,count:4}},{buy:{id:netherrack,count:64},sell:{id:nether_gold_ore,count:8}},{maxUses:16,buy:{id:magma_block,count:16},sell:{id:gold_ingot}},{buy:{id:nether_wart,count:8},sell:{id:gold_ingot,count:8}},{maxUses:2,buy:{id:wither_skeleton_skull},sell:{id:gold_ingot,count:30}}]},CustomName:{"text":"Piglin Merchant"},Invulnerable:1b,NoAI:1b,Silent:1b,Tags:[merchant,plussed,pigmerchant,piglinmerc],Team:merchant,active_effects:[{id:invisibility,duration:-1,show_particles:0b}],equipment:{mainhand:{id:bundle}},drop_chances:{mainhand:0f}}
#execute as @e[tag=spawnmerchant,type=piglin] run tag @s remove spawnmerchant

execute if score hardmode hardmode matches 1 as @e[type=piglin,tag=!plussed,predicate=survivalplus:10chance] run data merge entity @s {IsBaby:0b,CannotHunt:0b,Health:40,Tags:[plussed],equipment:{mainhand:{id:crossbow,components:{enchantments:{"survivalplus:shotgun":1}}}},attributes:[{id:"knockback_resistance",base:0.5f},{id:"movement_speed",base:0.3f},{id:"max_health",base:40f},{id:"armor_toughness",base:8f}]}
execute if score hardmode hardmode matches 1 as @e[type=piglin,tag=!plussed,predicate=survivalplus:5chance] run data merge entity @s {IsBaby:0b,CannotHunt:0b,Health:40,Tags:[plussed],equipment:{mainhand:{id:crossbow,components:{enchantments:{"survivalplus:velocity":1}}}},attributes:[{id:"knockback_resistance",base:0.5f},{id:"movement_speed",base:0.3f},{id:"max_health",base:40f},{id:"armor_toughness",base:8f}]}

execute as @e[type=piglin,tag=!plussed,nbt={IsBaby:0b},predicate=survivalplus:20chance] run data merge entity @s {Tags:[plussed],equipment:{id:crossbow},Health:30,attributes:[{id:"knockback_resistance",base:0.5f},{id:"movement_speed",base:0.3f},{id:"max_health",base:30f},{id:"attack_damage",base:7f},{id:"armor_toughness",base:8f}]}
execute as @e[type=piglin,tag=!plussed,nbt={IsBaby:0b}] run data merge entity @s {equipment:{id:golden_sword},Health:30,attributes:[{id:"knockback_resistance",base:0.5f},{id:"movement_speed",base:0.3f},{id:"max_health",base:30f},{id:"attack_damage",base:4f},{id:"armor_toughness",base:8f}]}
execute as @e[type=piglin,tag=!plussed] run tag @s add plussed