forum Forumsplay_arrow Minecraft fiber_manual_record Redstone

1

Test for items in a players inventory

1 emerald5 replies4,947 views
created 01/15/2016 11:21 pm by Jakers1114
last reply 01/18/2016 11:33 am
Hello! I was wondering if there is a way to test for a certain amount of items in a players inventory. For example, if I have 64 (OR MORE) papers in my inventory, the command block will send out a redstone signal through a comparator. Please help, I am making a map and really need this. Thanks!
Posted by avatar
Jakers1114
Level 1 : New Crafter
0

comment Login or register to post a reply.

5 replies

01/18/2016 11:33 am
Level 28 : Expert Engineer
Jmal116
The 'b' is required, because minecraft is weird. However you shouldn't have quotes around anything in that tag. In the end you should get something looking like this:testfor @a {Inventory:[{id:"minecraft:paper",Count:64b}]}
It's worth noting that this will only work if a player has 64 papers in one item slot. If they're spread throughout their inventory, it won't detect them. That said, you won't be able to put multiple compounds together like BertieCrafter suggested, because with no slot tag defined the game will treat them all as the same thing. If that problem doesn't matter for your purposes, then you can leave it like it is. If you need a better method, I think I saw something about using stats to detect the number of items better somewhere, I'd have to dig it up though.
01/16/2016 10:15 am
Level 1 : New Crafter
Jakers1114
It gives me an error, and fails to work. It says "Data tag parsing failed: Unexpected token 'b' at: b"
01/16/2016 10:34 am
Level 19 : Journeyman Scribe
Travis
Lol the best part is that the error is the most emphasized part
01/16/2016 10:54 am
Level 1 : New Crafter
Jakers1114
I don't understand..
01/16/2016 7:53 am
Level 37 : Artisan Engineer
Bertiecrafter
This for 1-64 items:
/testfor @a {Inventory:[
{id:"minecraft:ITEM",Count:"COUNT"b}
]}

No, the b is not a typo, you need it.

For more items, you could try to test for multiple slots (e.g: 100 = 64 +36), but idk if it works:
/testfor @a {Inventory:[
{id:"minecraft:ITEM",Count:"COUNT"b},
{id:"minecraft:ITEM",Count:"COUNT"b},
{id:"minecraft:ITEM",Count:"COUNT"b},
{id:"minecraft:ITEM",Count:"COUNT"b},
(REPEAT IF NEEDED)
]}

Make sure to have no "," after the last one in the list.

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome