Particles where player is looking

Discussion in 'Plugin Development' started by Jamez, Nov 20, 2015.

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

    Jamez

    Hey, so what's happening is that I have a spiral of particles coming from a player as an effect. The only problem is that I can't figure out how to set the direction to where the player is looking. Here are some pictures.

    And here's the code:
    Code:
            public void runHelix(Player p) {
                Location loc = p.getEyeLocation();
                  
                double radius = 2;
    
                for (double y = 5; y >= 0; y -= 0.015) {
                    radius = y / 3;
                    double x = radius * Math.cos(3 * y);
                    double z = radius * Math.sin(3 * y);
    
                    double y2 = 5 - y;
    
                    Location loc2 = new Location(loc.getWorld(), loc.getX() + y2, loc.getY() + z, loc.getZ() + x);
                    ParticleEffect.FLAME.display(10, 15, 0, 0, 0, loc2, 10);
                }
    
                for (double y = 5; y >= 0; y -= 0.015) {
                    radius = y / 3;
                    double x = -(radius * Math.cos(3 * y));
                    double z = -(radius * Math.sin(3 * y));
    
                    double y2 = 5 - y;
    
                    Location loc2 = new Location(loc.getWorld(), loc.getX() + y2, loc.getY() + z, loc.getZ() + x);
                    ParticleEffect.FLAME.display(10, 15, 0, 0, 0, loc2, 10);
                }
    
                }
     
  2. Offline

    Creeper674

    I believe that pitch and yaw are the measures of the player's direction that you'll need to use here.
     
  3. Offline

    Jamez

    Thanks, but how would I use that to then point the particles that way?
     
  4. get target block maybe works? im not sure but just thinking what should work for you..
     
  5. Offline

    Jamez

    So that would get me the block in front of a player at any direction?
    Thanks
     
  6. Offline

    mcdorli

    Yes it is.
     
  7. Offline

    Scimiguy

    @Jamez
    getTargetBlock() returns the block that the player's pointer is looking at.
     
  8. Offline

    Jamez

    These messages are quite the opposite of each other. So if I am looking at air, will getTargetBlock() even work?
     
  9. Offline

    Scimiguy

    @Jamez
    Probably give you null, or air.
     
  10. Offline

    mcdorli

    If there is nothing in the sight, then it returns the latest AIR block it can reach
     
  11. Offline

    Jamez

    Ok, so I can use that and they yaw to change the direction of the spiral then? Thanks.
     
Thread Status:
Not open for further replies.

Share This Page