Solved Particle Beacon

Discussion in 'Plugin Development' started by DogeDebugger, Apr 21, 2015.

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

    DogeDebugger

    I'm trying to make a line of particles going straight up from a location. I know it's kinda frowned upon to just ask for code, but i have no idea...so can anyone give me an example and explain it? Thanks!

    Any code that uses a library/util is fine with me :p
     
  2. player.playEffect

    And just put this in a loop and increment the location y a little bit
     
  3. Offline

    DogeDebugger

    So i got this in a loop:
    p.playEffect(p.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);
    How do i "increment the location y a little bit?"
     
  4. Offline

    SuperOriginal

    getLoacation().add(0,increment,0)
     
  5. @SuperOriginal
    Not really.

    @DogeDebugger
    Create a new location where you want it to happen:
    Location loc = p.getLocation(); //for example

    Make the for-loop
    for(int y = 0; y < 50; y++) {

    Next play the effect at the location loc (inside the loop)
    Next increment the location's y:
    loc.add(0, 0.25, 0);
     
  6. Offline

    BurnerDiamond

    Doge much, such cool, coincidence much.


    Apologies give, had to, chance saw, chance took.
     
    SuperOriginal likes this.
  7. Offline

    DogeDebugger

    That makes a box rather than a line.
    Code:
    for(int y = 0; y < 50; y++) {
           Location loc = p.getLocation();
           loc.add(0, 0.25, 0);
           p.playEffect(loc, Effect.MOBSPAWNER_FLAMES, 0);  
         }
     
    Last edited: Apr 21, 2015
  8. Offline

    SuperOriginal

    How is
    Different from this?
     
  9. Offline

    DogeDebugger

    Solved
    Code:
    @EventHandler
        public void onPlayerJoin(final PlayerInteractEvent event) {
            final Player p = event.getPlayer();
            Location loc = p.getLocation();
            for(int y = 0; y < 50; y++) {
                Location pLoc = loc.add(0, y, 0);
                p.playEffect(pLoc, Effect.MOBSPAWNER_FLAMES, 0);     
            }
        }
     
    Last edited: Apr 21, 2015
  10. @SuperOriginal
    Location variables must be assigned to the location again.
    Code:
    loc.add(0,1,0);
    would not work, but
    Code:
    loc = loc.add(0,1,0);
    would. Correct me if I'm wrong.
     
  11. Offline

    DSH105

    nope – both will function identically but re-assigning is unnecessary.
     
    SuperOriginal likes this.
Thread Status:
Not open for further replies.

Share This Page