0

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?

0

For the first problem, you don't have to specify a slot or count when testing for NBT data. Try something like this:

/testforblock X Y Z chest -1 {Items:[{id:minecraft:gold_nugget}]}

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:

  1. Break the chest with a /setblock
  2. 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}}

  3. Change the NBT data of the dropped nuggets: /entitydata @e[type=Item,score_IsNugget_min=1] {Item:{tag:{display:{Name:"NUGGET"}}}}

  4. Use a (minecart) hopper to scoop the items back up into a chest.

  • For the second problem, you could use the /blockdata command to set a display tag, although this would require a different command for each slot in the chest, so it would be annoying to set up. – Silentvenom7 Sep 5 '15 at 21:27
  • @Silentvenom7 A different command for each slot, and for each potential item amount; I don't think 1728 command blocks is worth it. – SirBenet Sep 5 '15 at 21:40
  • couldn't you just omit the Count tag? Or does that not work when assigning data? – Silentvenom7 Sep 5 '15 at 22:25
  • @Silentvenom7 When changing items in an inventory I think you have to the entire item. – SirBenet Sep 5 '15 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.