When I use this skript to spawn a custom Villager with custom trades, all the trades work, except the fact that the amount of items the player needs to trade is only 1. I have tried this with replacing the variables with actual numbers but it still doesnt work. Also the enchanted book doesn't display the enchantment and is only a enchanted book with no enchants. The skript is below.
Code:
on right click on zombie nitwit with enchanted golden apple:
if clicked entity doesn't have potion effect weakness:
exit
if metadata tag "godVillager" of clicked entity is true:
exit
if (clicked entity).isConverting() is true:
exit
make player swing their hand
remove 1 of enchanted golden apple from player's held item
set {_oxidizedCopper} to random integer from 20 and 50
set {_phantomMembrane} to random integer from 20 and 50
set {_nautilusShell} to random integer from 16 and 32
set {_emeraldBlock} to random integer from 16 and 32
set {_nbt} to nbt of "{VillagerData:{type:emoji_stuck_out_tongue:lains,profession:nitwit,level:99},Offers:{Recipes:[{maxUses:1,buy:{id:emoji_astonished:xidized_copper,Count:%{_oxidizedCopper}%},buyB:{id:heart_of_the_sea,Count:1},sell:{id:trident,Count:1}},{maxUses:8,buy:{id:emoji_stuck_out_tongue:hantom_membrane,Count:%{_phantomMembrane}%},buyB:{id:nautilus_shell,Count:%{_nautilusShell}%},sell:{id:shulker_shell,Count:1}},{maxUses:4,buy:{id:emerald_block,Count:%{_emeraldBlock}%},buyB:{id:book,Count:1},sell:{id:enchanted_book,Count:1,tag:{StoredEnchantments:[{id:""minecraft:swift_sneak"",lvl:3s}]}}}]}}"
if clicked entity is baby zombie nitwit:
spawn baby zombie nitwit at clicked entity's location with nbt {_nbt}
else:
spawn adult zombie nitwit at clicked entity's location with nbt {_nbt}
clear clicked entity
(last spawned zombie nitwit).setConversionTime(100)