diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2022-12-07 21:09:58 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-07 21:09:58 -0600 |
| commit | 7d901e39bc10a855b545d7b6c167f45148a1fb0a (patch) | |
| tree | 88fe0a8f2f04f49f4df90e2f5462aa35a4278c68 /azalea-world/src/entity/metadata.rs | |
| parent | 9f5e5c092be9167e4d5222fdee4a1d2c419e5052 (diff) | |
| download | azalea-drasl-7d901e39bc10a855b545d7b6c167f45148a1fb0a.tar.xz | |
1.19.3 (#34)
* start updating to 22w42a
* work a bit more on 22w42a
* player chat packet
* serverbound hello packet
* Update mod.rs
* add more stuff to clientbound player chat packet
* ClientboundPlayerInfoUpdatePacket
* features enabled and container closed
* serverbound chat packets
* make it compile
* 22w43a
* ServerboundChatSessionUpdatePacket
* profile_public_key isn't Option anymore
* Update bitset.rs
* joining a server works
* fix entitydatavalue
* backtraces + fix clientbound chat message
* fix some warnings and add more ecomments
* 22w44a
* generate en_us.json
* add updating guide to codegen/readme
* fix some markdown
* update list of generated things
* metadata stuff
* Replace PJS generator mod with PixLyzer (#38)
* pixlizer extractor
* start working on shape extraction
* fix generating language
* fix pixlyzer shape generation
* use empty_shape
* generate blocks and shapes
* update pixlyzer dir
* Revert "update pixlyzer dir"
This reverts commit ee9a0e7a49936dd8569c610ba9b6455895eeff71.
* fix
* fix
* Revert "fix"
This reverts commit ad12ddcb009ccc4eeb13ddef0871db1d9322ab7d.
* fix
* detect pixlyzer fail
* fix pixlyzer
* 22w45a
* gen entities
* add async-trait dep
* update codegen/readme.md
* explain when rust_log should be used
* remove some unused code
* start fixing pixlyzer issues
* fix a thing in codegen
* almost fixed
* more progress towards 1.19.3
* 1.19.3-pre2
* fixes
* revert some hardcoded property names
* Delete clientbound_player_info_packet.rs
* handle 1.19.3 player info packets
* handle playerinforemove
* start updating to 1.19.3-rc1
* optional registries work
* fix some issues with 1.19.3
chat doesn't work yet
* aaaaaaaaaaaaaaaaa
* oh
* ignore unused shapes
* uncomment generate_blocks
* fix migrate
* 1.19.3-rc2
* fix clippy warnings
* 1.19.3-rc3
* split the azalea-buf macro into separate modules
* improve Recipe in protocol
* 1.19.3
Diffstat (limited to 'azalea-world/src/entity/metadata.rs')
| -rw-r--r-- | azalea-world/src/entity/metadata.rs | 154 |
1 files changed, 139 insertions, 15 deletions
diff --git a/azalea-world/src/entity/metadata.rs b/azalea-world/src/entity/metadata.rs index a74635b3..44ec6dae 100644 --- a/azalea-world/src/entity/metadata.rs +++ b/azalea-world/src/entity/metadata.rs @@ -2,7 +2,7 @@ // Don't change it manually! #![allow(clippy::clone_on_copy, clippy::derivable_impls)] -use super::{EntityDataValue, Pose, Rotations, VillagerData}; +use super::{EntityDataValue, OptionalUnsignedInt, Pose, Rotations, VillagerData}; use azalea_block::BlockState; use azalea_chat::Component; use azalea_core::{BlockPos, Direction, Particle, Slot}; @@ -114,7 +114,7 @@ impl Default for AreaEffectCloud { fn default() -> Self { Self { abstract_entity: Default::default(), - radius: 0.5, + radius: 3.0, color: 0, waiting: false, particle: Default::default(), @@ -731,6 +731,119 @@ impl DerefMut for Boat { } #[derive(Debug, Clone)] +pub struct Camel { + pub abstract_animal: AbstractAnimal, + pub tamed: bool, + pub eating: bool, + pub standing: bool, + pub bred: bool, + pub saddled: bool, + pub owner_uuid: Option<Uuid>, + pub dash: bool, + pub last_pose_change_tick: i64, +} + +impl Camel { + pub fn read(metadata: &mut VecDeque<EntityDataValue>) -> Option<Self> { + let abstract_animal = AbstractAnimal::read(metadata)?; + let bitfield = metadata.pop_front()?.into_byte().ok()?; + let tamed = bitfield & 0x2 != 0; + let eating = bitfield & 0x10 != 0; + let standing = bitfield & 0x20 != 0; + let bred = bitfield & 0x8 != 0; + let saddled = bitfield & 0x4 != 0; + let owner_uuid = metadata.pop_front()?.into_optional_uuid().ok()?; + let dash = metadata.pop_front()?.into_boolean().ok()?; + let last_pose_change_tick = metadata.pop_front()?.into_long().ok()?; + Some(Self { + abstract_animal, + tamed, + eating, + standing, + bred, + saddled, + owner_uuid, + dash, + last_pose_change_tick, + }) + } + + pub fn write(&self) -> Vec<EntityDataValue> { + let mut metadata = Vec::new(); + metadata.extend(self.abstract_animal.write()); + let mut bitfield = 0u8; + if self.tamed { + bitfield &= 0x2; + } + if self.eating { + bitfield &= 0x10; + } + if self.standing { + bitfield &= 0x20; + } + if self.bred { + bitfield &= 0x8; + } + if self.saddled { + bitfield &= 0x4; + } + metadata.push(EntityDataValue::Byte(bitfield)); + metadata.push(EntityDataValue::OptionalUuid(self.owner_uuid.clone())); + metadata.push(EntityDataValue::Boolean(self.dash.clone())); + metadata.push(EntityDataValue::Long(self.last_pose_change_tick.clone())); + metadata + } +} + +impl Default for Camel { + fn default() -> Self { + Self { + abstract_animal: Default::default(), + tamed: false, + eating: false, + standing: false, + bred: false, + saddled: false, + owner_uuid: None, + dash: false, + last_pose_change_tick: -52, + } + } +} + +impl Camel { + pub fn set_index(&mut self, index: u8, value: EntityDataValue) -> Option<()> { + match index { + 0..=16 => self.abstract_animal.set_index(index, value)?, + 17 => { + let bitfield = value.into_byte().ok()?; + self.tamed = bitfield & 0x2 != 0; + self.eating = bitfield & 0x10 != 0; + self.standing = bitfield & 0x20 != 0; + self.bred = bitfield & 0x8 != 0; + self.saddled = bitfield & 0x4 != 0; + } + 18 => self.owner_uuid = value.into_optional_uuid().ok()?, + 19 => self.dash = value.into_boolean().ok()?, + 20 => self.last_pose_change_tick = value.into_long().ok()?, + _ => {} + } + Some(()) + } +} +impl Deref for Camel { + type Target = AbstractAnimal; + fn deref(&self) -> &Self::Target { + &self.abstract_animal + } +} +impl DerefMut for Camel { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.abstract_animal + } +} + +#[derive(Debug, Clone)] pub struct Cat { pub abstract_tameable: AbstractTameable, pub variant: azalea_registry::CatVariant, @@ -1733,7 +1846,7 @@ impl DerefMut for EnderPearl { #[derive(Debug, Clone)] pub struct Enderman { pub abstract_monster: AbstractMonster, - pub carry_state: Option<BlockState>, + pub carry_state: BlockState, pub creepy: bool, pub stared_at: bool, } @@ -1741,7 +1854,7 @@ pub struct Enderman { impl Enderman { pub fn read(metadata: &mut VecDeque<EntityDataValue>) -> Option<Self> { let abstract_monster = AbstractMonster::read(metadata)?; - let carry_state = metadata.pop_front()?.into_optional_block_state().ok()?; + let carry_state = metadata.pop_front()?.into_block_state().ok()?; let creepy = metadata.pop_front()?.into_boolean().ok()?; let stared_at = metadata.pop_front()?.into_boolean().ok()?; Some(Self { @@ -1755,9 +1868,7 @@ impl Enderman { pub fn write(&self) -> Vec<EntityDataValue> { let mut metadata = Vec::new(); metadata.extend(self.abstract_monster.write()); - metadata.push(EntityDataValue::OptionalBlockState( - self.carry_state.clone(), - )); + metadata.push(EntityDataValue::BlockState(self.carry_state.clone())); metadata.push(EntityDataValue::Boolean(self.creepy.clone())); metadata.push(EntityDataValue::Boolean(self.stared_at.clone())); metadata @@ -1768,7 +1879,7 @@ impl Default for Enderman { fn default() -> Self { Self { abstract_monster: Default::default(), - carry_state: None, + carry_state: BlockState::Air, creepy: false, stared_at: false, } @@ -1779,7 +1890,7 @@ impl Enderman { pub fn set_index(&mut self, index: u8, value: EntityDataValue) -> Option<()> { match index { 0..=15 => self.abstract_monster.set_index(index, value)?, - 16 => self.carry_state = value.into_optional_block_state().ok()?, + 16 => self.carry_state = value.into_block_state().ok()?, 17 => self.creepy = value.into_boolean().ok()?, 18 => self.stared_at = value.into_boolean().ok()?, _ => {} @@ -2213,7 +2324,7 @@ impl DerefMut for Fireball { pub struct FireworkRocket { pub abstract_entity: AbstractEntity, pub fireworks_item: Slot, - pub attached_to_target: Option<u32>, + pub attached_to_target: OptionalUnsignedInt, pub shot_at_angle: bool, } @@ -2248,7 +2359,7 @@ impl Default for FireworkRocket { Self { abstract_entity: Default::default(), fireworks_item: Slot::Empty, - attached_to_target: None, + attached_to_target: OptionalUnsignedInt(None), shot_at_angle: false, } } @@ -2464,7 +2575,7 @@ impl DerefMut for Fox { pub struct Frog { pub abstract_animal: AbstractAnimal, pub variant: azalea_registry::FrogVariant, - pub tongue_target: Option<u32>, + pub tongue_target: OptionalUnsignedInt, } impl Frog { @@ -2495,7 +2606,7 @@ impl Default for Frog { Self { abstract_animal: Default::default(), variant: azalea_registry::FrogVariant::Temperate, - tongue_target: None, + tongue_target: OptionalUnsignedInt(None), } } } @@ -6421,7 +6532,11 @@ impl Default for Villager { Self { abstract_ageable: Default::default(), unhappy_counter: 0, - villager_data: Default::default(), + villager_data: VillagerData { + kind: azalea_registry::VillagerType::Plains, + profession: azalea_registry::VillagerProfession::None, + level: 0, + }, } } } @@ -7169,7 +7284,11 @@ impl Default for ZombieVillager { Self { zombie: Default::default(), converting: false, - villager_data: Default::default(), + villager_data: VillagerData { + kind: azalea_registry::VillagerType::Plains, + profession: azalea_registry::VillagerProfession::None, + level: 0, + }, } } } @@ -7920,6 +8039,7 @@ pub enum EntityMetadata { Bee(Bee), Blaze(Blaze), Boat(Boat), + Camel(Camel), Cat(Cat), CaveSpider(CaveSpider), ChestBoat(ChestBoat), @@ -8047,6 +8167,7 @@ impl From<azalea_registry::EntityType> for EntityMetadata { azalea_registry::EntityType::Bee => EntityMetadata::Bee(Bee::default()), azalea_registry::EntityType::Blaze => EntityMetadata::Blaze(Blaze::default()), azalea_registry::EntityType::Boat => EntityMetadata::Boat(Boat::default()), + azalea_registry::EntityType::Camel => EntityMetadata::Camel(Camel::default()), azalea_registry::EntityType::Cat => EntityMetadata::Cat(Cat::default()), azalea_registry::EntityType::CaveSpider => { EntityMetadata::CaveSpider(CaveSpider::default()) @@ -8270,6 +8391,7 @@ impl EntityMetadata { EntityMetadata::Bee(entity) => entity.set_index(index, value), EntityMetadata::Blaze(entity) => entity.set_index(index, value), EntityMetadata::Boat(entity) => entity.set_index(index, value), + EntityMetadata::Camel(entity) => entity.set_index(index, value), EntityMetadata::Cat(entity) => entity.set_index(index, value), EntityMetadata::CaveSpider(entity) => entity.set_index(index, value), EntityMetadata::ChestBoat(entity) => entity.set_index(index, value), @@ -8396,6 +8518,7 @@ impl Deref for EntityMetadata { EntityMetadata::Bee(entity) => entity, EntityMetadata::Blaze(entity) => entity, EntityMetadata::Boat(entity) => entity, + EntityMetadata::Camel(entity) => entity, EntityMetadata::Cat(entity) => entity, EntityMetadata::CaveSpider(entity) => entity, EntityMetadata::ChestBoat(entity) => entity, @@ -8520,6 +8643,7 @@ impl DerefMut for EntityMetadata { EntityMetadata::Bee(entity) => entity, EntityMetadata::Blaze(entity) => entity, EntityMetadata::Boat(entity) => entity, + EntityMetadata::Camel(entity) => entity, EntityMetadata::Cat(entity) => entity, EntityMetadata::CaveSpider(entity) => entity, EntityMetadata::ChestBoat(entity) => entity, |
