mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 22:41:30 +11:00
Don't load entities with the same UUID as the client
This commit is contained in:
parent
0d07b3659f
commit
4aca4e24a7
|
@ -962,8 +962,13 @@ impl Client {
|
||||||
world.spatial_index.query::<_, _, ()>(
|
world.spatial_index.query::<_, _, ()>(
|
||||||
|bb| bb.projected_point(pos).distance(pos) <= view_dist as f64 * 16.0,
|
|bb| bb.projected_point(pos).distance(pos) <= view_dist as f64 * 16.0,
|
||||||
|id, _| {
|
|id, _| {
|
||||||
let entity = entities.get(id).unwrap();
|
let entity = entities
|
||||||
if entity.typ() != EntityType::Marker && self.loaded_entities.insert(id) {
|
.get(id)
|
||||||
|
.expect("entities in spatial index should be valid");
|
||||||
|
if entity.typ() != EntityType::Marker
|
||||||
|
&& entity.uuid() != self.uuid
|
||||||
|
&& self.loaded_entities.insert(id)
|
||||||
|
{
|
||||||
self.send_packet(
|
self.send_packet(
|
||||||
entity
|
entity
|
||||||
.spawn_packet(id)
|
.spawn_packet(id)
|
||||||
|
|
|
@ -310,6 +310,10 @@ impl Entity {
|
||||||
self.flags.set_on_ground(on_ground);
|
self.flags.set_on_ground(on_ground);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn uuid(&self) -> Uuid {
|
||||||
|
self.uuid
|
||||||
|
}
|
||||||
|
|
||||||
pub fn push_event(&mut self, event: EntityEvent) {
|
pub fn push_event(&mut self, event: EntityEvent) {
|
||||||
self.events.push(event);
|
self.events.push(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,16 +426,7 @@ fn join_player(server: &mut Server, msg: NewClientMessage) {
|
||||||
|
|
||||||
let client = Client::new(c2s_packet_channels, &server.shared, msg.ncd);
|
let client = Client::new(c2s_packet_channels, &server.shared, msg.ncd);
|
||||||
|
|
||||||
if server.entities.get_with_uuid(client.uuid()).is_none() {
|
|
||||||
server.clients.insert(client);
|
server.clients.insert(client);
|
||||||
} else {
|
|
||||||
log::warn!(
|
|
||||||
"client '{}' cannot join the server because their UUID ({}) conflicts with an \
|
|
||||||
existing entity",
|
|
||||||
client.username(),
|
|
||||||
client.uuid()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Codec {
|
struct Codec {
|
||||||
|
|
Loading…
Reference in a new issue