How to spawn particle in the players looking direction?

Discussion in 'Spigot Plugin Development' started by JavaNaza, Jun 27, 2018.

  1. Hello everybody, I just came over in particles and trying to learn them. I was wondering how can I make a particle in the players looking direction using PacketPlayOutParticle class.

    Can somebody show me how to do it?
    Thank you and have a nice day !
    #1 JavaNaza, Jun 27, 2018
    Last edited: Jun 27, 2018
  2. why would you even do this if you can send particles to players individually
  3. Then show me how to do it and I wanna do that all players could see it. But I dunno how.
  4. Player and World both have the method spawnParticle(a lot of arguments). If you are 1.8 or lower you can only use playEffect(less customizable arguments).
    You can probably imagine that obe is for all players visible, the other one only for the player.

    Do you work on a 1.10 plugin or anything higher?
  5. I work on 1.12
  6. It is documented in the apidocs how you can spawn particles, if I remember right the should be where to look - play around with it, no need to go into detail about that. A reminder though, colored particles cannot have velocity assigned to them (You use the velocity to define the color scheme.) The API however isn't available on lower versions, in case you insist on working with packets (which i really dont recommend) I would check out for it.

    The player location stores a get direction vector if i remember right, its an unit vector so you can multiply it with a value to "extend" it to a certain length (multiplying with 2.0 & adding to the player location would get you a point two block units away.) If you want a more complex structure to be rotated with it you can just look up a vector-matrix rotation function, these are somewhat more complex but if you grab well documented code you can just use them as an utility function and not think about how it works.
    • Agree Agree x 1