Minecraft – way to /testfor a specific potion

minecraft-commandsminecraft-java-edition

I am working on a map with a boss fight where a witch is the boss. During the boss fight, I need different mobs to spawn on the ground based on which potion the witch threw (slowness, poison, weakness, or damage).

Using the testfor command, I have tried:
/testfor @e[type=ThrownPotion] {Potion:{id:potion,Damage:16388}}
and I have connected a comparator output from the command block. Yes, the command block is on a clock.

When I throw the Poison Splash Potion (0:33), the command block says the potion did not have the required data structure.

Is there something wrong with the command? Is there something wrong with the ThrownPotion? Is there a possible way to do this?

Thanks

Best Answer

When testing for pre-existing data, you must declare the data as-is. The item ID is saved with a namespace, defaulting to minecraft, but your input via /testfor (or /scoreboard) will not be automatically corrected. As such, you must input the namespace that the item is saved with, becoming minecraft:potion.

The Damage tag is saved with a tag-type of Short. In order to declare a Short, you must append the numerical value with an 's'.

Your command will become:

/testfor @e[type=ThrownPotion] {Potion:{id:"minecraft:potion",Damage:16388s}}