mirror of
https://github.com/italicsjenga/valence.git
synced 2025-01-11 07:11:30 +11:00
Only set center chunk when crossing chunk borders, not sections
This commit is contained in:
parent
d9b7008827
commit
b13fe32f76
|
@ -15,7 +15,7 @@ impl ChunkPos {
|
|||
Self { x, z }
|
||||
}
|
||||
|
||||
/// Takes an absolute position and returns the chunk position
|
||||
/// Takes an X and Z position in world space and returns the chunk position
|
||||
/// containing the point.
|
||||
pub fn at(x: f64, z: f64) -> Self {
|
||||
Self::new((x / 16.0).floor() as i32, (z / 16.0).floor() as i32)
|
||||
|
|
|
@ -1224,18 +1224,13 @@ impl<C: Config> Client<C> {
|
|||
|
||||
let center = ChunkPos::at(self.position.x, self.position.z);
|
||||
|
||||
// Send the update view position packet if the client changes the chunk section
|
||||
// they're in.
|
||||
{
|
||||
let old_section = self.old_position.map(|n| (n / 16.0).floor() as i32);
|
||||
let new_section = self.position.map(|n| (n / 16.0).floor() as i32);
|
||||
|
||||
if old_section != new_section {
|
||||
// Send the update view position packet if the client changes the chunk they're
|
||||
// in.
|
||||
if ChunkPos::at(self.old_position.x, self.old_position.z) != center {
|
||||
self.send_packet(SetCenterChunk {
|
||||
chunk_x: VarInt(new_section.x),
|
||||
chunk_z: VarInt(new_section.z),
|
||||
})
|
||||
}
|
||||
chunk_x: VarInt(center.x),
|
||||
chunk_z: VarInt(center.z),
|
||||
});
|
||||
}
|
||||
|
||||
let dimension = shared.dimension(world.meta.dimension());
|
||||
|
|
Loading…
Reference in a new issue