Can't add a specific number of an item after a command

You could use something like:

  • /execute if entity @p[nbt={Inventory:[{id:"minecraft:gold_nugget",Count:1b}]}] run COMMAND

And change the value in Count:#b to the desired amount, but this only works if you are looking for the EXACT amount of an item.

If you want it to target a player with 1 or more gold nuggets, you will have to use a scoreboard:

  • /scoreboard objectives add gold_nuggets dummy (This is used to store the amount of gold nuggets players have.) [You only have to run this once]
  • execute as @a store result score @s gold_nuggets run clear @s minecraft:gold_nugget 0 (This stores the actually amount of gold nuggets each player has into the scoreboard (doesn't actually clear any items).) [You should put this in a repeating command block]
  • execute if entity @p[scores={gold_nuggets=1..}] run COMMAND (This is used to see if a player has 1 or more gold nuggets in their inventory.) [You should use one of these for each shop trade, just change the value of gold_nuggets=1..]