Creating Egg Throw

Discussion in 'Plugin Development' started by DS_STORE, Feb 4, 2016.

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

    DS_STORE

    I got the following code:
    Show Spoiler

    Code:
    Entity egg = player.getWorld().spawnEntity(player.getLocation().add(player.getLocation().getDirection()), EntityType.EGG)
    egg.setVelocity(player.getLocation().getDirection())

    There is just one problem:
    I had to add (player.getLocation().getDirection()) to the spawn location cause otherwise the egg would spawn inside of the player and instantly break. Now it breaks if the code is executed when the player look higher than -51.1. How may I fix this?
    Second: When I spawn this egg its a lot lower than a normal one. How to get it up? (I'm to dump)

    Fixed both. Had to add (0, 1.5, 0)

    Edit: now you hit yourself if you throw downwards...
     
    Last edited by a moderator: Feb 4, 2016
  2. Offline

    GamerzKing

    Egg egg = player.launchProjectile(Egg.class)
    egg.setVelocity(player.getLocation().getDirection().multiply(1.6));
     
  3. Offline

    Flaps

    That'll work.
     
Thread Status:
Not open for further replies.

Share This Page