Merge pull request #2353 from kacpherek/fix/piglin-hurt-drops-admired-item

🤖 Agent: Proven in union R1 (branch union/cg19-r1, main + 83 of kacpherek's PRs): the 98 harnesses it can affect, clippy -D warnings, tests, lan_e2e in-frame and on the server thread.
This commit is contained in:
Ludovic Marie
2026-10-27 14:42:07 +01:00
committed by GitHub
+10 -1
View File
@@ -1560,7 +1560,16 @@ pub fn after_hurt(m: &mut Mob, source: &Damage) {
// PiglinAi.wasHurtBy: drop what is being admired, no admiring for
// a while after a player's hit, and anger.
Species::Piglin if source.attacker == Some(Who::Player) => {
m.extra.using_item = 0;
// stopHoldingOffHandItem(.., false): a gold ingot is not bartered
// and is gone; anything else ends its admiring next tick, as if
// the time ran out, and the game side puts it away.
if m.extra.off_hand.as_deref() == Some("minecraft:gold_ingot") {
m.extra.off_hand = None;
m.extra.using_item = 0;
} else {
m.extra.using_item =
i32::from(m.extra.off_hand.is_some() && m.extra.using_item > 0);
}
m.extra.egg_time = 400;
m.extra.anger = 600;
}