From b2310db7b747cd912eb95a7769d4cbc399458f14 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 10 Aug 2022 10:27:25 -0700 Subject: [PATCH] Fix chunks loading multiple times The default chunk view distance has also been lowered to 2 since that is the most conservative guess. --- examples/conway.rs | 4 ++-- examples/raycast.rs | 4 ++-- src/client.rs | 4 +++- src/config.rs | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/conway.rs b/examples/conway.rs index e6bbfc9..164f7cc 100644 --- a/examples/conway.rs +++ b/examples/conway.rs @@ -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. diff --git a/examples/raycast.rs b/examples/raycast.rs index 97c4969..4dc4539 100644 --- a/examples/raycast.rs +++ b/examples/raycast.rs @@ -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; type WorldState = (); - type PlayerListState = (); fn max_connections(&self) -> usize { // We want status pings to be successful even if the server is full. diff --git a/src/client.rs b/src/client.rs index 7547972..0ce4430 100644 --- a/src/client.rs +++ b/src/client.rs @@ -266,7 +266,7 @@ impl Client { 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 Client { // 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) diff --git a/src/config.rs b/src/config.rs index b86011f..2e2bfa8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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