I'm trying to make a turret in Bukkit (Java). This will shoot an arrow to the players that are in the shooting radius. But now I've a little problem, the arrow gets stuck inside the block where its spawned. Now I'm trying to spawn the arrow at the side of that block so it wont get stuck anymore, but I don't know how to calculate the best side of the block to set the new spawn location. Like North, East, South or West of the block.
So is there someone who can help me with this? Thnx!
Code that I use for now:
Vector v = pl.getLocation().add(0, 2, 0).toVector().subtract(loc.toVector()); Arrow arrow = (Arrow) Bukkit.getWorld(loc.getWorld().getName()).spawnArrow(loc, v, (float) 4, t.getAccuracy());
So the variable loc needs to be recalculated so it will be outside the block to the right direction from the vector 'v'.