Fix chunks loading multiple times

The default chunk view distance has also been lowered to 2 since that is the most conservative guess.
This commit is contained in:
Ryan 2022-08-10 10:27:25 -07:00
parent d61c3f1f6f
commit b2310db7b7
4 changed files with 9 additions and 6 deletions

View file

@ -12,10 +12,10 @@ use valence::config::{Config, ServerListPing};
use valence::dimension::{Dimension, DimensionId};
use valence::entity::types::Pose;
use valence::entity::{Entity, EntityEvent, EntityId, EntityKind, TrackedData};
use valence::player_list::PlayerListId;
use valence::server::{Server, SharedServer, ShutdownResult};
use valence::text::{Color, TextFormat};
use valence::{async_trait, ident};
use valence::player_list::PlayerListId;
pub fn main() -> ShutdownResult {
env_logger::Builder::new()
@ -56,9 +56,9 @@ impl Config for Game {
type ChunkState = ();
type ClientState = EntityId;
type EntityState = ();
type PlayerListState = ();
type ServerState = ServerState;
type WorldState = ();
type PlayerListState = ();
fn max_connections(&self) -> usize {
// We want status pings to be successful even if the server is full.

View file

@ -9,12 +9,12 @@ use valence::config::{Config, ServerListPing};
use valence::dimension::DimensionId;
use valence::entity::types::Pose;
use valence::entity::{Entity, EntityEvent, EntityId, EntityKind, TrackedData};
use valence::player_list::PlayerListId;
use valence::server::{Server, SharedServer, ShutdownResult};
use valence::spatial_index::RaycastHit;
use valence::text::{Color, TextFormat};
use valence::util::from_yaw_and_pitch;
use vek::Vec3;
use valence::player_list::PlayerListId;
pub fn main() -> ShutdownResult {
env_logger::Builder::new()
@ -46,9 +46,9 @@ impl Config for Game {
type ClientState = EntityId;
/// `true` for entities that have been intersected with.
type EntityState = bool;
type PlayerListState = ();
type ServerState = Option<PlayerListId>;
type WorldState = ();
type PlayerListState = ();
fn max_connections(&self) -> usize {
// We want status pings to be successful even if the server is full.

View file

@ -266,7 +266,7 @@ impl<C: Config> Client<C> {
velocity: Vec3::default(),
yaw: 0.0,
pitch: 0.0,
view_distance: 8,
view_distance: 2,
teleport_id_counter: 0,
pending_teleports: 0,
spawn_position: BlockPos::default(),
@ -879,6 +879,8 @@ impl<C: Config> Client<C> {
// Send the join game packet and other initial packets. We defer this until now
// so that the user can set the client's initial location, game mode, etc.
if self.created_this_tick() {
self.bits.set_spawn(false);
if let Some(id) = &self.new_player_list {
player_lists
.get(id)

View file

@ -31,7 +31,8 @@ pub trait Config: 'static + Sized + Send + Sync + UnwindSafe + RefUnwindSafe {
type WorldState: Send + Sync;
/// Custom state to store with every [`Chunk`](crate::chunk::Chunk).
type ChunkState: Send + Sync;
/// Custom state to store with every [`PlayerList`](crate::player_list::PlayerList).
/// Custom state to store with every
/// [`PlayerList`](crate::player_list::PlayerList).
type PlayerListState: Send + Sync;
/// Called once at startup to get the maximum number of simultaneous