diff --git a/.gitignore b/.gitignore index 7661067..c1c31ce 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,10 @@ target/ .rust/ working/ +# IntelliJ +.idea +*.iml + # Steven Data conf.cfg index diff --git a/.travis.yml b/.travis.yml index 5522b63..78f06ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install sdl2 ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo chown root:wheel /usr/local/bin/brew ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo brew link sdl2 ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link sdl2 ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libsdl2-dev libsdl2-mixer-dev libssl-dev gcc ; fi script: diff --git a/Cargo.toml b/Cargo.toml index 02e7acc..43e78ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,12 @@ name = "steven" version = "0.0.1" authors = [ "Thinkofdeath " ] +[profile.dev] +# Steven runs horrendously slow with no optimizations, and often freezes. +# However, building with full -O3 optimizations takes too long for a debug build. +# Use an -O1 optimization level strikes a good compromise between build and program performance. +opt-level = 1 + [dependencies] sdl2 = "0.16.1" byteorder = "0.5.0" diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index d1b3d02..6bc14c8 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -34,7 +34,7 @@ use flate2; use time; use shared::Position; -pub const SUPPORTED_PROTOCOL: i32 = 210; +pub const SUPPORTED_PROTOCOL: i32 = 315; /// Helper macro for defining packets @@ -200,7 +200,9 @@ impl Serializable for Option where T : Serializable { impl Serializable for String { fn read_from(buf: &mut R) -> Result { - let len = try!(VarInt::read_from(buf)).0; + let len = VarInt::read_from(buf)?.0; + debug_assert!(len >= 0, "Negative string length: {}", len); + debug_assert!(len <= 65536, "String length too big: {}", len); let mut ret = String::new(); try!(buf.take(len as u64).read_to_string(&mut ret)); Result::Ok(ret) diff --git a/src/protocol/packet.rs b/src/protocol/packet.rs index 2b5f8aa..fb4613f 100644 --- a/src/protocol/packet.rs +++ b/src/protocol/packet.rs @@ -231,9 +231,9 @@ state_packets!( field location: Position =, field face: VarInt =, field hand: VarInt =, - field cursor_x: u8 =, - field cursor_y: u8 =, - field cursor_z: u8 =, + field cursor_x: f32 =, + field cursor_y: f32 =, + field cursor_z: f32 =, } /// UseItem is sent when the client tries to use an item. packet UseItem { @@ -281,7 +281,7 @@ state_packets!( packet SpawnMob { field entity_id: VarInt =, field uuid: UUID =, - field ty: u8 =, + field ty: VarInt =, field x: f64 =, field y: f64 =, field z: f64 =, @@ -780,9 +780,10 @@ state_packets!( field action: VarInt =, field title: Option = when(|p: &Title| p.action.0 == 0), field sub_title: Option = when(|p: &Title| p.action.0 == 1), - field fade_in: Option = when(|p: &Title| p.action.0 == 2), - field fade_stay: Option = when(|p: &Title| p.action.0 == 2), - field fade_out: Option = when(|p: &Title| p.action.0 == 2), + field action_bar_text: Option = when(|p: &Title| p.action.0 == 2), + field fade_in: Option = when(|p: &Title| p.action.0 == 3), + field fade_stay: Option = when(|p: &Title| p.action.0 == 3), + field fade_out: Option = when(|p: &Title| p.action.0 == 3), } /// SoundEffect plays the named sound at the target location. packet SoundEffect { @@ -804,6 +805,7 @@ state_packets!( packet CollectItem { field collected_entity_id: VarInt =, field collector_entity_id: VarInt =, + field number_of_items: VarInt =, } /// EntityTeleport teleports the entity to the target location. This is /// sent if the entity moves further than EntityMove allows. diff --git a/src/resources.rs b/src/resources.rs index be1914e..e8efc11 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -30,10 +30,10 @@ use zip; use types::hash::FNVHash; use ui; -const RESOURCES_VERSION: &'static str = "1.10.2"; -const VANILLA_CLIENT_URL: &'static str = "https://launcher.mojang.com/mc/game/1.10.2/client/dc8e75ac7274ff6af462b0dcec43c307de668e40/client.jar"; -const ASSET_VERSION: &'static str = "1.10.2"; -const ASSET_INDEX_URL: &'static str = "https://launchermeta.mojang.com/mc/assets/1.10/d3bfc4ffba1ea334c725dd91eaf4ecd402d641f7/1.10.json"; +const RESOURCES_VERSION: &'static str = "1.11"; +const VANILLA_CLIENT_URL: &'static str = "https://launcher.mojang.com/mc/game/1.11/client/780e46b3a96091a7f42c028c615af45974629072/client.jar"; +const ASSET_VERSION: &'static str = "1.11"; +const ASSET_INDEX_URL: &'static str = "https://launchermeta.mojang.com/mc/assets/1.11/e02b8fba4390e173057895c56ecc91e3ce3bbd40/1.11.json"; pub trait Pack: Sync + Send { fn open(&self, name: &str) -> Option>; diff --git a/src/server/mod.rs b/src/server/mod.rs index 2475a61..3e381ab 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -522,9 +522,9 @@ impl Server { _ => unreachable!(), }), hand: protocol::VarInt(0), - cursor_x: (at.x * 16.0) as u8, - cursor_y: (at.y * 16.0) as u8, - cursor_z: (at.z * 16.0) as u8, + cursor_x: at.x as f32, + cursor_y: at.y as f32, + cursor_z: at.z as f32 }); } }