Update to minecraft 1.10.2

This commit is contained in:
Techcable 2016-07-10 04:23:59 -07:00 committed by Matthew Collins
parent 862cf97331
commit 49b1ae1dbc
2 changed files with 16 additions and 2 deletions

View File

@ -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() {

View File

@ -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 {