示例#1
0
  protected void b(WorldSettings worldsettings) {
    if (!this.worldProvider.e()) {
      this.worldData.setSpawn(0, this.worldProvider.getSeaLevel(), 0);
    } else {
      this.isLoading = true;
      WorldChunkManager worldchunkmanager = this.worldProvider.e;
      List list = worldchunkmanager.a();
      Random random = new Random(this.getSeed());
      ChunkPosition chunkposition = worldchunkmanager.a(0, 0, 256, list, random);
      int i = 0;
      int j = this.worldProvider.getSeaLevel();
      int k = 0;

      // CraftBukkit start
      if (this.generator != null) {
        Random rand = new Random(this.getSeed());
        org.bukkit.Location spawn =
            this.generator.getFixedSpawnLocation(((WorldServer) this).getWorld(), rand);

        if (spawn != null) {
          if (spawn.getWorld() != ((WorldServer) this).getWorld()) {
            throw new IllegalStateException(
                "Cannot set spawn point for "
                    + this.worldData.getName()
                    + " to be in another world ("
                    + spawn.getWorld().getName()
                    + ")");
          } else {
            this.worldData.setSpawn(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
            this.isLoading = false;
            return;
          }
        }
      }
      // CraftBukkit end

      if (chunkposition != null) {
        i = chunkposition.x;
        k = chunkposition.z;
      } else {
        this.getLogger().warning("Unable to find spawn biome");
      }

      int l = 0;

      while (!this.canSpawn(i, k)) { // CraftBukkit - use our own canSpawn
        i += random.nextInt(64) - random.nextInt(64);
        k += random.nextInt(64) - random.nextInt(64);
        ++l;
        if (l == 1000) {
          break;
        }
      }

      this.worldData.setSpawn(i, j, k);
      this.isLoading = false;
      if (worldsettings.c()) {
        this.k();
      }
    }
  }