0

Quick question.

After a thorough google and Arqade search before, I was wondering if there was a way to detect if a player was inside of a particle effect. For example if I had the command:

/particle happyVillager 10 15 12 1 1 1 25 25 25

Running on a clock, and a player walked through 10 15 12, it would output a redstone signal. Perhaps an execute command or maybe this is simply impossible? Any ideas are appreciated :)

1 Answer 1

3

Particles cannot be detected/targeted. If you know the location that the particles are being created, you can merely target players at that location:

/testfor @a[10,15,12,1]

I should mention that you have a stray 25 at the end of your /particle command, when it should either be normal or force (otherwise defaulting to normal).


An alternative to using /particle in 1.9 is to use an AreaEffectCloud entity, which creates particles at a particular location as well as optionally applying custom potion effects to players who enter the area.

/summon AreaEffectCloud 10 15 12 {Particle:"happyVillager",Radius:1.0f,Duration:2147483647}

You could target players via /execute and the AreaEffectCloud:

/execute @e[type=AreaEffectCloud] ~ ~ ~ /say @a[r=1]

Alternatively (and more accurately), you could cause the entity to apply an inert custom effect to the player and detect players with that effect. For example, the following gives the player a Resistance effect with an amplifier of -1, which means 0% damage reduction (essentially rendering the actual effect useless, but we can still detect it appropriately).

/summon AreaEffectCloud 10 15 12 {Particle:"happyVillager",Radius:1.0f,Effects:[{Id:11b,Duration:10,Amplifier:-1b,ShowParticles:0b}],Duration:2147483647}

For detection:

/scoreboard players tag @a[tag=inCloud] remove inCloud
/scoreboard players tag @a[tag=!inCloud] add inCloud {ActiveEffects:[{Id:11b,Amplifier:-1b}]}
7
  • The resistance effect here would overwrite existing resistance effects, right? Wouldn't something like Bad Luck 0 work better in this case?
    – MrLemon
    Commented Feb 26, 2016 at 9:18
  • @MrLemon That's correct, it would indeed have to overwrite. Bad Luck would also end up needing to overwrite as well, so it's mainly about what would work best for the OP since unfortunately there is not a perfect solution.
    – Skylinerw
    Commented Feb 26, 2016 at 9:54
  • Still think a /testfor in radius works well. Interesting idea, though! Commented Feb 27, 2016 at 5:50
  • @Skylinerw Thanks for your thorough answer. Could you explain the detection part a little? I understand I need to first add the scoreboard, and would second command you give (in detection) need to run on a clock? Sorry, scoreboards are my weakness :) Commented Mar 12, 2016 at 15:02
  • @SMILIECHICKEN There are no objectives being used. /scoreboard tags is a new feature added in 1.9 and has essentially no relation to scoreboards other than its use with the /scoreboard command's syntax (which is unfortunately misleading). Both commands for detection need to be run on a clock: the first removes the label so that players don't always have the label, and the second one gives the label. See the wiki for more info on /scoreboard tags syntax.
    – Skylinerw
    Commented Mar 12, 2016 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.