Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void teleport(final Vehicle vehicle, Portal origin) {
- Location traveller = new Location(this.world, vehicle.getLocation().getX(), vehicle.getLocation().getY(), vehicle.getLocation().getZ());
- Location exit = getExit(traveller, origin);
- double velocity = vehicle.getVelocity().length();
- // Stop and teleport
- vehicle.setVelocity(new Vector());
- // Get new velocity
- final Vector newVelocity = new Vector();
- switch ((int)id.getBlock().getData()) {
- case 2:
- newVelocity.setZ(-1);
- break;
- case 3:
- newVelocity.setZ(1);
- break;
- case 4:
- newVelocity.setX(-1);
- break;
- case 5:
- newVelocity.setX(1);
- break;
- }
- newVelocity.multiply(velocity);
- final Entity passenger = vehicle.getPassenger();
- vehicle.eject();
- vehicle.remove();
- final Minecart mc = exit.getWorld().spawnMinecart(exit);
- if (passenger != null) {
- passenger.teleport(exit);
- Stargate.server.getScheduler().scheduleSyncDelayedTask(Stargate.stargate, new Runnable() {
- public void run() {
- mc.setPassenger(passenger);
- mc.setVelocity(newVelocity);
- }
- });
- } else {
- mc.setVelocity(newVelocity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement