Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main extends JavaPlugin implements Listener {
- @Override
- public void onEnable() {
- getServer().getPluginManager().registerEvents(this, this);
- }
- @EventHandler
- public void onRightClick(PlayerInteractEvent e) {
- // if (e.getAction() == Action.RIGHT_CLICK_AIR) {
- // Vector v = e.getPlayer().getLocation().getDirection();
- // e.getPlayer().sendMessage(v.length() + "");
- //
- // v = v.multiply(1.5);
- // e.getPlayer().sendMessage(String.format("x=%s, y=%s, z=%s, length=%s",
- // v.getX(), v.getY(), v.getZ(), v.length()));
- // e.getPlayer().setVelocity(v);
- // }
- double angle = Math.toRadians(e.getPlayer().getLocation().getYaw());
- if (e.getAction() == Action.RIGHT_CLICK_AIR) {
- angle += Math.PI;
- double r = 1;
- Vector v = new Vector(r * Math.cos(angle), 0, r * Math.sin(angle));
- e.getPlayer().setVelocity(v);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement