1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Entry module for the Netherrack project

// We'll be using serialization a lot
extern crate rustc_serialize;

// Enable logging and use of logging macros throughout Netherrack
#[macro_use]
extern crate log;

// Allow use of Semantic Versioning througout Netherrack
extern crate semver;
// Also allow usage of Version through Netherrack
pub use semver::Version;

// Allow use of the core module
pub mod core;

// Allow access to I/O operations
pub mod io;

// Allow access to the universe
pub mod universe;

// Okay, this is the start of Netherrack's functions

/// The version of the Minecraft protocol accepted by Netherrack
pub const MINECRAFT_PROTOCOL_VERSION: u32 = 47;

/// The version of Netherrack as determined at compile time
pub const NETHERRACK_VERSION_STRING: &'static str = env!("CARGO_PKG_VERSION");

/// Gets the current version of Netherrack
pub fn get_version() -> Version {
    Version::parse(NETHERRACK_VERSION_STRING).unwrap()
}

/// Starts a new Netherrack server instance
pub fn start_server() {
    
    info!("Netherrack startup called");
    
    trace!("Starting network in a new thread");
    
    std::thread::spawn(move || {
        io::network::start_network();
    });
    
    debug!("Networking should be set up");
    
    loop {
        //TODO: In the future, execute a tick. Use Duration's span function to get time taken, sleep the remainder, and go again
        std::thread::sleep_ms(20);
    }
    
}