## Get random name
function vb:load_entity/type/villager

## Diamond trade
# Get a random value to determine whether or not we should modify trades
execute store result score @s vb.dummy1 run random value 1..7
execute if score #VB vb.settings.disable_custom_trades matches 1 run scoreboard players set @s vb.dummy1 99999
# Modify
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[2].buy.count set value 7
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[2].sell.id set value "minecraft:diamond"
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[2].sell.count set value 1
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[2].sell.maxUses set value 4

## Disc Fragment trade
# Get a random value to determine whether or not we should modify trades
execute store result score @s vb.dummy1 run random value 1..8
execute if score #VB vb.settings.disable_custom_trades matches 1 run scoreboard players set @s vb.dummy1 99999
# Modify
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[3].buy.count set value 15
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[3].sell.id set value "minecraft:disc_fragment_5"
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[3].sell.count set value 1
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[3].sell.maxUses set value 2

## Common ore trades
# Get a random value to determine whether or not we should modify trades
execute store result score @s vb.dummy1 run random value 1..3
execute store result score @s vb.dummy2 run random value 1..12
execute if score #VB vb.settings.disable_custom_trades matches 1 run scoreboard players set @s vb.dummy1 99999
# Modify
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[4].buy.count set value 6
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 1 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:coal_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 2 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_coal_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 3 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:iron_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 4 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_iron_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 5 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:copper_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 6 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_copper_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 7 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:gold_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 8 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_gold_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 9 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:redstone_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 10 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_redstone_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 11 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:lapis_ore"
execute if score @s vb.dummy1 matches 1 if score @s vb.dummy2 matches 12 run data modify entity @s Offers.Recipes[4].sell.id set value "minecraft:deepslate_lapis_ore"
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[4].sell.count set value 2
execute if score @s vb.dummy1 matches 1 run data modify entity @s Offers.Recipes[4].sell.maxUses set value 4