I've noticed that if a player throws a harm splash potion, passive mobs will panic and run around for a few seconds, so I've tried to take advantage of that, but I'm having a little trouble. I'm using pigs as part of a game, and I want to be able to scatter them using this method, but apparently harm potions not thrown by a player won't do anything.
This seems to work as far as creating the harm potion goes (and it does injure the pigs), but it doesn't actually make the pigs panic the same way as if a player threw one. So I tried using a dispenser loaded with the potions, but ended up with the same results.
Anyone know a little more about mob AI to explain this (or to suggest an alternate method)?
Oh! Didn't even consider that you could use that with non-player entities... well, it doesn't cause the pigs to flee, but I guess it's at least a fall back, thanks.
Thinking about it a bit, this may not work for the same reason that wolves won't be aggroed by non-player sources (arrows, harm potions, etc)... but that's only a guess.
Not likely the best solution, since there's a visual effect, but if you set passive mobs on fire they will run in panic. You can also give them fire resistance to prevent fire damage, and they'll still run:
I'm guessing that the pig is running because the potion had an nbt tag that specified a player.
Try using a command like /summon ThrownPotion ~ ~1 ~ {ownerName:Sarmachus,Potion:{id:potion,Damage:8204}
I'm guessing that the pig is running because the potion had an nbt tag that specified a player.
Try using a command like /summon ThrownPotion ~ ~1 ~ {ownerName:Sarmachus,Potion:{id:potion,Damage:8204}
Also try using your IGN if this one doesn't work.
I can confirm that this works, but only if the owner is online. This means it cannot be used for a shared map.
Yea, just figured that out after testing it. However, I noticed that a skeleton's arrow and a witch's thrown potion were able to also make the pigs panic. I tried using entity data to get the same potion that the witch threw, but that potion didn't have the same panic effect on the pig.
A solution is to this might be to store potions that witches throw, but when I've tried to do so I don't get expected results.
I have done this command to stop the potion (it is on a clock) and then I have teleported it to the pig.
I disabled the first command and then the potions appeared again and hit the pig, however the pig wasn't scared. This may be because the poison potions are interfering, but I can't tell for sure.
Yea, just figured that out after testing it. However, I noticed that a skeleton's arrow and a witch's thrown potion were able to also make the pigs panic. I tried using entity data to get the same potion that the witch threw, but that potion didn't have the same panic effect on the pig.
A solution is to this might be to store potions that witches throw, but when I've tried to do so I don't get expected results.
I have done this command to stop the potion (it is on a clock) and then I have teleported it to the pig.
I disabled the first command and then the potions appeared again and hit the pig, however the pig wasn't scared. This may be because the poison potions are interfering, but I can't tell for sure.
Potions thrown by witches do not have an ownerName. In this case, there's a reliance on the server processing the connection between the thrown potion and a specific witch, which is not something we can do with commands. Storing witch potions might work so long as the witch does not despawn and as long as the game is not closed (which also does not allow you to share a map with pre-stored witch potions, so they'd need to be created proactively).
Is there anyway to just set the ownerName attribute to the nearest player?
edit:
Maybe if I use an execute command to summon the thrown potion, it'll set the owner to that player. I'll have to test it later and report back.
double-edit:
Is it possible to use nested execute commands? Like,
To answer the first question, no, it is not possible. To the second, of course, as far as I know there is no limit to the number of nested execute commands you can use in the same command.
Honestly, the solution Skylinerw first suggested with the fire is really your best bet.
Yea, unfortunately you were right about the ownerName tag, I didn't have any luck getting it to assign an owner using execute @p. Oh well, I'll just make due with setting them on fire for a short time.
You could give them regeneration for a few seconds while this happens so they don't die.
Just not fire resistance because then they wouldn't take damage from the fire and therefore would not run away.
They'll actually still run even with fire resistance (though it does prevent the player from applying a fire effect with the intention to deal damage).
I've actually already given them boosted health via the active effect tag, really its more of a visuals concern. And from my experiments setting them on fire with the fire tag, they only panic for the duration they're on fire, so I can't light them for just a single tick to start their panicking, they have to be on fire for a while.
Using command blocks, I summon the following:
This seems to work as far as creating the harm potion goes (and it does injure the pigs), but it doesn't actually make the pigs panic the same way as if a player threw one. So I tried using a dispenser loaded with the potions, but ended up with the same results.
Anyone know a little more about mob AI to explain this (or to suggest an alternate method)?
Edit: I tested it, it doesn't work...
Inactive account. See Bio.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
Try using a command like /summon ThrownPotion ~ ~1 ~ {ownerName:Sarmachus,Potion:{id:potion,Damage:8204}
Also try using your IGN if this one doesn't work.
I have a small YouTube channel and would greatly appreciate it if you were to check me out!!
I can confirm that this works, but only if the owner is online. This means it cannot be used for a shared map.
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
A solution is to this might be to store potions that witches throw, but when I've tried to do so I don't get expected results.
I have done this command to stop the potion (it is on a clock) and then I have teleported it to the pig.
/entitydata @e[type=ThrownPotion] {Motion:[0,0,0]}
/tp @e[type=ThrownPotion] @e[type=Pig]
I disabled the first command and then the potions appeared again and hit the pig, however the pig wasn't scared. This may be because the poison potions are interfering, but I can't tell for sure.
I have a small YouTube channel and would greatly appreciate it if you were to check me out!!
Potions thrown by witches do not have an ownerName. In this case, there's a reliance on the server processing the connection between the thrown potion and a specific witch, which is not something we can do with commands. Storing witch potions might work so long as the witch does not despawn and as long as the game is not closed (which also does not allow you to share a map with pre-stored witch potions, so they'd need to be created proactively).
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/
edit:
Maybe if I use an execute command to summon the thrown potion, it'll set the owner to that player. I'll have to test it later and report back.
double-edit:
Is it possible to use nested execute commands? Like,
To answer the first question, no, it is not possible. To the second, of course, as far as I know there is no limit to the number of nested execute commands you can use in the same command.
Honestly, the solution Skylinerw first suggested with the fire is really your best bet.
They'll actually still run even with fire resistance (though it does prevent the player from applying a fire effect with the intention to deal damage).
Minecraft-things: http://skylinerw.com
More Minecraft-things: https://sourceblock.net
Guides for command-related features (eventually moving to Source Block): https://github.com/skylinerw/guides
I primarily hang out in the /r/MinecraftCommands discord, where there's a lot of people that help with commands: https://discord.gg/QAFXFtZ
Their corresponding subreddit: https://www.reddit.com/r/MinecraftCommands/