The Meaning of Life, the Universe, and Everything.
Location:
Both here
Join Date:
1/5/2012
Posts:
245
Location:
and there at once.
Minecraft:
same as this one
Xbox:
Don't have one
PSN:
Don't want one
Member Details
There are a few ways I know of doing this, each with their own pros and cons.
If the splash potion is going to be thrown at an entity, then the best way would probably be to add some seldom used potion effect to your potion like water breathing. Then, constantly run /effect @e water_breathing 0. That tries to remove the water breathing effect from all entities. If that command is successful, you know that the player has thrown the potion at something.
Another way is to define a scoreboard objective with /scoreboard objectives add potionTest stat.useItem.minecraft.potion , When a player right clicks with a potion, that will go to 1. The downside of this is that it can't limit the detection to a specific potion. Even normal, non splash ones would activate it. So, if the player is not going to have any other potions, use this method.
The last way I can think of is to use a very quick clock that is constantly running /testfor @e[type=ThrownPotion] {specific potion related data here} , The pro of that is you can limit the potion to be only one specific potion will work. Also, it doesn't have to hit an entity for it to detect. The downside is that you need a very, very fast clock, which might cause a bit of lag. Also, if the player throws the potion at point blank range, it might hit the target before even your fast clock can detect it.
Actually, never mind. I found another way you might be able to do it. Have the command block constantly run the command /clear @a potion [potion's data here] 0 {potion related data here}. That command constantly "clears" away 0 potions from the players. So, it will tell you wether or not the player has the potion in their inventory. So, when the command stops outputting any signal, you know the player has thrown the potion. A downside of this method is that the player can work around it by either dropping the potion with Q or placing it into some container.
There is another way that involves detecting certain player data and testing for inventory slots. However, I think it is rather impractical because it is more complex than any of the 4 other options and you don't know which slot the player is going to put their potion into.
By the way, the "specific potion related data" means the potion's NBT tag. So, for a fire resistance potion modified to give speed, it would be {Potion:{id:potion,Damage:16387,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:2000}]}}} . However, you would remove the things before the "tag" for the /clear version because then it is an item not an entity. For this kind of thing, I recommend http://mcstacker.bimbimma.com
There are a few ways I know of doing this, each with their own pros and cons.
Awesome, thanks for the heads up!
I think I'll give it a go for the 3rd or 4th options since they seem to make the most sense.
The clock I'm using seems to be rather fast so I'm positive it'll work just fine with the 3rd option. It consists of a pair of command blocks with an empty block between them using the commands /setblock ~ ~1 ~ minecraft:air and /setblock ~ ~-1 ~ minecraft:redstone_block I've got a couple dozen of them running all of the events in clusters of 4 events per clock and there's no worry for lag because in each of the cluster's beginning and end they enable and disable the next and last cluster respectively. Meaning at all times there's only up to 4 clocks running at the same time which doesn't make the map struggle at all.
Now for the specific event in question here, I have the player make a splash potion of instant damaged which is re-named as "Volatile Mixture" (It's re-named for lore and convenience sake) the idea is that the player will treat this as an explosive to break through a wall rather than actually using TNT and having to deal with a random explosion. So with this plan I needed to know when the player used the splash potion so that I could trigger the crumbling wall (complete with visual and sound effects) but until now I had no idea how to go about it.
Again thanks for the advise, I'll come back when after I've tried these methods.
This is literally the last thing I need before I can start decorating and polishing up the map's aesthetics ^^;
[EDIT:1]
So I'm back after messing with this for a bit.
the final command I ended up with is as follows
but I keep getting the following message when I test out the block.
[14:54:24] Potion did not match the required data structure
I'm not sure if there's something I missed in the command it makes sense to me but this is also the tooltip I get when I'm looking at the specific potion I want to use.
[EDIT:2]
Nevermind, I got it working, I had to remove the potion ID so it only looks for the labeled entity rather than what minecraft recognizes it as.
Is there a command that can detect a player using a splash potion or that can detect when an inventory slot goes from occupied to empty?
I am using command blocks running on a clock rather than a specific redstone trigger if that helps to answer my question.
Any help would be appreciated, though it's not a big deal if it can't be done, I'll just have rewrite the even in a different way.
If the splash potion is going to be thrown at an entity, then the best way would probably be to add some seldom used potion effect to your potion like water breathing. Then, constantly run /effect @e water_breathing 0. That tries to remove the water breathing effect from all entities. If that command is successful, you know that the player has thrown the potion at something.
Another way is to define a scoreboard objective with /scoreboard objectives add potionTest stat.useItem.minecraft.potion , When a player right clicks with a potion, that will go to 1. The downside of this is that it can't limit the detection to a specific potion. Even normal, non splash ones would activate it. So, if the player is not going to have any other potions, use this method.
The last way I can think of is to use a very quick clock that is constantly running /testfor @e[type=ThrownPotion] {specific potion related data here} , The pro of that is you can limit the potion to be only one specific potion will work. Also, it doesn't have to hit an entity for it to detect. The downside is that you need a very, very fast clock, which might cause a bit of lag. Also, if the player throws the potion at point blank range, it might hit the target before even your fast clock can detect it.
Actually, never mind. I found another way you might be able to do it. Have the command block constantly run the command /clear @a potion [potion's data here] 0 {potion related data here}. That command constantly "clears" away 0 potions from the players. So, it will tell you wether or not the player has the potion in their inventory. So, when the command stops outputting any signal, you know the player has thrown the potion. A downside of this method is that the player can work around it by either dropping the potion with Q or placing it into some container.
There is another way that involves detecting certain player data and testing for inventory slots. However, I think it is rather impractical because it is more complex than any of the 4 other options and you don't know which slot the player is going to put their potion into.
By the way, the "specific potion related data" means the potion's NBT tag. So, for a fire resistance potion modified to give speed, it would be {Potion:{id:potion,Damage:16387,tag:{CustomPotionEffects:[{Id:1,Amplifier:0,Duration:2000}]}}} . However, you would remove the things before the "tag" for the /clear version because then it is an item not an entity. For this kind of thing, I recommend http://mcstacker.bimbimma.com
There's a difference between a hero and a champion. A champion overcomes threats, but a hero overcomes fears.
All my maps, click here.
Then there's also a Youtube channel I'm somewhat involved in.
Awesome, thanks for the heads up!
I think I'll give it a go for the 3rd or 4th options since they seem to make the most sense.
The clock I'm using seems to be rather fast so I'm positive it'll work just fine with the 3rd option. It consists of a pair of command blocks with an empty block between them using the commands /setblock ~ ~1 ~ minecraft:air and /setblock ~ ~-1 ~ minecraft:redstone_block I've got a couple dozen of them running all of the events in clusters of 4 events per clock and there's no worry for lag because in each of the cluster's beginning and end they enable and disable the next and last cluster respectively. Meaning at all times there's only up to 4 clocks running at the same time which doesn't make the map struggle at all.
Now for the specific event in question here, I have the player make a splash potion of instant damaged which is re-named as "Volatile Mixture" (It's re-named for lore and convenience sake) the idea is that the player will treat this as an explosive to break through a wall rather than actually using TNT and having to deal with a random explosion. So with this plan I needed to know when the player used the splash potion so that I could trigger the crumbling wall (complete with visual and sound effects) but until now I had no idea how to go about it.
Again thanks for the advise, I'll come back when after I've tried these methods.
This is literally the last thing I need before I can start decorating and polishing up the map's aesthetics ^^;
[EDIT:1]
So I'm back after messing with this for a bit.
the final command I ended up with is as follows
/testfor @e[type=ThrownPotion] {Potion:{id:potion,Damage:16396,tag:{display:{Name:"Volatile Mixture",Lore:["A homemade explosive..."]}}}}
but I keep getting the following message when I test out the block.
[14:54:24] Potion did not match the required data structure
I'm not sure if there's something I missed in the command it makes sense to me but this is also the tooltip I get when I'm looking at the specific potion I want to use.
Volatile Mixture {#0373/16396)
Brewing
Instant Damage
A homemade explosive...
minecraft:potion
NBT:1 tag(s)
[EDIT:2]
Nevermind, I got it working, I had to remove the potion ID so it only looks for the labeled entity rather than what minecraft recognizes it as.