Merge pull request #2152 from kacpherek/fix/trident-unbreaking-riptide
🤖 Agent: Gate check by Ludovic's AI agent (Claude). Checked against 26.3: a thrown trident wears through `hurtAndBreak`, so Unbreaking applies, and `TridentItem.releaseUsing` doesn't launch a riding player with Riptide. Gate: this wave's 55 PRs merged on main in one tree: clippy `-D warnings` clean, 1186 horizon-client and 163 horizon-world tests pass, and of the 101 harnesses `parity.py --changed-files` picked, 100 pass (`block_removal` failed on one spawner case from #2199's orb merging, fixed there). `lan_e2e.py` passes 24 checks with the host on its server thread and in-frame (chest, xp, pvp, doors, villagers, beds, frames, projectiles, arrows, fishing, damage, mobs, blast, drops, elytra, breath, predict, cracks, barter, kills, hurt, contacts, underwater, plates), plus forced-levels on the server thread. Thanks @kacpherek!
This commit is contained in:
@@ -8883,6 +8883,24 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// `ItemStack.hurtWithoutBreaking`: Unbreaking applies, but the stack stops at
|
||||
/// one point of durability left instead of breaking.
|
||||
fn hurt_held_without_breaking(&mut self, amount: u32) {
|
||||
if self.creative {
|
||||
return;
|
||||
}
|
||||
let Some(held) = self.held().cloned() else {
|
||||
return;
|
||||
};
|
||||
let amount = self.durability_loss(&held, amount);
|
||||
let max = self.res.items().get(&held.item).map_or(0, |i| i.max_damage);
|
||||
if amount == 0 || max == 0 {
|
||||
return;
|
||||
}
|
||||
if let Some(stack) = self.held_mut().as_mut() {
|
||||
stack.damage = (stack.damage + amount).min(max - 1);
|
||||
}
|
||||
}
|
||||
/// Block tool use: distinguish success, failure and fall-through for hand feedback.
|
||||
fn use_tool(
|
||||
&mut self,
|
||||
|
||||
@@ -236,10 +236,11 @@ impl Game<'_> {
|
||||
.as_ref()
|
||||
.map(|p| [p.position.x, p.position.y, p.position.z]);
|
||||
if riptide > 0 {
|
||||
if !self.in_water_or_rain() {
|
||||
// `isInWaterOrRain() && !isPassenger()`.
|
||||
if !self.in_water_or_rain() || self.riding.is_some() {
|
||||
return;
|
||||
}
|
||||
self.damage_held(1);
|
||||
self.hurt_held_without_breaking(1);
|
||||
// trident_spin_attack_strength: 1.5 + 0.75 per level above the first.
|
||||
let strength = 1.5 + 0.75 * (riptide as f32 - 1.0);
|
||||
let d = view_vector(self.yaw, self.pitch);
|
||||
@@ -260,12 +261,8 @@ impl Game<'_> {
|
||||
self.audio.play(&sound, at, 1.0, 1.0);
|
||||
return;
|
||||
}
|
||||
// hurtWithoutBreaking, then the thrown copy.
|
||||
if !self.creative
|
||||
&& let Some(s) = self.held_mut().as_mut()
|
||||
{
|
||||
s.damage += 1;
|
||||
}
|
||||
// hurtWithoutBreaking (Unbreaking applies), then the thrown copy.
|
||||
self.hurt_held_without_breaking(1);
|
||||
let thrown = self.held().cloned().unwrap_or(stack);
|
||||
if !self.creative {
|
||||
*self.held_mut() = None;
|
||||
|
||||
Reference in New Issue
Block a user