Skip to content

Minecraft: Java Edition 26.3 rewritten from scratch in Rust, checked against vanilla with 281 differential harnesses. Get it with the Horizon launcher.

Merge main into perf/tracking-chunk-index

Ludovic Marie270439435517
diff --cc crates/horizon-client/src/lan/entity.rs
index 686f52733,f61400b7f..be94fbf4d
--- a/crates/horizon-client/src/lan/entity.rs
+++ b/crates/horizon-client/src/lan/entity.rs
@@@ -837,34 -871,17 +882,34 @@@ impl Entities
.get(&v.entity_id)
.is_none_or(|s| s.seen != now || self.is_moved[s.index]);
if all {
- flags.extend(self.probes.iter().zip(pairs.iter_mut()).map(|(p, pairs)| {
- if p.id == v.entity_id || !sees(v, p, chunks, held) {
- 0
- } else if v.tracker.seen.contains_key(&p.id) {
- kept += 1;
- SEES | TRACKS
- } else {
- *pairs = true;
- SEES
+ // `sees` caps the range at its view distance, so only the
+ // entities in chunks that far from its own can be seen; the
+ // rest stay 0, as checking each of them gave.
+ flags.resize(self.probes.len(), 0);
+ let reach = v.view_distance + 1;
+ let (vx, vz) = (
+ (v.position[0].floor() as i32) >> 4,
+ (v.position[2].floor() as i32) >> 4,
+ );
+ for (&(cx, cz), members) in chunks.iter().zip(members) {
+ if (cx - vx).abs() > reach || (cz - vz).abs() > reach {
+ continue;
}
- }));
+ for &index in members {
+ let index = index as usize;
+ let p = &self.probes[index];
+ if p.id == v.entity_id || !sees(v, p, chunks, held) {
+ continue;
+ }
- if v.tracker.seen.contains(&p.id) {
++ if v.tracker.seen.contains_key(&p.id) {
+ flags[index] = SEES | TRACKS;
+ kept += 1;
+ } else {
+ flags[index] = SEES;
+ pairs[index] = true;
+ }
+ }
+ }
} else if v.tracker.seen.len() * 4 > self.probes.len() {
// Otherwise its pairs stay as they were, but for the entities
// that appeared or changed section; a client tracking much