Solved Get Location Looking At?

Discussion in 'Plugin Development' started by Meatiex, Jul 30, 2015.

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

    Meatiex

    I want to spawn a firework where a player is looking when they right click with a stick, I don't understand why the code below doesn't work...

    Code:
        @EventHandler
        public void interact(PlayerInteractEntityEvent event) {
            Player player = event.getPlayer();
            if (player.getItemInHand().getType() == Material.STICK)
                fireworkCommand.SpawnFirework(player.getEyeLocation());
        }
    Yes is tested and does work: fireworkCommand.SpawnFirework(loc);

    I know this is probably a really dumb question, but I'v been trying to get this working for literally 2 hours now...
     
  2. Offline

    xXCapzXx

    Ok, this is really silly :V.

    First you didn't even build the fire work, unless if you did that already and your not showing us the code.

    player.getEyeLocation(); means get the height of the eye, so it spawns where you are.

    Maybe you could do:

    Code:
    fireworkCommand.SpawnFirework(player.getTargetBlock(null, 200).getLocation());
    
     
Thread Status:
Not open for further replies.

Share This Page