Add 18w50a (451) multiprotocol support (#79)
Adds 18w50a (451) multiprotocol support, last snapshot of 2018 Reference: https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14491 * Use v18w50a module for protocol * Add blasting, smoking, and suspicious stew recipe types * Add entity tags to tags packet * Add chunk data packet variant with height map * Add update light packet * Add chunk format parsing with block_count, without skylights, conditionalize on protocol_version >= 451 * Add villager data entity metadata type parsing https://wiki.vg/Pre-release_protocol#Entity_Metadata * Add open book and entity sound effect packets
This commit is contained in:
parent
68441320e8
commit
264bf6084e
|
@ -321,6 +321,7 @@ impl Metadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
15 => panic!("TODO: particle"),
|
15 => panic!("TODO: particle"),
|
||||||
|
16 => m.put_raw(index, VillagerData::read_from(buf)?),
|
||||||
_ => return Err(protocol::Error::Err("unknown metadata type".to_owned())),
|
_ => return Err(protocol::Error::Err("unknown metadata type".to_owned())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -400,6 +401,10 @@ impl Metadata {
|
||||||
u8::write_to(&15, buf)?;
|
u8::write_to(&15, buf)?;
|
||||||
val.write_to(buf)?;
|
val.write_to(buf)?;
|
||||||
}
|
}
|
||||||
|
Value::Villager(ref val) => {
|
||||||
|
u8::write_to(&16, buf)?;
|
||||||
|
val.write_to(buf)?;
|
||||||
|
}
|
||||||
_ => panic!("unexpected metadata"),
|
_ => panic!("unexpected metadata"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,6 +477,7 @@ pub enum Value {
|
||||||
Block(u16), // TODO: Proper type
|
Block(u16), // TODO: Proper type
|
||||||
NBTTag(nbt::NamedTag),
|
NBTTag(nbt::NamedTag),
|
||||||
Particle(ParticleData),
|
Particle(ParticleData),
|
||||||
|
Villager(VillagerData),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -613,6 +619,27 @@ impl Serializable for ParticleData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct VillagerData {
|
||||||
|
villager_type: protocol::VarInt,
|
||||||
|
profession: protocol::VarInt,
|
||||||
|
level: protocol::VarInt,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serializable for VillagerData {
|
||||||
|
fn read_from<R: io::Read>(buf: &mut R) -> Result<Self, protocol::Error> {
|
||||||
|
let villager_type = protocol::VarInt::read_from(buf)?;
|
||||||
|
let profession = protocol::VarInt::read_from(buf)?;
|
||||||
|
let level = protocol::VarInt::read_from(buf)?;
|
||||||
|
Ok(VillagerData { villager_type, profession, level })
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_to<W: io::Write>(&self, _buf: &mut W) -> Result<(), protocol::Error> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pub trait MetaValue {
|
pub trait MetaValue {
|
||||||
fn unwrap(_: &Value) -> &Self;
|
fn unwrap(_: &Value) -> &Self;
|
||||||
fn wrap(self) -> Value;
|
fn wrap(self) -> Value;
|
||||||
|
@ -823,6 +850,18 @@ impl MetaValue for nbt::NamedTag {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl MetaValue for VillagerData {
|
||||||
|
fn unwrap(value: &Value) -> &Self {
|
||||||
|
match *value {
|
||||||
|
Value::Villager(ref val) => val,
|
||||||
|
_ => panic!("incorrect key"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn wrap(self) -> Value {
|
||||||
|
Value::Villager(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in New Issue