2 problems, making a player stay on the ground + doing something when a player shoots an arrow.

Discussion in 'Plugin Development' started by Relentless_x, Apr 13, 2011.

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

    Relentless_x

    Is there anyway to see if a player fires and arrow and then if they do, run something?

    also i have this code which i want to make the guys just move faster, but it also makes you lfy in any direction you look, how can i make them stay on the ground?

    Code:
            if (player.isSneaking())
            {
                if (playerHandler.getRace(player).equalsIgnoreCase("elf")) {
                    Vector dir = player.getLocation().getDirection().multiply(2);
                    player.setVelocity(dir);
    
                }
            }
        }
     
  2. Offline

    ssell

    @Relentless_x

    Your first question (the bow firing) you would listen for right-click events and check to see if the player was wielding a bow.

    For the second problem, the first thing that came to mind was to check under the player for the first non-AIR block and set the player's y-value one above that. Don't know how this would work in practice though.
     
  3. Offline

    Relentless_x

    ok thanks i'll try them both out!

    how can i check if there is air underneath the player been searching the javadocs since i posted last message, ive found nothing :S

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  4. Offline

    Kekec852

    Try :

    Location l = player.getLocation();
    World w = player.getWorld();
    Block b = w.getBlockAt(l.getX(),l.getY() - 1, l.getZ());
    if(b.getType == Materil.AIR){
    //DO somthing
    }
     
  5. Offline

    Relentless_x

    ok thanks ill look into it :) (Y)
     
  6. Offline

    vildaberper

    This works too:
    Code:
    if(player.getWorld().getBlockAt(player.getLocation()).getFace(BlockFace.DOWN).getType().equals(Material.AIR)){
         ...
    }
    
     
  7. Offline

    Relentless_x

    thank you kindly :)
     
Thread Status:
Not open for further replies.

Share This Page