Apply Unbreaking to thrown tridents and stop Riptide while riding
Throwing a trident now wears it through the same durability path as Riptide, so Unbreaking applies, and it still never breaks the trident. Riptide no longer launches a player who is riding something.
This commit is contained in:
@@ -8660,6 +8660,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,
|
||||
|
||||
@@ -171,10 +171,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);
|
||||
@@ -195,12 +196,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