Prevent entity from spawning in the player

Discussion in 'Plugin Development' started by Shadow_Parallax, May 11, 2014.

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

    Shadow_Parallax

    I'm trying to spawn a Fireball on the players location but with an offset so it doesn't explode in me. I've tried the following:
    Code:java
    1. Location pLoc = vp.getPlayer().getLocation();
    2. Location spawnLoc = new Location(vp.getPlayer().getWorld(), pLoc.getX() - (OFFSET * Math.cos(Math.toRadians(pLoc.getYaw()))), pLoc.getY() + vp.getPlayer().getEyeHeight(), pLoc.getZ() - (OFFSET * Math.cos(Math.toRadians(pLoc.getYaw()))));
    3. spawnLoc.setYaw(pLoc.getYaw());
    4. spawnLoc.setPitch(pLoc.getPitch());
    5. vp.getPlayer().getWorld().spawnEntity(spawnLoc, EntityType.FIREBALL);


    And before you comment on me having a reference to the player object, I make sure to null it when the player leaves. OFFSET is the offset as float btw.
     
  2. Offline

    Garris0n

    Just add their direction vector to the location so it spawns a bit in front of them.
     
Thread Status:
Not open for further replies.

Share This Page