aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-06 09:28:28 -1030
committermat <git@matdoes.dev>2025-05-07 06:00:29 +1000
commitaf3affb467c01ee2880fbbc366ea0420c0580ab8 (patch)
treef8619a19b927f18cdf18445890f65cedb9773f58 /azalea-client/src
parent68f657310bf7f69f7f9dd0476ca9c04da191ab33 (diff)
downloadazalea-drasl-af3affb467c01ee2880fbbc366ea0420c0580ab8.tar.xz
fix chunk errors when joining a world with a same name but different height
Diffstat (limited to 'azalea-client/src')
-rw-r--r--azalea-client/src/local_player.rs14
-rw-r--r--azalea-client/src/plugins/packet/game/mod.rs7
2 files changed, 19 insertions, 2 deletions
diff --git a/azalea-client/src/local_player.rs b/azalea-client/src/local_player.rs
index 455cc470..bf1609ab 100644
--- a/azalea-client/src/local_player.rs
+++ b/azalea-client/src/local_player.rs
@@ -144,6 +144,20 @@ impl InstanceHolder {
))),
}
}
+
+ /// Reset the `Instance` to a new reference to an empty instance, but with
+ /// the same registries as the current one.
+ ///
+ /// This is used by Azalea when entering the config state.
+ pub fn reset(&mut self) {
+ let registries = self.instance.read().registries.clone();
+
+ let mut new_instance = Instance::default();
+ new_instance.registries = registries;
+ self.instance = Arc::new(RwLock::new(new_instance));
+
+ self.partial_instance.write().reset();
+ }
}
#[derive(Error, Debug)]
diff --git a/azalea-client/src/plugins/packet/game/mod.rs b/azalea-client/src/plugins/packet/game/mod.rs
index 71766f8b..b301973f 100644
--- a/azalea-client/src/plugins/packet/game/mod.rs
+++ b/azalea-client/src/plugins/packet/game/mod.rs
@@ -1496,10 +1496,11 @@ impl GamePacketHandler<'_> {
pub fn start_configuration(&mut self, _p: &ClientboundStartConfiguration) {
debug!("Got start configuration packet");
- as_system::<(Commands, Query<&mut RawConnection>)>(
+ as_system::<(Commands, Query<(&mut RawConnection, &mut InstanceHolder)>)>(
self.ecs,
|(mut commands, mut query)| {
- let Some(mut raw_conn) = query.get_mut(self.player).ok() else {
+ let Some((mut raw_conn, mut instance_holder)) = query.get_mut(self.player).ok()
+ else {
warn!("Got start configuration packet but player doesn't have a RawConnection");
return;
};
@@ -1515,6 +1516,8 @@ impl GamePacketHandler<'_> {
.insert(crate::client::InConfigState)
.remove::<crate::JoinedClientBundle>()
.remove::<EntityBundle>();
+
+ instance_holder.reset();
},
);
}