Solved Creating Particles Around a Player

Discussion in 'Plugin Development' started by The_BloodHound, Mar 28, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    The_BloodHound

    I'm creating a plugin that when a player does /particles <particle> it creates the certain particle around them. The thing is, I've tried
    Sender.playEffect(player.getLocation(), Effect.SMOKE, 0);
    and it has an error for playEffect that has a quick fix that says "Add Cast To Sender" which doesn't really help.

    I know I can use packets, but I don't know how to use them. Please help me with the playEffect problem or explain how to use packets.

    Your help would be deeply appreciated. :)
     
  2. Offline

    ProMCKingz

  3. Offline

    Barrek

    You need to cast it to a player.

    For instance use this at the top of your command:

    Code:
     final Player player = (Player) sender;
    And then when you want to play an effect use:

    Code:
    player.playEffect(player.getLocation(), Effect.SMOKE, 0);
     
  4. Offline

    Nathat23

    You can use
    Code:
    if(Sender instanceof Player){
    Sender.getWorld().playEffect(Sender.getLocation(), Effect.SMOKE. 0);
    }
     
  5. Offline

    nverdier

    But first you have to check the the sender is actually a Player!
     
  6. Offline

    Barrek

    Correct! My bad.
     
  7. Offline

    The_BloodHound

    Thanks for all the help everyone :)

    For some reason, my local host server won't load my recent plugins but that's a different problem to deal with.

    Once again, thank you.
     
  8. @The_BloodHound If your problem was solved, please set this thread to solved by going to Thread Tools (at the top) > Edit Title > Prefix > Solved. If not, just ignore this post. ;)
     
  9. Offline

    The_BloodHound

    Okay, thanks for letting me know. I'm new to this. : )
     
  10. Offline

    WladHD

    If you want to spawn particles AROUND the player (like a circle) than you can use this:

    Code:
    for (int i = 0; i < 360; i++) {
               int n = 6 - 30 + 1;
               int in = r.nextInt() % n;
               int size =  3 + in;
                  
               double angle = (i * size * Math.PI / 180);
               double x = size * Math.cos(angle);
               double z = size * Math.sin(angle);
               Location loc = p.getLocation().add(x, 1, z);
              
              p.playEffect(p.getLocation(), Effect.yourEffect, 0);
    }
    
     
  11. Offline

    meguy26

    @The_BloodHound
    I know this thread is a bit old, but as future reference for others looking at this thread, it is possible to show any block break particle using the regular bukkit API:
    Code:
    Player p = some player;
    p.playEffect(Location loc, Effect.StepSound, Material.<some block>);
     
Thread Status:
Not open for further replies.

Share This Page