svdragster

shoot arrow

Sep 19th, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. Player player = Canary.getServer().getPlayer(caller.getName());
  2. double pitch = (player.getPitch() + 90.0F) * Math.PI / 180.0D;
  3. double rot = (player.getRotation() + 90.0F) * Math.PI / 180.0D;
  4. double x = Math.sin(pitch) * Math.cos(rot);
  5. double y = Math.sin(pitch) * Math.sin(rot);
  6. double z = Math.cos(pitch);
  7. Vector3D v = new Vector3D(x, z, y); // Wichtig hier ist x, z, y weil in minecraft z und y vertauscht sind
  8. v.multiply(3);
  9. Arrow entity = (Arrow) Canary.factory().getEntityFactory().newEntity(EntityType.ARROW, player.getLocation());
  10. entity.spawn();
  11. entity.moveEntity(v.getX(), v.getY(), v.getZ());
Advertisement
Add Comment
Please, Sign In to add comment