Beispiel #1
0
  @Override
  public boolean teleport(Location location) {
    WorldServer oldWorld = ((CraftWorld) getWorld()).getHandle();
    WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    ServerConfigurationManager manager = server.getHandle();
    EntityPlayer entity = getHandle();
    boolean teleportSuccess;

    if (oldWorld != newWorld) {

      EntityPlayer newEntity =
          new EntityPlayer(manager.c, newWorld, entity.name, new ItemInWorldManager(newWorld));

      newEntity.id = entity.id;
      newEntity.a = entity.a;
      newEntity.health = entity.health;
      newEntity.fireTicks = entity.fireTicks;
      newEntity.inventory = entity.inventory;
      newEntity.inventory.d = newEntity;
      newEntity.activeContainer = entity.activeContainer;
      newEntity.defaultContainer = entity.defaultContainer;
      newEntity.lastwarp = entity.lastwarp; // Buck - It
      newEntity.locX = location.getX();
      newEntity.locY = location.getY();
      newEntity.locZ = location.getZ();
      newEntity.displayName = entity.displayName;
      newEntity.compassTarget = entity.compassTarget;
      newEntity.fauxSleeping = entity.fauxSleeping;
      newWorld.u.c((int) location.getBlockX() >> 4, (int) location.getBlockZ() >> 4);

      teleportSuccess = newEntity.a.teleport(location);

      if (teleportSuccess) {
        manager.c.k.a(entity);
        manager.c.k.b(entity);
        oldWorld.manager.b(entity);
        manager.b.remove(entity);
        oldWorld.e(entity);

        newWorld.manager.a(newEntity);
        newWorld.a(newEntity);
        manager.b.add(newEntity);

        entity.a.e = newEntity;
        this.entity = newEntity;

        setCompassTarget(getCompassTarget());
      }

      return teleportSuccess;
    } else {
      return entity.a.teleport(location);
    }
  }