"Shoot" out some particles?

Discussion in 'Plugin Development' started by TigerHix, Jul 15, 2013.

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

    TigerHix

    How to "shoot" some white particles from location of player to where player looks at?

    Thanks for your help.
     
  2. Offline

    Woobie

    TigerHix
    There's no good way of "shooting" particles, but you can use getTargetBlock(), and set the max radius to whatever.

    Put this inside a PlayerInteractEvent
    Code:
    player.playEffect(player.getTargetBlock(null, radius), Effect.YOURPARTICLE, 0);
    Replace "radius" with the max radius (in blocks) you want the player to be able to click at. Also replace "YOURPARTICLE" with, never guess what.. your particle. Can't remember what that last integer is for, probably the duration.
     
    TigerHix likes this.
  3. Offline

    TigerHix

    Thx for reply, but unfortunately I have tried this method.. It creates the effect at the target block, not shoot out. I mean, trajectory or somethin' like that.
     
  4. Offline

    xTrollxDudex

    There is no way of "shooting" particles. What you can do is shoot an arrow extremely quickly and track it's location to spawn particles there. I don't know about white particles though. I have no idea which particle that is
     
    TigerHix and Woobie like this.
  5. Offline

    Woobie

    Oh, sorry. Must've missed that part while reading. Certainly possible, just a bit more tricky, and I'm not on my pc right now, so I can't test anything, sorry.

    xTrollxDudex
    Any "whitish" block breaking particle? :p
     
    TigerHix likes this.
  6. Offline

    TigerHix

    Woobie
    :) Never mind.
    xTrollxDudex
    Hmm, maybe you can refer to Hypixel's quakecraft, or Bukkit plugin Crackshot. Arrow sounds alright, I will try would shooting arrows creating particles effect.
    Edit: OK, arrows won't have any effects..

    How to track? I have no idea, although I found something call ProjectileLaunchEvent on javadoc.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  7. Offline

    xTrollxDudex

    Woobie
    Is the data a material? Like playEffect(location, Effect.STEP_SOUND, Material.GLASS)?
    TigerHix
    That's not the way it works...
    Code:java
    1. //on player interact event, check for right click block/right click air, item in hand is how
    2. Player player = event.getPlayer();
    3. final Arrow arrow = (Arrow) player.getWorld().spawn(player.getLocation(), Arrow.class);
    4. arrow.setShooter(((LivingEntity) player));
    5. arrow.setVelocity(player.getLocation().getDirection().multiply(3));
    6. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    7. @Override
    8. public void run(){
    9. arrow.getWorld().playEffect(arrow.getLocation(), Effect.STEP_SOUND, Material.WOOL);
    10.  
    11. if(arrow.isOnGround()){
    12. this.cancel()(
    13. }
    14. }
    15. }, 0L, 1L);
     
  8. Offline

    Woobie

    I actually have no idea, never used playEffect before.

    Also, remember to set the arrow shooter.
     
  9. Offline

    TigerHix

    Come out with some fountains.
    [​IMG][​IMG]
     
  10. Offline

    xTrollxDudex

    Woobie
    Actually your not forced to set the shooter and its just an example anyway :p

    Ill edit the code to cancel

    Edit: TigerHix
    Wtf? What did you so where's your code? Also ten off the texture pack its difficult to see

    Edit2: TigerHix
    PHP:
    //on command
    Player player = (Playersender;
    final 
    Arrow arrow = (Arrowplayer.getWorld().spawn(player.getEyeLocation(), Arrow.class);
    arrow.setShooter(((LivingEntityplayer));
    arrow.setVelocity(player.getEyeLocation().getDirection().multiply(2));

    new 
    BukkitRunnable(){

    @
    Override
    public void run(){
    if(!(
    arrow.isOnGround()) || arrow.isDead() == false || arrow.isValid() == true){
    arrow.getWorld().playEffect(arrow.getLocation(), Effect.STEP_SOUNDMaterial.WOOL);

    else if(
    arrow.isOnGround() || arrow.isValid() == false || arrow.isDead() == true){
    this.cancel();
    }
    }

    }.
    runTaskTimer(this0L1L);
    I have not tested for multiple players
     
  11. Offline

    Woobie

    xTrollxDudex
    I seem to go offtopic on almost every thread I post on, but anyways, if you don't set the shooter, then the arrow is going to hit the player.

    TigerHix
    As the guy above said, get rid of the texture pack, hard to see. Also shoot it somewhere else, that ice is messing up the view.
     
    TigerHix likes this.
  12. Offline

    xTrollxDudex

    Woobie
    Right. I'll edit the location too because its wierd to shoot out of a players feet.

    Edit: edited code in post #11
     
    TigerHix likes this.
  13. Offline

    TigerHix

    Well, Runnable don't support cancel(). So I changed it to BukkitRunnable, then compiler goes well. And when you shoot, some particles will follow the arrow. Problem is, they don't stop even arrow hit the ground. Instead, particles keep generating and looks like a fountain..

    [​IMG][​IMG][​IMG]
    [​IMG]
    [​IMG]
    I'm sorry if you feel difficult to see this.. :(
     
  14. Offline

    xTrollxDudex

    TigerHix
    Do you have the if(arrow.isOnGround())?
     
    TigerHix likes this.
  15. Offline

    TigerHix

    Yes.
     
  16. Offline

    xTrollxDudex

    TigerHix
    WEIRD. I have no idea what is going on.
     
  17. Offline

    TigerHix

    xTrollxDudex
    Maybe this.cancel() don't actually cancel the task?
     
  18. Offline

    xTrollxDudex

    TigerHix
    Ok code updated!
    Changelog:
    - cleaned up code
    - changed to bukkit runnable
    - added new checks
    - swagger than ever
    - switched to php syntax because I like the colors :p

    Edit: hypixel's quakecraft uses actual firework sparks which can be achieved with packets, but the only wy is with reflection and the idea of many players shooting a bunch of particles spawned with reflection is just scary because its not safe

    Edit2: changed a changelog-changelogception?
     
    TigerHix likes this.
  19. Offline

    Bammerbom

    TigerHix This are wool breaking textures.
     
    TigerHix and xTrollxDudex like this.
  20. Offline

    ReviveDept

    Use "event.setCancelled(true);" instead of "this.cancel();"
     
  21. Offline

    TigerHix

    xTrollxDudex
    Thanks for code again, but still fountains everywhere.. :eek:
     
  22. Offline

    TheTinySpider

    The problem is, isOnGround() has been glitched forever now, I had to use it myself too to check if an item is on the ground, but it doesn't seem to ever return true, unless you make collision with the item or try to pick it up.
     
  23. Offline

    xTrollxDudex

    TheTinySpider
    That's what I was suspecting. It seems deprecated for most things
     
  24. Offline

    TheTinySpider

    ice374, TigerHix and xTrollxDudex like this.
  25. Offline

    TigerHix

  26. Offline

    xTrollxDudex

    Wrong use of setCancelled.
     
Thread Status:
Not open for further replies.

Share This Page