Advertisement
Drakia

Untitled

Mar 29th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public void teleport(final Vehicle vehicle, Portal origin) {
  2. Location traveller = new Location(this.world, vehicle.getLocation().getX(), vehicle.getLocation().getY(), vehicle.getLocation().getZ());
  3. Location exit = getExit(traveller, origin);
  4.  
  5. double velocity = vehicle.getVelocity().length();
  6.  
  7. // Stop and teleport
  8. vehicle.setVelocity(new Vector());
  9.  
  10. // Get new velocity
  11. final Vector newVelocity = new Vector();
  12. switch ((int)id.getBlock().getData()) {
  13. case 2:
  14. newVelocity.setZ(-1);
  15. break;
  16. case 3:
  17. newVelocity.setZ(1);
  18. break;
  19. case 4:
  20. newVelocity.setX(-1);
  21. break;
  22. case 5:
  23. newVelocity.setX(1);
  24. break;
  25. }
  26. newVelocity.multiply(velocity);
  27.  
  28. final Entity passenger = vehicle.getPassenger();
  29. vehicle.eject();
  30. vehicle.remove();
  31. final Minecart mc = exit.getWorld().spawnMinecart(exit);
  32. if (passenger != null) {
  33. passenger.teleport(exit);
  34. Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
  35. public void run() {
  36. mc.setPassenger(passenger);
  37. mc.setVelocity(newVelocity);
  38. }
  39. });
  40. } else {
  41. mc.setVelocity(newVelocity);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement