We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

9

Additional commands

4 Comments

Please sign in to leave a comment.

Sorted by oldest
  • 2
    Registered User commented
    Comment actions Permalink

    This is already possible. To test if a player has an item in their inventory, just run /clear on them, but set the maximum item count to 0. This will not clear anything, but instead return the number of matching items on the player, which can be probed with a redstone comparator or with /execute store.

    clear @p minecraft:gold_nugget 0
  • 1
    Registered User commented
    Comment actions Permalink

    This would be great if you could test in a specific inventory slot, or for specifically named items/data values, but without that it won't be anymore useful than /clear.

  • 0
    Registered User commented
    Comment actions Permalink

    You can already do this even for specific slots. The command you have to run is like this: /execute <target>[hasitem={item=<item>}]

    For specific slots, put a comma, then type"slot=<slot number>"

    For exact location in the inventory, put a comma, then type"location=<location>"

    Here are different examples of locations:

    Slot.inventory

    slot.armor

    head

    chest

    legs

    feet

    slot.weapon.mainhand

    slot.weapon.offhand

    For specific data, put a comma, then type"data=<data>"

    I hope I didn't miss anything and that this helps you a lot.

  • 0
    Registered User commented
    Comment actions Permalink

    You can just do /testfor @e{[hasitem={item=Your_item}