Make shoot at enderpearl direction

Discussion in 'Plugin Development' started by negative_codezZ, Jul 22, 2014.

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

    negative_codezZ

    Hello, I need a player to stick to the enderpearl they shot. I tried making the player ride the enderpearl, didn't work. Also tried setting the velocity and multiplying it, just glitches a lot and doesn't exactly follow. Please help.
     
  2. Offline

    fireblast709

    negative_codezZ post any code you tried and tell us what it did and what it should do. Then we might be able to spot bugs that cause the code not to work
     
  3. Offline

    negative_codezZ

    Code:
      @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
            if(event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
                Player player = event.getPlayer();
                if(this.getConfig().getStringList("Worlds").contains(player.getLocation().getWorld().getName())) {
                    if (player.getItemInHand().getType().equals(Material.ENDER_PEARL)) {
                        EnderPearl enderPearl = player.launchProjectile(EnderPearl.class);
                        player.setVelocity(enderPearl.getVelocity().multiply(10));
                        if(!player.getGameMode().equals(GameMode.CREATIVE)) {
                            player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
                        }
                        enderPearled.add(player.getName());
                    }
                }
            }
        }
    Very buggy, doesn't take full way and if used while in air, will glitch bad

    Also
    Code:
    enderPearl.setPassenger(player);
    Doesn't even mount
     
  4. Offline

    Zarkopafilis

    player.setVelocity(enderPearl.getVelocity().multiply(10));

    thats a lot of speed.

    Player p = event.getPlayer();
    Enderpearl endp = p.getWorld().spawn(p.getEyeLocation(), Enderpearl.class);
    endp.setVelocity(p.getLocation().getDirection().multiply(1.5));
    endp.setShooter(p);//idk if needed
    endp.setPassenger(p);
     
  5. Offline

    negative_codezZ

    Doesn't work.
     
    Zarkopafilis likes this.
  6. Offline

    Deleted user

    negative_codezZ
    Check out my ArrowView plugin. Sounds like something around the lines of what you need.

    dev.bukkit.org/bukkit-plugins/arrowview
     
  7. Offline

    Zarkopafilis

    Fix : Spawn the pearl , then listen to a ProjectileLaunchEvent and set the player as passenger!
    After that be sure to disable teleport by enderpearl
     
Thread Status:
Not open for further replies.

Share This Page