Merge pull request #2111 from kacpherek/fix/2067-deflect-fireballs

🤖 Agent: Read against the vanilla 26.3 sources (Show a hit-back fireball turning at once) and proven in contrib-gate-21's union of 72 kacpherek PRs: 95 parity harnesses on playhorizon and the Mac mini, clippy, 1534 tests, lan_e2e 23 checks in-frame and with --server-thread. Thanks @kacpherek!
This commit is contained in:
Ludovic Marie
2026-10-27 11:12:46 +01:00
committed by GitHub
4 changed files with 13 additions and 0 deletions
@@ -120,6 +120,11 @@ impl Game<'_> {
p.guest = guest;
// Not into the one who turned it on its way out.
p.left_owner = false;
// `AbstractHurtingProjectile.onDeflection` by an attack, and the
// `needsSync` that `AIM_DEFLECT` sets: a server's players see it turn
// at once, not at the fireball's next update ten ticks later.
p.acceleration = 0.1;
p.needs_sync = true;
self.reset_attack_strength();
self.swing_arm();
let from = self
+3
View File
@@ -1030,6 +1030,9 @@ impl Game<'_> {
for m in &mut self.mobs {
m.needs_sync = false;
}
for p in &mut self.creatures.projectiles {
p.needs_sync = false;
}
// `runBlockEvents`' broadcast precedes the tick's block changes
// (`ChunkHolder.broadcastChanges` in `tick_level` below): the
// guest re-runs a piston's `triggerEvent` while its level still
@@ -342,6 +342,7 @@ impl Game<'_> {
let mut e = state(p.id, kind, at(p.position), p.yaw, false);
e.pitch = p.pitch;
e.velocity = at(p.velocity);
e.needs_sync = p.needs_sync;
// Projectile.getAddEntityPacket: the owner's id.
e.data = match p.guest.and_then(|conn| hub.guest(conn)) {
Some(g) => g.entity_id,
+4
View File
@@ -109,6 +109,9 @@ pub struct Projectile {
pub arrow: Option<Box<crate::arrows::ArrowState>>,
/// `AbstractHurtingProjectile.accelerationPower`.
pub acceleration: f64,
/// `Entity.needsSync`: a server tells its clients about the change this
/// tick instead of at the next update interval.
pub needs_sync: bool,
}
/// What a projectile struck this tick.
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -173,6 +176,7 @@ impl Projectile {
left_owner: false,
bonus: Default::default(),
acceleration: 0.1,
needs_sync: false,
arrow: kind_is_arrow.then(|| {
// Entity.random: seeded unpredictably, the position stands in.
Box::new(crate::arrows::ArrowState::new(