Use the impaling entity tag for thrown tridents

The bonus went to every swimming or water-breathing mob, including undead,
blazes, ghasts and iron golems. Read the damage from the enchantment data so
only #sensitive_to_impaling mobs take it.
This commit is contained in:
Kacpherek
2026-10-26 18:45:13 +01:00
parent 2ca383f36d
commit 555ddb94bf
+24 -5
View File
@@ -5,6 +5,7 @@
use super::{Game, view_vector};
use horizon_client::{
collisions::SceneCollisions,
enchant::EffectContext,
items::ItemStack,
mesher::Vertex,
mobs::{Damage, DamageKind, Who, anim::Poses},
@@ -305,11 +306,29 @@ impl Game<'_> {
}
}
if let Some((id, _)) = hit_mob {
let impaling = t.stack.enchantment_level("minecraft:impaling") as f32;
let aquatic = self.mobs.iter().find(|m| m.id == id).is_some_and(|m| {
m.kind.flags.aquatic_swimmer || m.kind.flags.breathes_water
});
let damage = 8.0 + if aquatic { 2.5 * impaling } else { 0.0 };
// ThrownTrident.getDamage: `EnchantmentHelper.modifyDamage` on 8
// (impaling hits `#sensitive_to_impaling`, the aquatic tag).
let victim = self
.mobs
.iter()
.find(|m| m.id == id)
.map(|m| m.kind.id.clone());
let ctx = EffectContext {
this: victim.as_deref(),
attacker: Some("minecraft:player"),
direct_attacker: Some("minecraft:trident"),
is_direct: true,
damage_type: Some("minecraft:trident"),
items: Some(self.res.items()),
..Default::default()
};
let damage = self.res.stations().enchantments.modify_value(
Some(&t.stack),
"minecraft:damage",
&ctx,
&mut self.world.random,
8.0,
);
t.dealt_damage = true;
if let Some(m) = self.mobs.iter_mut().find(|m| m.id == id) {
let from = Some([t.position.x, t.position.y, t.position.z]);