Let a piglin let go of the gold it admires when a player hits it

This commit is contained in:
Kacpherek
2026-10-26 19:12:31 +01:00
parent cfc55bb6c6
commit 6823e34451
+10 -1
View File
@@ -1328,7 +1328,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;
}