1

In my custom map there is a point where the items in the chest have to be tested, so I wrote this command:

/testforblock -17 105 198 minecraft:chest 5 {Items:[{id:1,Slot:0,Count:64},{id:1,Slot:1,Count:64},{id:1,Slot:2,Count:64},{id:1,Slot:3,Count:64},{id:1,Slot:4,Count:64},{id:1,Slot:5,Count:64},{id:1,Slot:6,Count:64},{id:1,Slot:7,Count:64},{id:1,Slot:8,Count:64},{id:1,Slot:9,Count:64},{id:1,Slot:10,Count:64},{id:1,Slot:11,Count:64},{id:1,Slot:12,Count:64},{id:1,Slot:13,Count:64},{id:1,Slot:14,Count:4}]}

To a command block (and kept it in a loop of 1/2 of a second) but it gives the following error:

The block at -17,105,198 did not have the required NBT keys.

But there is a chest there 100% (if thats the case). I will leave a screenshot of the chests so to determine if there is any placement issue. Layout of my chest:

description

3

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}]}
| improve this answer | |
  • Thx @Skylinerw it really helped me – Tom Apr 18 '16 at 15:45

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.