Merge branch 'parity-base' into parity/server-leftovers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-13 05:44:19 +02:00
29 changed files with 732 additions and 59 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ pub fn extract(
|| z > max_z + render_distance;
if !deep_inside && !far_outside {
let alpha = 1.0 - border.distance(x, z) / render_distance;
state.alpha = jclamp(alpha.powf(4.0), 0.0, 1.0);
state.alpha = jclamp(horizon_core::jmath::pow(alpha, 4.0), 0.0, 1.0);
state.tint = status_color(border.status());
} else {
state.alpha = 0.0;
@@ -21,6 +21,7 @@ impl Game<'_> {
let mut quiet_since = Instant::now();
let mut step = 0;
let mut step_at = Instant::now();
let mut chat_at = 0;
let mut position = None;
let mut chunks = 0;
let mut error = None;
@@ -44,6 +45,10 @@ impl Game<'_> {
last_chunks = count;
quiet_since = now;
}
// Each step waits for what it sent to be answered (its chat line,
// the /list reply), however busy the machine, up to 15 s.
let shown = self.remote.as_ref().map_or(0, |r| r.chat.len());
let answered = shown > chat_at || now - step_at > Duration::from_secs(15);
match step {
0 if spawned_at.is_some()
&& count > 0
@@ -53,13 +58,15 @@ impl Game<'_> {
self.send_chat("hello from the horizon client");
step = 1;
step_at = now;
chat_at = shown;
}
1 if now - step_at > Duration::from_millis(1500) => {
1 if answered => {
self.send_chat("/list");
step = 2;
step_at = now;
chat_at = shown;
}
2 if now - step_at > Duration::from_millis(1500) => {
2 if answered => {
step = 3;
break;
}
@@ -742,7 +742,7 @@ impl Gate {
// current order, then a stable sort.
for k in &mut self.kids {
let r = self.random.next_float();
k.2 = -f64::from(r).powf(f64::from(1.0_f32 / k.1 as f32));
k.2 = -horizon_core::jmath::pow(f64::from(r), f64::from(1.0_f32 / k.1 as f32));
}
self.kids.sort_by(|a, b| a.2.total_cmp(&b.2));
for k in &mut self.kids {
+5 -5
View File
@@ -6,7 +6,7 @@ use super::{
anim::{Poses, State},
keyframes::Animation,
};
use horizon_core::{geometry::Vec3, random::RandomSource};
use horizon_core::{geometry::Vec3, jmath, random::RandomSource};
use std::collections::HashMap;
// `variant3` is the pose, `variant` the pose the animations last saw,
@@ -96,9 +96,9 @@ fn jump_vector(m: &Mob, target: Vec3, max_velocity: f32, angle: i32) -> Option<V
let r = r2.sqrt();
let y = d.y;
let g = m.gravity();
let sin2 = f64::from(2.0 * angrad).sin();
let cos_sq = f64::from(angrad).cos().powf(2.0);
let (sin, cos) = (f64::from(angrad).sin(), f64::from(angrad).cos());
let sin2 = jmath::sin(f64::from(2.0 * angrad));
let cos_sq = jmath::pow(jmath::cos(f64::from(angrad)), 2.0);
let (sin, cos) = (jmath::sin(f64::from(angrad)), jmath::cos(f64::from(angrad)));
let v0sq = r2 * g / (r * sin2 - 2.0 * y * cos_sq);
if v0sq < 0.0 {
return None;
@@ -108,7 +108,7 @@ fn jump_vector(m: &Mob, target: Vec3, max_velocity: f32, angle: i32) -> Option<V
return None;
}
let (v0r, v0y) = (v0 * cos, v0 * sin);
Some(Vec3::new(v0r * xz.cos(), v0y, v0r * xz.sin()).scale(f64::from(0.95_f32)))
Some(Vec3::new(v0r * jmath::cos(xz), v0y, v0r * jmath::sin(xz)).scale(f64::from(0.95_f32)))
}
/// `LongJump.calculateOptimalJumpVector`: the allowed angles shuffled, the
/// first that reaches the target.
+4 -4
View File
@@ -1,7 +1,7 @@
//! Vanilla's `GoalSelector` (priorities, MOVE/LOOK/JUMP/TARGET control flags,
//! interruption) and the shared goals of `net.minecraft.world.entity.ai.goal`.
use super::{Mob, MobEvent, MobWorld, Seen, Species, Who, world::TargetInfo};
use horizon_core::{geometry::Vec3, random::RandomSource};
use horizon_core::{geometry::Vec3, jmath, random::RandomSource};
use std::sync::Arc;
pub const MOVE: u8 = 1;
@@ -208,8 +208,8 @@ impl Mob {
let yrad = center + f64::from(2.0 * self.random.next_float() - 1.0) * max_rad;
let dist = (min + self.random.next_double().sqrt() * (max - min))
* f64::from(std::f32::consts::SQRT_2);
let xt = -dist * yrad.sin();
let zt = dist * yrad.cos();
let xt = -dist * jmath::sin(yrad);
let zt = dist * jmath::cos(yrad);
if xt.abs() > max || zt.abs() > max {
return None;
}
@@ -934,7 +934,7 @@ impl Goal for RandomLookAround {
}
fn start(&mut self, m: &mut Mob, _: &mut Cx) {
let r = std::f64::consts::TAU * m.random.next_double();
self.rel = [r.cos(), r.sin()];
self.rel = [jmath::cos(r), jmath::sin(r)];
self.time = 20 + m.random.next_int_bound(20).unwrap_or(0);
}
fn every_tick(&self) -> bool {
@@ -550,7 +550,7 @@ impl RunOne {
// order, then a stable sort.
for k in &mut self.kids {
let r = self.random.next_float();
k.2 = -f64::from(r).powf(f64::from(1.0_f32 / k.1 as f32));
k.2 = -horizon_core::jmath::pow(f64::from(r), f64::from(1.0_f32 / k.1 as f32));
}
self.kids.sort_by(|a, b| a.2.total_cmp(&b.2));
for k in &mut self.kids {
@@ -1105,7 +1105,7 @@ impl Gate {
// current order, then a stable sort.
for k in &mut self.kids {
let r = self.random.next_float();
k.2 = -f64::from(r).powf(f64::from(1.0_f32 / k.1 as f32));
k.2 = -horizon_core::jmath::pow(f64::from(r), f64::from(1.0_f32 / k.1 as f32));
}
self.kids.sort_by(|a, b| a.2.total_cmp(&b.2));
}
@@ -2396,7 +2396,7 @@ impl B {
} => {
for k in kids.iter_mut() {
let r = random.next_float();
k.2 = -f64::from(r).powf(f64::from(1.0_f32 / k.1 as f32));
k.2 = -horizon_core::jmath::pow(f64::from(r), f64::from(1.0_f32 / k.1 as f32));
}
kids.sort_by(|a, b| a.2.total_cmp(&b.2));
for k in kids.iter_mut() {
@@ -844,7 +844,7 @@ impl B {
// current order, then a stable sort.
for k in &mut g.kids {
let r = g.random.next_float();
k.2 = -f64::from(r).powf(f64::from(1.0_f32 / k.1 as f32));
k.2 = -horizon_core::jmath::pow(f64::from(r), f64::from(1.0_f32 / k.1 as f32));
}
g.kids.sort_by(|a, b| a.2.total_cmp(&b.2));
for k in &mut g.kids {
+2 -2
View File
@@ -298,7 +298,7 @@ fn double_range(v: f64, lo: f64, hi: f64) -> Option<f64> {
(v.total_cmp(&lo).is_ge() && v.total_cmp(&hi).is_le() && !v.is_nan()).then_some(v)
}
fn log_mouse(value: i32) -> f64 {
10f64.powf(f64::from(value) / 100.0)
horizon_core::jmath::pow(10.0, f64::from(value) / 100.0)
}
fn unit_alt(json: &Json) -> Option<f64> {
codec_double(json)
@@ -366,7 +366,7 @@ impl Spec {
}
(Spec::Fov, V::Int(x)) => (30..=110).contains(x).then(|| v.clone()),
(Spec::WheelSensitivity, V::Double(x)) => {
let i = floor_int(x.log10() * 100.0);
let i = floor_int(horizon_core::jmath::log10(*x) * 100.0);
(-200..=100).contains(&i).then(|| V::Double(log_mouse(i)))
}
(Spec::Unit, V::Double(x)) => (*x >= 0.0 && *x <= 1.0).then(|| v.clone()),