Advertisement
Evyatar12

move to the right

Aug 14th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public class Main extends JavaPlugin implements Listener {
  2.    
  3.     @Override
  4.     public void onEnable() {
  5.         getServer().getPluginManager().registerEvents(this, this);
  6.     }
  7.    
  8.     @EventHandler
  9.     public void onRightClick(PlayerInteractEvent e) {
  10. //      if (e.getAction() == Action.RIGHT_CLICK_AIR) {
  11. //          Vector v = e.getPlayer().getLocation().getDirection();
  12. //          e.getPlayer().sendMessage(v.length() + "");
  13. //         
  14. //          v = v.multiply(1.5);
  15. //          e.getPlayer().sendMessage(String.format("x=%s, y=%s, z=%s, length=%s",
  16. //                  v.getX(), v.getY(), v.getZ(), v.length()));
  17. //          e.getPlayer().setVelocity(v);
  18. //      }
  19.        
  20.         double angle = Math.toRadians(e.getPlayer().getLocation().getYaw());
  21.                
  22.         if (e.getAction() == Action.RIGHT_CLICK_AIR) {
  23.             angle += Math.PI;
  24.             double r = 1;
  25.             Vector v = new Vector(r * Math.cos(angle), 0, r * Math.sin(angle));
  26.             e.getPlayer().setVelocity(v);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement