Merge pull request #2423 from kacpherek/fix/entity-broadcast-range
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: `ChunkMap.TrackedEntity.getEffectiveRange` ends in `scaledRange`, which applies `entity-broadcast-range-percentage`, as done here. Gate: this wave's 50 PRs merged on main in one tree (union 9033a9c3b): fmt and clippy `-D warnings` clean, the horizon-client (1136 lib plus the integration tests), horizon-client-core (37), horizon-world (165) and horizon-protocol (100) tests pass, the fast build links, and the 140 harnesses `parity.py` picks for the tree's changed files pass on playhorizon (remote_fireworks, a known load flake there, passed on a rerun on a quiet Mac mini). `lan_e2e.py` passes 14 checks with the host on its server thread and in-frame (chest, xp, damage, kills, projectiles, mobs, drops, body, stopsound, digging, instant_digging, books, knockback, barter); `hurt` fails on main too when run after `damage` (check-order dependency, not this wave). Thanks @kacpherek!
This commit is contained in:
@@ -654,6 +654,9 @@ impl Game<'_> {
|
||||
// DedicatedServer.initServer ends with saveEverything(false, true, true).
|
||||
self.save_game()?;
|
||||
self.log_saved_levels();
|
||||
if let Some(host) = self.lan.as_mut() {
|
||||
host.hub.entity_range_percent = props.entity_broadcast_range_percentage;
|
||||
}
|
||||
let mut state = ServerState {
|
||||
lists,
|
||||
console,
|
||||
|
||||
@@ -611,8 +611,9 @@ pub struct Viewer<'a> {
|
||||
}
|
||||
|
||||
/// One entity as this tick's range checks read it: where it is
|
||||
/// horizontally, its id, its type's tracking range in chunks and the chunk
|
||||
/// it is in (an index into the tick's chunks).
|
||||
/// horizontally, its id, its tracking range in blocks (scaled by
|
||||
/// `entity-broadcast-range-percentage`) and the chunk it is in (an index
|
||||
/// into the tick's chunks).
|
||||
#[derive(Clone, Copy)]
|
||||
struct Probe {
|
||||
x: f64,
|
||||
@@ -627,7 +628,7 @@ struct Probe {
|
||||
/// each of the tick's chunks whether the client has it (0: not looked up
|
||||
/// yet, 1: no, 2: yes), so each chunk is looked up once per client.
|
||||
fn sees(v: &Viewer, p: &Probe, chunks: &[(i32, i32)], held: &mut [u8]) -> bool {
|
||||
let range = f64::from(p.range.min(v.view_distance) * 16);
|
||||
let range = f64::from(p.range.min(v.view_distance * 16));
|
||||
let (dx, dz) = (v.position[0] - p.x, v.position[2] - p.z);
|
||||
dx * dx + dz * dz <= range * range && {
|
||||
let held = &mut held[p.chunk as usize];
|
||||
@@ -641,6 +642,9 @@ fn sees(v: &Viewer, p: &Probe, chunks: &[(i32, i32)], held: &mut [u8]) -> bool {
|
||||
/// One level's tracked entities (ChunkMap.entityMap).
|
||||
#[derive(Default)]
|
||||
pub struct Entities {
|
||||
/// `entity-broadcast-range-percentage` (None: 100), which scales every
|
||||
/// type's tracking range (MinecraftServer.getScaledTrackingDistance).
|
||||
pub range_percent: Option<i32>,
|
||||
states: crate::fast_hash::FxHashMap<i32, ServerEntity>,
|
||||
/// The level tick, stamped on every entity still in the level.
|
||||
tick: u32,
|
||||
@@ -732,7 +736,9 @@ impl Entities {
|
||||
x: e.position[0],
|
||||
z: e.position[2],
|
||||
id: e.id,
|
||||
range: s.range,
|
||||
range: self
|
||||
.range_percent
|
||||
.map_or(s.range * 16, |p| p * (s.range * 16) / 100),
|
||||
chunk,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -168,6 +168,8 @@ pub struct Hub {
|
||||
level_sync: std::collections::HashMap<String, LevelSync>,
|
||||
/// Operators and their permission levels (dedicated servers).
|
||||
pub ops: std::collections::HashMap<u128, u8>,
|
||||
/// `entity-broadcast-range-percentage` (dedicated servers).
|
||||
pub entity_range_percent: i32,
|
||||
chat_type: i32,
|
||||
dimension_type: i32,
|
||||
clock_ids: Vec<i32>,
|
||||
@@ -335,6 +337,7 @@ impl Hub {
|
||||
ticking: (20.0, false),
|
||||
stepping: 0,
|
||||
ops: Default::default(),
|
||||
entity_range_percent: 100,
|
||||
weather: (false, 0.0, 0.0),
|
||||
level_sync: Default::default(),
|
||||
chat_type,
|
||||
@@ -1705,6 +1708,7 @@ impl Hub {
|
||||
out,
|
||||
})
|
||||
.collect();
|
||||
level.range_percent = Some(self.entity_range_percent);
|
||||
let (types, sync) = (&mut self.entity_types, &self.sync);
|
||||
level.tick(&entities, &self.riding, &mut viewers, |kind| {
|
||||
entity_type(types, sync, kind)
|
||||
|
||||
Reference in New Issue
Block a user