Update to minecraft 1.10.2
This commit is contained in:
parent
e96ec620fb
commit
555b646696
|
@ -1,3 +1,11 @@
|
||||||
target/
|
target/
|
||||||
.rust/
|
.rust/
|
||||||
working/
|
working/
|
||||||
|
|
||||||
|
# Steven Data
|
||||||
|
conf.cfg
|
||||||
|
index
|
||||||
|
objects
|
||||||
|
resources-*
|
||||||
|
servers.json
|
||||||
|
skin-cache
|
||||||
|
|
|
@ -22,6 +22,20 @@ pub enum Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component {
|
impl Component {
|
||||||
|
|
||||||
|
pub fn from_string(str: &str) -> Self {
|
||||||
|
let mut component;
|
||||||
|
match serde_json::from_str::<serde_json::Value>(str) {
|
||||||
|
Ok(value) => component = Component::from_value(&value),
|
||||||
|
// Sometimes mojang sends a literal string, so we should interpret it literally
|
||||||
|
Err(_) => {
|
||||||
|
component = Component::Text(TextComponent::new(str));
|
||||||
|
convert_legacy(&mut component);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_value(v: &serde_json::Value) -> Self {
|
pub fn from_value(v: &serde_json::Value) -> Self {
|
||||||
let mut modifier = Modifier::from_value(v);
|
let mut modifier = Modifier::from_value(v);
|
||||||
if let Some(val) = v.as_string() {
|
if let Some(val) = v.as_string() {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use super::protocol::Serializable;
|
||||||
use super::protocol;
|
use super::protocol;
|
||||||
use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
|
use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Tag {
|
pub enum Tag {
|
||||||
End,
|
End,
|
||||||
Byte(i8),
|
Byte(i8),
|
||||||
|
@ -36,7 +36,7 @@ pub enum Tag {
|
||||||
IntArray(Vec<i32>),
|
IntArray(Vec<i32>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct NamedTag(pub String, pub Tag);
|
pub struct NamedTag(pub String, pub Tag);
|
||||||
|
|
||||||
impl Tag {
|
impl Tag {
|
||||||
|
|
|
@ -34,7 +34,7 @@ use flate2;
|
||||||
use time;
|
use time;
|
||||||
use shared::Position;
|
use shared::Position;
|
||||||
|
|
||||||
pub const SUPPORTED_PROTOCOL: i32 = 109;
|
pub const SUPPORTED_PROTOCOL: i32 = 210;
|
||||||
|
|
||||||
|
|
||||||
/// Helper macro for defining packets
|
/// Helper macro for defining packets
|
||||||
|
|
|
@ -196,7 +196,6 @@ state_packets!(
|
||||||
/// ResourcePackStatus informs the server of the client's current progress
|
/// ResourcePackStatus informs the server of the client's current progress
|
||||||
/// in activating the requested resource pack
|
/// in activating the requested resource pack
|
||||||
packet ResourcePackStatus {
|
packet ResourcePackStatus {
|
||||||
field hash: String =,
|
|
||||||
field result: VarInt =,
|
field result: VarInt =,
|
||||||
}
|
}
|
||||||
/// HeldItemChange is sent when the player changes the currently active
|
/// HeldItemChange is sent when the player changes the currently active
|
||||||
|
@ -448,7 +447,7 @@ state_packets!(
|
||||||
field y: i32 =,
|
field y: i32 =,
|
||||||
field z: i32 =,
|
field z: i32 =,
|
||||||
field volume: f32 =,
|
field volume: f32 =,
|
||||||
field pitch: u8 =,
|
field pitch: f32 =,
|
||||||
}
|
}
|
||||||
/// Disconnect causes the client to disconnect displaying the passed reason.
|
/// Disconnect causes the client to disconnect displaying the passed reason.
|
||||||
packet Disconnect {
|
packet Disconnect {
|
||||||
|
@ -499,6 +498,7 @@ state_packets!(
|
||||||
field new: bool =,
|
field new: bool =,
|
||||||
field bitmask: VarInt =,
|
field bitmask: VarInt =,
|
||||||
field data: LenPrefixedBytes<VarInt> =,
|
field data: LenPrefixedBytes<VarInt> =,
|
||||||
|
field block_entities: LenPrefixed<VarInt, Option<nbt::NamedTag>> =,
|
||||||
}
|
}
|
||||||
/// Effect plays a sound effect or particle at the target location with the
|
/// Effect plays a sound effect or particle at the target location with the
|
||||||
/// volume (of sounds) being relative to the player's position unless
|
/// volume (of sounds) being relative to the player's position unless
|
||||||
|
@ -784,14 +784,6 @@ state_packets!(
|
||||||
field fade_stay: Option<i32> = when(|p: &Title| p.action.0 == 2),
|
field fade_stay: Option<i32> = when(|p: &Title| p.action.0 == 2),
|
||||||
field fade_out: Option<i32> = when(|p: &Title| p.action.0 == 2),
|
field fade_out: Option<i32> = when(|p: &Title| p.action.0 == 2),
|
||||||
}
|
}
|
||||||
/// UpdateSign sets or changes the text on a sign.
|
|
||||||
packet UpdateSign {
|
|
||||||
field location: Position =,
|
|
||||||
field line1: format::Component =,
|
|
||||||
field line2: format::Component =,
|
|
||||||
field line3: format::Component =,
|
|
||||||
field line4: format::Component =,
|
|
||||||
}
|
|
||||||
/// SoundEffect plays the named sound at the target location.
|
/// SoundEffect plays the named sound at the target location.
|
||||||
packet SoundEffect {
|
packet SoundEffect {
|
||||||
field name: VarInt =,
|
field name: VarInt =,
|
||||||
|
@ -800,7 +792,7 @@ state_packets!(
|
||||||
field y: i32 =,
|
field y: i32 =,
|
||||||
field z: i32 =,
|
field z: i32 =,
|
||||||
field volume: f32 =,
|
field volume: f32 =,
|
||||||
field pitch: u8 =,
|
field pitch: f32 =,
|
||||||
}
|
}
|
||||||
/// PlayerListHeaderFooter updates the header/footer of the player list.
|
/// PlayerListHeaderFooter updates the header/footer of the player list.
|
||||||
packet PlayerListHeaderFooter {
|
packet PlayerListHeaderFooter {
|
||||||
|
|
|
@ -30,10 +30,10 @@ use zip;
|
||||||
use types::hash::FNVHash;
|
use types::hash::FNVHash;
|
||||||
use ui;
|
use ui;
|
||||||
|
|
||||||
const RESOURCES_VERSION: &'static str = "1.9.2";
|
const RESOURCES_VERSION: &'static str = "1.10.2";
|
||||||
const VANILLA_CLIENT_URL: &'static str = "https://launcher.mojang.com/mc/game/1.9.2/client/19106fd5e222dca0f2dde9f66db8384c9a7db957/client.jar";
|
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.9";
|
const ASSET_VERSION: &'static str = "1.10.2";
|
||||||
const ASSET_INDEX_URL: &'static str = "https://launchermeta.mojang.com/mc-staging/assets/1.9/13f566a82f5a8a1b5a5552d968a93c2d9b86df66/1.9.json";
|
const ASSET_INDEX_URL: &'static str = "https://launchermeta.mojang.com/mc/assets/1.10/d3bfc4ffba1ea334c725dd91eaf4ecd402d641f7/1.10.json";
|
||||||
|
|
||||||
pub trait Pack: Sync + Send {
|
pub trait Pack: Sync + Send {
|
||||||
fn open(&self, name: &str) -> Option<Box<io::Read>>;
|
fn open(&self, name: &str) -> Option<Box<io::Read>>;
|
||||||
|
|
|
@ -381,7 +381,7 @@ impl Server {
|
||||||
TeleportPlayer => on_teleport,
|
TeleportPlayer => on_teleport,
|
||||||
TimeUpdate => on_time_update,
|
TimeUpdate => on_time_update,
|
||||||
ChangeGameState => on_game_state_change,
|
ChangeGameState => on_game_state_change,
|
||||||
UpdateSign => on_sign_update,
|
UpdateBlockEntity => on_block_entity_update,
|
||||||
PlayerInfo => on_player_info,
|
PlayerInfo => on_player_info,
|
||||||
Disconnect => on_disconnect,
|
Disconnect => on_disconnect,
|
||||||
// Entities
|
// Entities
|
||||||
|
@ -712,19 +712,34 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_sign_update(&mut self, mut update_sign: packet::play::clientbound::UpdateSign) {
|
fn on_block_entity_update(&mut self, block_update: packet::play::clientbound::UpdateBlockEntity) {
|
||||||
use format;
|
match block_update.nbt {
|
||||||
format::convert_legacy(&mut update_sign.line1);
|
None => {
|
||||||
format::convert_legacy(&mut update_sign.line2);
|
// NBT is null, so we need to remove the block entity
|
||||||
format::convert_legacy(&mut update_sign.line3);
|
self.world.add_block_entity_action(world::BlockEntityAction::Remove(
|
||||||
format::convert_legacy(&mut update_sign.line4);
|
block_update.location,
|
||||||
self.world.add_block_entity_action(world::BlockEntityAction::UpdateSignText(
|
));
|
||||||
update_sign.location,
|
},
|
||||||
update_sign.line1,
|
Some(nbt) => {
|
||||||
update_sign.line2,
|
match block_update.action {
|
||||||
update_sign.line3,
|
9 => {
|
||||||
update_sign.line4,
|
use format;
|
||||||
));
|
let line1 = format::Component::from_string(nbt.1.get("Text1").unwrap().as_string().unwrap());
|
||||||
|
let line2 = format::Component::from_string(nbt.1.get("Text2").unwrap().as_string().unwrap());
|
||||||
|
let line3 = format::Component::from_string(nbt.1.get("Text3").unwrap().as_string().unwrap());
|
||||||
|
let line4 = format::Component::from_string(nbt.1.get("Text4").unwrap().as_string().unwrap());
|
||||||
|
self.world.add_block_entity_action(world::BlockEntityAction::UpdateSignText(
|
||||||
|
block_update.location,
|
||||||
|
line1,
|
||||||
|
line2,
|
||||||
|
line3,
|
||||||
|
line4,
|
||||||
|
));
|
||||||
|
},
|
||||||
|
_ => {} // Ignore it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_player_info(&mut self, player_info: packet::play::clientbound::PlayerInfo) {
|
fn on_player_info(&mut self, player_info: packet::play::clientbound::PlayerInfo) {
|
||||||
|
@ -817,6 +832,29 @@ impl Server {
|
||||||
chunk_data.bitmask.0 as u16,
|
chunk_data.bitmask.0 as u16,
|
||||||
chunk_data.data.data
|
chunk_data.data.data
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
for optional_block_entity in chunk_data.block_entities.data {
|
||||||
|
match optional_block_entity {
|
||||||
|
Some(block_entity) => {
|
||||||
|
let x = block_entity.1.get("x").unwrap().as_int().unwrap();
|
||||||
|
let y = block_entity.1.get("y").unwrap().as_int().unwrap();
|
||||||
|
let z = block_entity.1.get("z").unwrap().as_int().unwrap();
|
||||||
|
let tile_id = block_entity.1.get("id").unwrap().as_string().unwrap();
|
||||||
|
let action;
|
||||||
|
match tile_id {
|
||||||
|
// Fake a sign update
|
||||||
|
"Sign" => action = 9,
|
||||||
|
// Not something we care about, so break the loop
|
||||||
|
_ => continue,
|
||||||
|
}
|
||||||
|
self.on_block_entity_update(packet::play::clientbound::UpdateBlockEntity {
|
||||||
|
location: Position::new(x, y, z),
|
||||||
|
action: action,
|
||||||
|
nbt: Some(block_entity.clone()),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
None => {} // Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_chunk_unload(&mut self, chunk_unload: packet::play::clientbound::ChunkUnload) {
|
fn on_chunk_unload(&mut self, chunk_unload: packet::play::clientbound::ChunkUnload) {
|
||||||
|
|
Loading…
Reference in New Issue