mirror of
https://github.com/italicsjenga/valence.git
synced 2024-12-23 14:31: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::<_, _, ()>(
|
||||
|bb| bb.projected_point(pos).distance(pos) <= view_dist as f64 * 16.0,
|
||||
|id, _| {
|
||||
let entity = entities.get(id).unwrap();
|
||||
if entity.typ() != EntityType::Marker && self.loaded_entities.insert(id) {
|
||||
let entity = entities
|
||||
.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(
|
||||
entity
|
||||
.spawn_packet(id)
|
||||
|
|
|
@ -310,6 +310,10 @@ impl Entity {
|
|||
self.flags.set_on_ground(on_ground);
|
||||
}
|
||||
|
||||
pub fn uuid(&self) -> Uuid {
|
||||
self.uuid
|
||||
}
|
||||
|
||||
pub fn push_event(&mut self, event: EntityEvent) {
|
||||
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);
|
||||
|
||||
if server.entities.get_with_uuid(client.uuid()).is_none() {
|
||||
server.clients.insert(client);
|
||||
} else {
|
||||
log::warn!(
|
||||
"client '{}' cannot join the server because their UUID ({}) conflicts with an \
|
||||
existing entity",
|
||||
client.username(),
|
||||
client.uuid()
|
||||
);
|
||||
}
|
||||
server.clients.insert(client);
|
||||
}
|
||||
|
||||
struct Codec {
|
||||
|
|
Loading…
Reference in a new issue