I'm playing with the /data command for a while in MC14.2, but I can't find a way to access items by index when a NBT path selector matches several items.
Let's say for example I want to know which slot of a chest containing pumpkins. I can write that:
/data get block x y z Items[{id:"minecraft:pumpkin"}].Slot
However, it will work only if pumpkins are found in one slot. If the chest has several slots filled with pumpkins, data get produces the error "only one NBT value accepted". So, is there a way to select only the first item (or at least only one item, being the first or not) matching an NBT path?
I'm playing with the ", courier, monospace">/data command for a while in MC14.2, but I can't find a way to access items by index when a NBT path selector matches several items.
Let's say for example I want to know which slot of a chest containing pumpkins. I can write that:
/data get block x y z Items[{id:"minecraft:pumpkin"}].Slot
However, it will work only if pumpkins are found in one slot. If the chest has several slots filled with pumpkins, ", courier, monospace">data get produces the error "only one NBT value accepted". So, is there a way to select only the first item (or at least only one item, being the first or not) matching an NBT path?
Third, use your command in a slightly different way.
Sth like this: /data modify block <coords of chest under> Items[0].tag.Slotz append from block <coords of target chest> Items[{id:"minecraft:pumpkin"}].Slot
After this, that item (stone in this case) has all the slots stored.
Lastly, get the first slot with sth like this:
/data get block ~ ~ ~ Items[0].tag.Slotz[0]
Ta-da!~ *cough* Here you go. Modify it so that it suits your situation.
I'm playing with the /data command for a while in MC14.2, but I can't find a way to access items by index when a NBT path selector matches several items.
Let's say for example I want to know which slot of a chest containing pumpkins. I can write that:
However, it will work only if pumpkins are found in one slot. If the chest has several slots filled with pumpkins, data get produces the error "only one NBT value accepted". So, is there a way to select only the first item (or at least only one item, being the first or not) matching an NBT path?
FWIW, I tried several variations with no luck:
Please, support the sledgehammer tool!
I ♥ Linux. Thanks Mojang for providing a game that runs natively on that OS!
Here's a slightly rough solution.
First, place another container under that target chest. Another chest can do. Or, summon an entity below. It has to hold the target item tho.
Second, either put that special item in the first slot of the chest under, or use /summon to include that item on the entity's hand.
That special item can be anything, not necessarily a pumpkin even if you're finding a pumpkin. But it just needs to have the tag:{} nbt tag.
Example: /setblock ~ ~ ~ chest{Items:[{id:"minecraft:stone",Count:1,tag:{}}]}
Third, use your command in a slightly different way.
Sth like this: /data modify block <coords of chest under> Items[0].tag.Slotz append from block <coords of target chest> Items[{id:"minecraft:pumpkin"}].Slot
After this, that item (stone in this case) has all the slots stored.
Lastly, get the first slot with sth like this:
/data get block ~ ~ ~ Items[0].tag.Slotz[0]
Ta-da!~ *cough* Here you go. Modify it so that it suits your situation.