Skip to main content

How to check player's inventory for specific number of items?

Comments

5 comments

  • Official comment
    Kyle M

    Hi Evgenii,

    Let me know if this helps:

    The easiest method would be to simply check their inventory, though this will only be able to check for an exact amount and not minimum:

    /testfor @a {Inventory:[{id:minecraft:arrow,Count:2b}]}
    or
    /scoreboard players set @a OBJECTIVE 1 {Inventory:[{id:minecraft:arrow,Count:2b}]}
  • Kory Urban

    Evgenii or Kyle,

    Was there ever a resolution for this? I'm also trying to detect for items in a player's inventory. I'm quite familiar with the command blocks in the java version, but MEE doesn't seem to give us access to the NBT data.

    1
  • Evgenii Permiakov

    Hello Kory, 

    I've been able to achieve my goal i.e. if player has 15 apples (or more) in his inventory, he or she can exchange 15 apples for 1$. I can share my solution with you, but it technically does not check the players inventory for a specific amount, rather it allows players to exchange items for money. 

    It's, however, entirely possible to make something else happen (not money transaction), on condition that a player has a certain amount of items in his/her inventory. 

    Please explain what you are trying to achieve so I we can better tailor the solution to your goal. 

    1
  • Kory Urban

    I was going to check for a student wearing a particular item in their head armor slot while be in certain areas for "safety" reasons, either to prevent them from entering the area or to kick them out of the area if removed. I don't see any real way of identifying what they are wearing if we can't search their inventories. 

    1
  • Evgenii Permiakov

    I suggest you post your problem on a MEE discord channel. This is the link: https://discord.gg/7fSQBdx There are MEE educators who are far more knowledgeable than me, and they never fail to come up with ingenious solutions to community requests. 

    1

Please sign in to leave a comment.