mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-09 02:29:50 -10:00
Riptide: the server tests the player's current box only
A ServerPlayer is client authoritative, so LivingEntity.aiStep does not travel on the server and checkAutoSpinAttack gets the current box twice (26.3 bytecode). Sweeping from where the tick's first move started hit mobs vanilla's server passes through. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
01b9a33298
commit
c7c48fe7a8
1 file changed
+9
-14
@@ -4249,16 +4249,18 @@ impl Game<'_> {
|
||||
|
||||
/// `LivingEntity.checkAutoSpinAttack` for a server's copy of a Riptide
|
||||
/// spinner (it runs before `aiStep`'s countdown clears the damage): the
|
||||
/// first mob in the box swept this tick takes `Player.attack` with the
|
||||
/// spin's damage and the spin ends.
|
||||
pub(super) fn server_spin_attack(&mut self, from: Vec3) {
|
||||
/// first mob touching the player's box takes `Player.attack` with the
|
||||
/// spin's damage and the spin ends. A `ServerPlayer` is client
|
||||
/// authoritative, so its `aiStep` does not travel and both boxes vanilla
|
||||
/// passes are the current one: no sweep over the tick's moves.
|
||||
pub(super) fn server_spin_attack(&mut self) {
|
||||
let Some(p) = self.player.as_ref() else {
|
||||
return;
|
||||
};
|
||||
if p.auto_spin_attack_ticks <= 0 {
|
||||
return;
|
||||
}
|
||||
let swept = p.dimensions.bounds(from).union_bounds(p.bounds());
|
||||
let swept = p.bounds();
|
||||
let riding = self.riding;
|
||||
let Some(index) = first_spin_target(
|
||||
swept,
|
||||
@@ -4317,18 +4319,11 @@ impl Game<'_> {
|
||||
let at = g.position;
|
||||
let (sneaking, sleeping) = (g.sneaking, g.sleeping);
|
||||
let riding = g.vehicle.is_some();
|
||||
// The Riptide spin's sweep starts where the tick's first move did.
|
||||
let spin_from = g
|
||||
.motion
|
||||
if g.motion
|
||||
.as_ref()
|
||||
.is_some_and(|m| m.auto_spin_attack_ticks > 0)
|
||||
.then(|| {
|
||||
moves.iter().fold(Vec3::new(at[0], at[1], at[2]), |p, m| {
|
||||
p.subtract(Vec3::new(m.0[0], m.0[1], m.0[2]))
|
||||
})
|
||||
});
|
||||
if let Some(from) = spin_from {
|
||||
self.as_guest(host, conn, |game| game.server_spin_attack(from));
|
||||
{
|
||||
self.as_guest(host, conn, |game| game.server_spin_attack());
|
||||
}
|
||||
let mut soul = None;
|
||||
let mut jumps = 0;
|
||||
|
||||
Reference in new issue
Block a user