From 49b1ae1dbc1de775983d5e8933fa5cb3735d8c6d Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 10 Jul 2016 04:23:59 -0700 Subject: [PATCH] Update to minecraft 1.10.2 --- protocol/src/format.rs | 14 ++++++++++++++ protocol/src/nbt/mod.rs | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/protocol/src/format.rs b/protocol/src/format.rs index 6b4ba38..1b1bad9 100644 --- a/protocol/src/format.rs +++ b/protocol/src/format.rs @@ -22,6 +22,20 @@ pub enum Component { } impl Component { + + pub fn from_string(str: &str) -> Self { + let mut component; + match serde_json::from_str::(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 { let mut modifier = Modifier::from_value(v); if let Some(val) = v.as_string() { diff --git a/protocol/src/nbt/mod.rs b/protocol/src/nbt/mod.rs index 5883c9e..ecd9495 100644 --- a/protocol/src/nbt/mod.rs +++ b/protocol/src/nbt/mod.rs @@ -20,7 +20,7 @@ use super::protocol::Serializable; use super::protocol; use byteorder::{BigEndian, WriteBytesExt, ReadBytesExt}; -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum Tag { End, Byte(i8), @@ -36,7 +36,7 @@ pub enum Tag { IntArray(Vec), } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct NamedTag(pub String, pub Tag); impl Tag {