Keep the command harness in the frame; compare finished border chunks
- The command harness (HORIZON_COMMAND_SCRIPT) drives the world itself, without the event loop, so it does not start the server thread. - `status` lists the minecarts a client of a server was sent. - save_roundtrip: single player's server thread finishes the chunks its player tracks, as vanilla's integrated server does, including some that vanilla's server (view distance 4) left before their terrain or light. Those had no blocks, light or heightmaps to compare yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 2818c89f242fd0856c098ceeb7c809c776120240)
This commit is contained in:
@@ -324,7 +324,10 @@ impl Options {
|
||||
dedicated: None,
|
||||
benchmark: None,
|
||||
dev_mods: Vec::new(),
|
||||
server_thread: std::env::var("HORIZON_SERVER_THREAD").map_or(true, |v| v != "0"),
|
||||
// The command harness (HORIZON_COMMAND_SCRIPT) drives the world
|
||||
// itself, without the event loop: it stays in the frame.
|
||||
server_thread: std::env::var("HORIZON_SERVER_THREAD").map_or(true, |v| v != "0")
|
||||
&& std::env::var_os("HORIZON_COMMAND_SCRIPT").is_none(),
|
||||
integrated: false,
|
||||
};
|
||||
let mut session_file = std::env::var("HORIZON_SESSION_FILE").ok();
|
||||
|
||||
@@ -879,7 +879,9 @@ impl Game<'_> {
|
||||
"tridents": self.tridents.len(),
|
||||
"rockets": self.rockets.len(),
|
||||
"fight": self.dragon_status(),
|
||||
"carts": self.carts.iter().map(|c| serde_json::json!({"kind": c.kind.id(), "position": [c.position.x, c.position.y, c.position.z], "velocity": [c.velocity.x, c.velocity.y, c.velocity.z]})).collect::<Vec<_>>(),
|
||||
// A client of a server (single player's server thread) knows the
|
||||
// carts it was sent.
|
||||
"carts": self.remote_carts().unwrap_or_else(|| self.carts.iter().map(|c| serde_json::json!({"kind": c.kind.id(), "position": [c.position.x, c.position.y, c.position.z], "velocity": [c.velocity.x, c.velocity.y, c.velocity.z]})).collect::<Vec<_>>()),
|
||||
"riding": self.riding,
|
||||
"using": self.using,
|
||||
"render_distance": self.streaming.radius,
|
||||
|
||||
@@ -529,6 +529,28 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The minecarts the server sent, for the control socket's `status`
|
||||
/// (their velocity is not tracked here).
|
||||
pub(super) fn remote_carts(&self) -> Option<Vec<serde_json::Value>> {
|
||||
let r = self.remote.as_ref()?;
|
||||
let mut carts: Vec<&Tracked> = r
|
||||
.entities
|
||||
.values()
|
||||
.filter(|t| t.kind.ends_with("minecart"))
|
||||
.collect();
|
||||
carts.sort_by(|a, b| {
|
||||
a.position
|
||||
.partial_cmp(&b.position)
|
||||
.unwrap_or(std::cmp::Ordering::Equal)
|
||||
});
|
||||
Some(
|
||||
carts
|
||||
.into_iter()
|
||||
.map(|t| serde_json::json!({"kind": t.kind, "position": t.position, "velocity": [0.0, 0.0, 0.0]}))
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
||||
/// The names in the server's player list, sorted.
|
||||
pub(super) fn remote_online_names(&self) -> Option<Vec<String>> {
|
||||
let r = self.remote.as_ref()?;
|
||||
|
||||
Reference in New Issue
Block a user