diff options
| author | mat <github@matdoes.dev> | 2022-09-10 19:46:01 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-09-10 19:46:01 -0500 |
| commit | c31a1f943464a096e0988363f4d56c937465642f (patch) | |
| tree | e1c72f288e4b63a812fc5e16d212415faef1a168 | |
| parent | 749c243fc51a212fa2479f10474079e6f7a95231 (diff) | |
| download | azalea-drasl-c31a1f943464a096e0988363f4d56c937465642f.tar.xz | |
fix outdated EntityDataValue
| -rwxr-xr-x | Cargo.lock | 1 | ||||
| -rw-r--r-- | azalea-protocol/azalea-protocol-macros/src/lib.rs | 2 | ||||
| -rwxr-xr-x | azalea-protocol/src/read.rs | 5 | ||||
| -rw-r--r-- | azalea-world/Cargo.toml | 1 | ||||
| -rw-r--r-- | azalea-world/src/entity/data.rs | 14 |
5 files changed, 19 insertions, 4 deletions
@@ -294,6 +294,7 @@ dependencies = [ "azalea-chat", "azalea-core", "azalea-nbt", + "azalea-registry", "log", "nohash-hasher", "thiserror", diff --git a/azalea-protocol/azalea-protocol-macros/src/lib.rs b/azalea-protocol/azalea-protocol-macros/src/lib.rs index d15fecf0..a83c09bb 100644 --- a/azalea-protocol/azalea-protocol-macros/src/lib.rs +++ b/azalea-protocol/azalea-protocol-macros/src/lib.rs @@ -365,7 +365,7 @@ fn variant_name_from(name: &syn::Ident) -> syn::Ident { variant_name = variant_name["Serverbound".len()..].to_string(); } if variant_name.ends_with("Packet") { - variant_name = variant_name[..variant_name.len()-"Packet".len()].to_string(); + variant_name = variant_name[..variant_name.len() - "Packet".len()].to_string(); } syn::Ident::new(&variant_name, name.span()) } diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs index 3ff24f72..313fb412 100755 --- a/azalea-protocol/src/read.rs +++ b/azalea-protocol/src/read.rs @@ -221,7 +221,10 @@ where #[cfg(test)] mod tests { use super::*; - use crate::packets::game::{clientbound_player_chat_packet::ChatType, ClientboundGamePacket}; + use crate::packets::{ + game::{clientbound_player_chat_packet::ChatType, ClientboundGamePacket}, + handshake::ClientboundHandshakePacket, + }; use std::io::Cursor; #[tokio::test] diff --git a/azalea-world/Cargo.toml b/azalea-world/Cargo.toml index 96365653..053c2534 100644 --- a/azalea-world/Cargo.toml +++ b/azalea-world/Cargo.toml @@ -13,6 +13,7 @@ azalea-buf = {path = "../azalea-buf", version = "^0.1.0"} azalea-chat = {path = "../azalea-chat", version = "^0.1.0"} azalea-core = {path = "../azalea-core", version = "^0.1.0"} azalea-nbt = {path = "../azalea-nbt", version = "^0.1.0"} +azalea-registry = {path = "../azalea-registry", version = "^0.1.0"} log = "0.4.17" nohash-hasher = "0.2.0" thiserror = "1.0.34" diff --git a/azalea-world/src/entity/data.rs b/azalea-world/src/entity/data.rs index ff708653..ba8a2157 100644 --- a/azalea-world/src/entity/data.rs +++ b/azalea-world/src/entity/data.rs @@ -1,7 +1,7 @@ use azalea_buf::{BufReadError, McBufVarReadable}; use azalea_buf::{McBuf, McBufReadable, McBufWritable}; use azalea_chat::component::Component; -use azalea_core::{BlockPos, Direction, Particle, Slot}; +use azalea_core::{BlockPos, Direction, GlobalPos, Particle, Slot}; use std::io::{Read, Write}; use uuid::Uuid; @@ -67,6 +67,10 @@ pub enum EntityDataValue { // 0 for absent; 1 + actual value otherwise. Used for entity IDs. OptionalUnsignedInt(Option<u32>), Pose(Pose), + CatVariant(azalea_registry::CatVariant), + FrogVariant(azalea_registry::FrogVariant), + GlobalPos(GlobalPos), + PaintingVariant(azalea_registry::PaintingVariant), } impl McBufReadable for EntityDataValue { @@ -91,7 +95,7 @@ impl McBufReadable for EntityDataValue { 11 => EntityDataValue::Direction(Direction::read_from(buf)?), 12 => EntityDataValue::OptionalUuid(Option::<Uuid>::read_from(buf)?), 13 => EntityDataValue::OptionalBlockState({ - let val = i32::read_from(buf)?; + let val = i32::var_read_from(buf)?; if val == 0 { None } else { @@ -110,6 +114,12 @@ impl McBufReadable for EntityDataValue { } }), 18 => EntityDataValue::Pose(Pose::read_from(buf)?), + 19 => EntityDataValue::CatVariant(azalea_registry::CatVariant::read_from(buf)?), + 20 => EntityDataValue::FrogVariant(azalea_registry::FrogVariant::read_from(buf)?), + 21 => EntityDataValue::GlobalPos(GlobalPos::read_from(buf)?), + 22 => { + EntityDataValue::PaintingVariant(azalea_registry::PaintingVariant::read_from(buf)?) + } _ => { return Err(BufReadError::UnexpectedEnumVariant { id: data_type as i32, |
