Minecraft /testfor Players Using Items

Minecraft /testfor Players Using Items - Young woman watching movie in headphones in messy room

I am trying to create a hydration system for my Minecraft adventure map that displays hydration levels on the scoreboard. To restore the players hydration a player should need to drink a water bottle, and so I figured this command would do the trick: /testfor @p {stat.useItem:373}

However I receive an error: (player) did not match the required data structure

Does anyone know why I recieve this error and if there is any way to make the command work? (preferably without using scoreboard values instead as I want to use the scoreboard values to display the hydration levels themselves)



Best Answer

stat.useItem is not a NBTag, it's a scoreboard objective type. Moreover, if it even was an data tag, you'd be testing for someone who has used an item 373 times, not someone who's used water once.

You are going to need to use scoreboard objectives for this. I feel like your concern may be a misunderstanding though; you can have as many different objectives as you want, and don't have to display the ones you don't want to be seen.

To set up this objective, type:

/scoreboard objectives add drankWater stat.useItem.minecraft.potion

You can then test for people who drank water like this:

/testfor @a[score_drankWater_min=1]

And reset their score to 0 like this:

/scoreboard players set @a[score_drankWater_min=1] drankWater 0



Pictures about "Minecraft /testfor Players Using Items"

Minecraft /testfor Players Using Items - Content female shopaholic lying on floor at home in messy room and making order in online store while using netbook
Minecraft /testfor Players Using Items - Crop man packing carton box with scotch tape dispenser
Minecraft /testfor Players Using Items - Small cardboard boxes and leather cases placed on bed with sheet near big box in light room of house under sloping roof





Minecraft Bedrock - Test For Items In Inventory (Mobile/Xbox/PS4/Windows 10/Switch)




More answers regarding minecraft /testfor Players Using Items

Answer 2

You cannot technically detect whether or not it's specifically a water bottle, unless you name it and have it testfor the player to have used it and hold it.

Answer 3

I'm fairly certain you use [ ] in place of { }

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Andrea Piacquadio, Andrea Piacquadio, Ketut Subiyanto, Ketut Subiyanto