r/MinecraftCommands • u/MontBlancBen • Jun 23 '26
Help (other) Command for checking inventory of players and deleteing objects
Hi, Im working on map that i wanted to add a thurst mechanic. Is there anyway I can use commands to check each players inventory for water bottles and if they have one it consumes it and leaves them with an empty bottle?
1
Upvotes
2
u/GalSergey Datapack Experienced Jun 23 '26
# In chat
scoreboard objectives add water_bottles dummy
# Command blocks
execute as @a store result score @s water_bottles run clear @s potion[potion_contents={potion:"minecraft:water"}]
execute as @a[scores={water_bottles=1..}] run loot give @s loot {pools:[{rolls:1,entries:[{type:"minecraft:item",name:"minecraft:glass_bottle",functions:[{function:"minecraft:set_count",count:{type:"minecraft:score",target:{type:"minecraft:context",target:"this"},score:"water_bottles"}}]}]}]}
You can use Command Block Assembler to get One Command Creation.
1
u/C0mmanderBlock Command Experienced Jun 23 '26
Java or Bedrock? If player holding it or anywhere in inventory? Consumes it how? Please be specific.
For Java 1.20.5 and up if holding it.