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:
- Break the chest with a
/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.
When testing for pre-existing NBT data, you must specify all data as it was stored. This includes proper string values for item IDs (you should not be using numerical IDs to begin with) as well as correct datatype declaration for all data.
The id
tag stores a string, being the name ID of the item (including the namespace, defaulting to "minecraft"). Both the Slot
and Count
tags are stored as bytes, so you append the whole numerical value with a "b".
Fixed command:
/testforblock -17 105 198 minecraft:chest 5 {Items:[{id:"minecraft:stone",Slot:0b,Count:64b},{id:"minecraft:stone",Slot:1b,Count:64b},{id:"minecraft:stone",Slot:2b,Count:64b},{id:"minecraft:stone",Slot:3b,Count:64b},{id:"minecraft:stone",Slot:4b,Count:64b},{id:"minecraft:stone",Slot:5b,Count:64b},{id:"minecraft:stone",Slot:6b,Count:64b},{id:"minecraft:stone",Slot:7b,Count:64b},{id:"minecraft:stone",Slot:8b,Count:64b},{id:"minecraft:stone",Slot:9b,Count:64b},{id:"minecraft:stone",Slot:10b,Count:64b},{id:"minecraft:stone",Slot:11b,Count:64b},{id:"minecraft:stone",Slot:12b,Count:64b},{id:"minecraft:stone",Slot:13b,Count:64b},{id:"minecraft:stone",Slot:14b,Count:4b}]}
Best Answer
Let's look at your data tag here carefully.
In this expanded form, you can immediately see that something is odd about your parentheses. There is a closing curly bracket without a partner. You'll have to add
{
beforeid
(which is the first tag inside the item tag). Generally, when something is wrong, expanding the command over multiple lines and indenting properly at every layer is a good idea to catch these type of errors.Secondly, the tag containing the item tags for chests is called
Items
, plural (cf. the wiki).In total, the data tag needs to be
Or compacted for easy copy and paste: