My goal is to be able to put a variable amount of gold nuggets in a chest and then run some commands to replace those with gold nuggets that have edited display NBT data.
Is this even possible? I'm encountering a few issues.
First, when checking for the amount of gold nuggets in an inventory with /testforblock, I have to specify the amount of gold nuggets I am testing for. However, I want the amount of nuggets you input to be variable, not restricted to a certain stack size. I also want it to be able to work with every slot in the chest, so somebody can fill the whole thing up.
Second, how would I store the amount of nuggets being inputted into the chest and pass that value to /replaceitem so that I replace the correct number of gold nuggets with edited display NBT nuggets?
Best Answer
For the first problem, you don't have to specify a slot or count when testing for NBT data. Try something like this:
That way, the command will succeed if any gold nuggets are in any slot.
No good way to do the second problem, AFAIK. Best way would be do:
/setblock
Identify the golden nugget items that just dropped with a scoreboard objective, E.G:
/scoreboard players set @e[type=Item] isNugget 1 {Item:{id:minecraft:gold_nugget}}
Change the NBT data of the dropped nuggets:
/entitydata @e[type=Item,score_IsNugget_min=1] {Item:{tag:{display:{Name:"NUGGET"}}}}
Use a (minecart) hopper to scoop the items back up into a chest.