From d112856ff6353592a50658b0ddd316f54dd97b87 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sun, 6 Nov 2022 14:05:01 -0600 Subject: Entity metadata (#37) * add example generated metadata.rs * metadata.rs codegen * add the files * add comment to top of metadata.rs * avoid clone * metadata * defaults * defaults * fix metadata readers and writers * fix bad bitmasks and ignore some clippy warnings in generated code * add set_index function to entity metadatas * applying metadata --- azalea-client/src/client.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'azalea-client/src') diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index f19178c2..ff2e02a9 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -28,7 +28,7 @@ use azalea_protocol::{ resolver, ServerAddress, }; use azalea_world::{ - entity::{EntityData, EntityMut, EntityRef}, + entity::{metadata, EntityData, EntityMetadata, EntityMut, EntityRef}, Dimension, }; use log::{debug, error, warn}; @@ -399,7 +399,11 @@ impl Client { // i'll make this an actual setting later *dimension_lock = Dimension::new(16, height, min_y); - let entity = EntityData::new(client.game_profile.uuid, Vec3::default()); + let entity = EntityData::new( + client.game_profile.uuid, + Vec3::default(), + EntityMetadata::Player(metadata::Player::default()), + ); dimension_lock.add_entity(p.player_id, entity); let mut player_lock = client.player.lock(); @@ -579,8 +583,11 @@ impl Client { let entity = EntityData::from(p); client.dimension.lock().add_entity(p.id, entity); } - ClientboundGamePacket::SetEntityData(_p) => { - // debug!("Got set entity data packet {:?}", p); + ClientboundGamePacket::SetEntityData(p) => { + debug!("Got set entity data packet {:?}", p); + let mut dimension = client.dimension.lock(); + let mut entity = dimension.entity_mut(p.id).expect("Entity doesn't exist"); + entity.apply_metadata(&p.packed_items.0); } ClientboundGamePacket::UpdateAttributes(_p) => { // debug!("Got update attributes packet {:?}", p); -- cgit v1.2.3