mojira.dev
MC-86875

I am unable to clear specific potions like I could have in 1.8.

I was able to clear potions but now I can't. I have:

/clear @p splash_potion 1 0 {Potion:water}

Comments 8

it's clear player item damage count datatag

Potions acquired via brewing or the creative inventory now fully qualify their type in the Potion tag:

/clear @p splash_potion 0 1 {Potion:minecraft:water}

Ok, thank you, however if I plugged this into a command block it didn't work:

[09:09:33] Could not clear the inventory of iheartfly, no items to remove

This happened because I had the command block clear the player of water splash potions then give them one. Since I had the command running to clear the player's inventory of water bottles and there weren't any, it messed it up. I have the commands in this order so that the player can only have one potion at a time. How can I fix this?

Have one command block that tests how many potions the player has, and only trigger the command block that clears them if the player has more than one.

Ok, I have:

/testfor @p {Inventory:[{id:"minecraft:splash_potion",Count:2,tag:{Potion:minecraft:water}}]}

But it doesn't work...

That would only work if potions could stack, because it's looking for a single item with a count of 2. You might have to use command stats to get the count. Use clear with a count of 0, and it will output the number of items found without actually clearing them. I'm neither a command nor scoredboard expert, I suggest you post either on the forums or subreddit, there are plenty of very clever people there who can probably provide you with a very compact solution.

Speaking of scoreboards, you gave me an idea. I could create a scoreboard objective and every time a player obtains a splash potion their scoreboard objective will gain a point. Then, if their scoreboard objective is at least 2, then it will clear their inventory of splash potions of water and reset the scoreboard. Thanks for all your help!

This is how you could solve this (using @unknown's method):

/scoreboard objectives add potionCount dummy
/stats entity @a set AffectedItems @p potionCount
/scoreboard players set @a potionCount 0
/execute @a ~ ~ ~ /clear @p splash_potion -1 0 {Potion:"minecraft:water"}
/execute @a ~ ~ ~ /tellraw @p ["",{"text":"Matching potions: "},{"score":{"objective":"potionCount","name":"@p"}}]

Nate Eng

(Unassigned)

Unconfirmed

Minecraft 15w34b

Retrieved