<commit_before>var Vec3 = require("vec3").Vec3;


function randomInt (low, high) {
  return Math.floor(Math.random() * (high - low) + low);
}

module.exports.server=function(serv,settings)
{
  serv.gameMode=settings.gameMode;

  async function findSpawnZone(world,initialPoint)
  {
    var point=initialPoint;
    while((await (world.getBlockType(point)))==0)
      point=point.offset(0,-1,0);
    while(true)
    {
      var p=await world.getBlockType(point);
      if(p.type!=8 && p.type!=9)
        break;
      point=point.offset(1,0,0);
    }
    while((await world.getBlockType(point))!=0)
      point = point.offset(0, 1, 0);

    return point;
  }

  serv.getSpawnPoint = async (world) =>  {
      return await findSpawnZone(world,new Vec3(randomInt(0,30),81,randomInt(0,30)));
  };
};


module.exports.player=async function(player,serv)
{
  player.gameMode=serv.gameMode;
  player.findSpawnPoint=async () => {
    player.spawnPoint=await serv.getSpawnPoint(player.world);
  };
  player._client.on('settings',({viewDistance}) => {
    player.view=viewDistance;
  });
};<commit_msg>fix spawning not in water, fix #63<commit_after>var Vec3 = require("vec3").Vec3;


function randomInt (low, high) {
  return Math.floor(Math.random() * (high - low) + low);
}

module.exports.server=function(serv,settings)
{
  serv.gameMode=settings.gameMode;

  async function findSpawnZone(world,initialPoint)
  {
    var point=initialPoint;
    while((await (world.getBlockType(point)))==0)
      point=point.offset(0,-1,0);
    while(true)
    {
      var p=await world.getBlockType(point);
      if(p!=8 && p!=9)
        break;
      point=point.offset(1,0,0);
    }
    while((await world.getBlockType(point))!=0)
      point = point.offset(0, 1, 0);

    return point;
  }

  serv.getSpawnPoint = async (world) =>  {
      return await findSpawnZone(world,new Vec3(randomInt(0,30),81,randomInt(0,30)));
  };
};


module.exports.player=async function(player,serv)
{
  player.gameMode=serv.gameMode;
  player.findSpawnPoint=async () => {
    player.spawnPoint=await serv.getSpawnPoint(player.world);
  };
  player._client.on('settings',({viewDistance}) => {
    player.view=viewDistance;
  });
};
{'fraction_non_alphanumeric': 0.16537231612608497, 'fraction_numerical': 0.02375513933302878, 'mean_word_length': 3.8993288590604025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7121157', 'n_tokens_mistral': 791, 'n_tokens_neox': 787, 'n_words': 112}