diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2025-02-21 13:43:56 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-21 13:43:56 -0600 |
| commit | 833f306e8b8faddd232b5c736b2134ed08adcb6c (patch) | |
| tree | 08a59009f3118d5c56891d6c4fb6a0293aa9e6fc /azalea-protocol/src/packets/common.rs | |
| parent | 63b1036a96c45b0fefc6ca2501f1cc479acc95de (diff) | |
| download | azalea-drasl-833f306e8b8faddd232b5c736b2134ed08adcb6c.tar.xz | |
Fix errors on switching dimensions (#204)
* Fix errors on switching dimensions
* fix other tests
* clippy
* fix log feature in test_simulation
* fix chunks oops
Diffstat (limited to 'azalea-protocol/src/packets/common.rs')
| -rw-r--r-- | azalea-protocol/src/packets/common.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/azalea-protocol/src/packets/common.rs b/azalea-protocol/src/packets/common.rs index fc78cd7a..ab9c46b4 100644 --- a/azalea-protocol/src/packets/common.rs +++ b/azalea-protocol/src/packets/common.rs @@ -1,9 +1,12 @@ use azalea_buf::AzBuf; use azalea_core::{ + data_registry::ResolvableDataRegistry, game_type::{GameMode, OptionalGameType}, position::GlobalPos, + registry_holder::{DimensionTypeElement, RegistryHolder}, resource_location::ResourceLocation, }; +use tracing::error; #[derive(Clone, Debug, AzBuf)] pub struct CommonPlayerSpawnInfo { @@ -20,3 +23,29 @@ pub struct CommonPlayerSpawnInfo { #[var] pub sea_level: i32, } +impl CommonPlayerSpawnInfo { + pub fn dimension_type( + &self, + registry_holder: &RegistryHolder, + ) -> Option<(ResourceLocation, DimensionTypeElement)> { + let dimension_res = self + .dimension_type + .resolve_and_deserialize::<DimensionTypeElement>(registry_holder); + let Some(dimension_res) = dimension_res else { + error!("Couldn't resolve dimension_type {:?}", self.dimension_type); + return None; + }; + let (dimension_type, dimension_data) = match dimension_res { + Ok(d) => d, + Err(err) => { + error!( + "Couldn't deserialize dimension_type {:?}: {err:?}", + self.dimension_type + ); + return None; + } + }; + + Some((dimension_type, dimension_data)) + } +} |
