aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-protocol/src')
-rw-r--r--azalea-protocol/src/packets/common.rs29
-rwxr-xr-xazalea-protocol/src/packets/game/c_level_chunk_with_light.rs1
-rwxr-xr-xazalea-protocol/src/packets/game/c_light_update.rs2
3 files changed, 31 insertions, 1 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))
+ }
+}
diff --git a/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs b/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs
index c9cdd508..9166e0eb 100755
--- a/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs
+++ b/azalea-protocol/src/packets/game/c_level_chunk_with_light.rs
@@ -6,6 +6,7 @@ use super::c_light_update::ClientboundLightUpdatePacketData;
#[derive(Clone, Debug, AzBuf, ClientboundGamePacket)]
pub struct ClientboundLevelChunkWithLight {
+ // this can't be a ChunkPos since that reads z first and then x
pub x: i32,
pub z: i32,
pub chunk_data: ClientboundLevelChunkPacketData,
diff --git a/azalea-protocol/src/packets/game/c_light_update.rs b/azalea-protocol/src/packets/game/c_light_update.rs
index 72523291..62b7a59d 100755
--- a/azalea-protocol/src/packets/game/c_light_update.rs
+++ b/azalea-protocol/src/packets/game/c_light_update.rs
@@ -11,7 +11,7 @@ pub struct ClientboundLightUpdate {
pub light_data: ClientboundLightUpdatePacketData,
}
-#[derive(Clone, Debug, AzBuf)]
+#[derive(Clone, Debug, AzBuf, Default)]
pub struct ClientboundLightUpdatePacketData {
pub sky_y_mask: BitSet,
pub block_y_mask: BitSet,