[PR #3942] [MERGED] Piglins and hoglins retreat, retaliate, grunt and ride like vanilla #5306

Closed
opened 2026-11-03 05:11:40 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3942
Author: @kacpherek
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: fix/split-piglin-hoglin


📝 Commits (10+)

  • ba7f106 Sense the adults a piglin or hoglin sees and track its activity
  • c40d011 Let piglins and hoglins retreat from their avoid target
  • 7a98019 Set an avoid target and broadcast a retreat to the adults nearby
  • d68d59f Make an outnumbered hoglin retreat after it hits a piglin
  • be2963b Make a hurt hoglin retreat or retaliate as vanilla does
  • e314b5c Make a hurt piglin flee, retreat or retaliate as vanilla does
  • 89ecd6c Grunt when a piglin or hoglin changes activity
  • 845343e Play a piglin's and hoglin's activity sound as its ambient grunt
  • c124b94 Keep adult hoglins 8 blocks from the adult piglins they see
  • 810a015 Make idle piglins watch a player who holds gold

📊 Changes

9 files changed (+1341 additions, -105 deletions)

View changed files

📝 crates/horizon-client/examples/probe/entity_anim_fixture.rs (+1 -0)
📝 crates/horizon-client/src/game/creatures.rs (+8 -0)
📝 crates/horizon-client/src/game/passengers.rs (+1 -10)
📝 crates/horizon-client/src/game/piglins.rs (+2 -3)
📝 crates/horizon-client/src/mobs.rs (+30 -0)
📝 crates/horizon-client/src/mobs/ai.rs (+7 -14)
📝 crates/horizon-client/src/mobs/piglin.rs (+1120 -75)
📝 crates/horizon-client/src/mobs/riders.rs (+153 -2)
📝 crates/horizon-client/src/mobs/world.rs (+19 -1)

📄 Description

What and why

  • Brain state: piglins and hoglins now count the adult piglins and hoglins they can see, keep an avoid target that expires, and note which activity they are in. Players saw mobs that had no idea who was around them. Ported as the HoglinSpecificSensor and PiglinSpecificSensor memories ticked from customServerAiStep.
  • Retreat: hoglins, baby hoglins and piglins now walk away from their avoid target (hoglin at 1.3 up to 15 blocks, piglin at 1.0 up to 12), copy a wither skeleton or zombified mob into the avoid target, and stop fleeing by the vanilla outnumbering tests. Before, baby hoglins panicked and piglins used a plain avoid goal. Idle behaviours and attack goals stay off during a retreat.
  • Avoid target and warning: a hoglin or piglin that decides to retreat picks its nearest target and warns the adults around it, which handle the warning on their next tick.
  • Hoglin hits a piglin: an outnumbered hoglin now retreats after hitting a piglin and warns the adult hoglins it sees, instead of fighting on.
  • Hurt hoglin: a hit baby hoglin flees and a hit adult retaliates only when vanilla allows it. Before, a baby never fled and an adult took on piglins and hoglins it should leave alone.
  • Hurt piglin: a hit piglin drops admiring and celebrating (except for a piglin attacker), a baby flees for 100 ticks and calls the adults, and an adult retreats from hoglins that outnumber piglins or retaliates only when vanilla allows it.
  • Activity grunts: piglins and hoglins now grunt when they start a fight, retreat, celebration or admiring, and their ambient grunt is the sound of the activity they are in (retreat, angry, admiring, celebrate, jealous). Before only the ambient roll played, and an angry grunt played whenever they had a target.
  • Hoglin spacing: idle adult hoglins walk away from the nearest visible adult piglin once it is closer than 8 blocks.
  • Gold watching: idle and celebrating piglins turn to look at a player within 14 blocks who holds gold or another loved item.
  • Hunt wait: the piglin's hunted-recently wait now counts down once per tick instead of twice, so the 30 to 120 second wait is the right length.
  • Riding: a mob's brain can now board another mob and get off it. A baby piglin that boards a hoglin goes on top of up to three piglins stacked on it; a hoglin seats its rider at 1.49375 (0.875 for a baby); a baby piglin hangs 0.1875 below its seat.
  • Riding pose: a piglin on a mount now sits (legs and arms bent) instead of standing stiff.
  • Ride activity: piglins get a ride target and a ride activity that is valid while the target exists, between celebrating and idle.
  • Baby piglin picks a mount: an idle baby piglin sometimes picks the nearest visible baby hoglin as its ride target for 10 to 30 seconds, every 10 to 40 seconds.
  • Mounting: a baby piglin walks to its ride target at 0.8 speed and boards it once closer than a block.
  • Dismounting: a riding piglin gets off when the vehicle is grown, dead, too far (8 blocks), the piglin was hurt in the last 40 ticks, or the vehicle is a piglin that rides nothing itself.
  • Baby ride ends: a baby piglin riding a baby comes off once its ride target ends, so a ride lasts as long as the 10 to 30 second memory.
  • Ride behaviours: a riding piglin only runs the ride activity's behaviours (no wandering or repellent avoidance), and looks at a player holding gold within 8 blocks, not 14.

Vanilla reference

  • Sensing and activity memories: HoglinSpecificSensor.java, PiglinSpecificSensor.java, Hoglin.customServerAiStep (Hoglin.java), Piglin.customServerAiStep (Piglin.java)
  • Retreat activity: HoglinAi.initRetreatActivity (HoglinAi.java), PiglinAi.initRetreatActivity (PiglinAi.java), wantsToStopFleeing
  • Avoid target and warning: HoglinAi.setAvoidTarget (HoglinAi.java), PiglinAi.setAvoidTargetAndDontHuntForAWhile, retreatFromNearestTarget, broadcastRetreat (PiglinAi.java)
  • Hoglin hits piglin: HoglinAi.onHitTarget, Hoglin.doHurtTarget (HoglinAi.java, Hoglin.java)
  • Hurt hoglin: HoglinAi.wasHurtBy, Hoglin.hurtServer (HoglinAi.java, Hoglin.java)
  • Hurt piglin: PiglinAi.wasHurtBy, Piglin.hurtServer (PiglinAi.java, Piglin.java)
  • Activity grunts: HoglinAi.updateActivity, PiglinAi.updateActivity, getSoundForActivity (HoglinAi.java, PiglinAi.java)
  • Ambient grunt: Piglin.getAmbientSound, Hoglin.getAmbientSound, PiglinAi.getSoundForCurrentActivity, HoglinAi.getSoundForCurrentActivity (Piglin.java, Hoglin.java, PiglinAi.java, HoglinAi.java)
  • Hoglin spacing: HoglinAi.initIdleActivity, SetWalkTargetAwayFrom (HoglinAi.java)
  • Gold watching: PiglinAi.initIdleActivity, PiglinAi.initCelebrateActivity, SetEntityLookTarget, isPlayerHoldingLovedItem (PiglinAi.java)
  • Hunt wait: PiglinAi.setAvoidTargetAndDontHuntForAWhile, StartHuntingHoglin, PiglinAi.TIME_BETWEEN_HUNTS (PiglinAi.java)
  • Boarding: Entity.startRiding (Entity.java), Piglin.startRiding (Piglin.java), LivingEntity.stopRiding (LivingEntity.java), Animal.getDismountLocationForPassenger (Animal.java), Piglin.BABY_DIMENSIONS (Piglin.java)
  • Riding pose: PiglinModel.setupAnim, HumanoidModel.setupAnim (PiglinModel.java, HumanoidModel.java)
  • Ride activity: PiglinAi.getActivities, PiglinAi.updateActivity (PiglinAi.java)
  • Baby picks a mount: PiglinAi.babySometimesRideBabyHoglin, SetEntityLookTargetSometimes.Ticker, PiglinSpecificSensor (PiglinAi.java, SetEntityLookTargetSometimes.java, PiglinSpecificSensor.java)
  • Mounting: Mount.create (Mount.java), MoveToTargetSink (MoveToTargetSink.java)
  • Dismounting: DismountOrSkipMounting (DismountOrSkipMounting.java), PiglinAi.wantsToStopRiding (PiglinAi.java)
  • Baby ride ends: PiglinAi.updateActivity, PiglinAi.isBabyRidingBaby (PiglinAi.java)
  • Ride behaviours: PiglinAi.initRideHoglinActivity (PiglinAi.java)

Self-check

cargo check and clippy -D warnings pass for horizon-client; not run in game.

Split out of #3926.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3942 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix/split-piglin-hoglin` --- ### 📝 Commits (10+) - [`ba7f106`](https://github.com/horizon-rust/horizon/commit/ba7f106d5309eaa98c7c41b7b42e47c99eea6d71) Sense the adults a piglin or hoglin sees and track its activity - [`c40d011`](https://github.com/horizon-rust/horizon/commit/c40d0112a60dfe182034e019e69b3caab89f53db) Let piglins and hoglins retreat from their avoid target - [`7a98019`](https://github.com/horizon-rust/horizon/commit/7a98019450d91fc75467536b42196d7cd7acf0fc) Set an avoid target and broadcast a retreat to the adults nearby - [`d68d59f`](https://github.com/horizon-rust/horizon/commit/d68d59f6b63c6dbf3ce6ecd9f05b045b7cd47702) Make an outnumbered hoglin retreat after it hits a piglin - [`be2963b`](https://github.com/horizon-rust/horizon/commit/be2963b1d64efb0fe28b3bbadf38d41a1ee4c70f) Make a hurt hoglin retreat or retaliate as vanilla does - [`e314b5c`](https://github.com/horizon-rust/horizon/commit/e314b5c6e17429e0403849cc7bfc2244c6332692) Make a hurt piglin flee, retreat or retaliate as vanilla does - [`89ecd6c`](https://github.com/horizon-rust/horizon/commit/89ecd6cd9d19b111eb20ad93936bc6ab9cc888c9) Grunt when a piglin or hoglin changes activity - [`845343e`](https://github.com/horizon-rust/horizon/commit/845343e019633962ed7fee5e3799df14d85c0992) Play a piglin's and hoglin's activity sound as its ambient grunt - [`c124b94`](https://github.com/horizon-rust/horizon/commit/c124b94c8b9299a42891c8ea5672c84a42a082cb) Keep adult hoglins 8 blocks from the adult piglins they see - [`810a015`](https://github.com/horizon-rust/horizon/commit/810a0152d3d45f94f7f518c427ea8e73018140e9) Make idle piglins watch a player who holds gold ### 📊 Changes **9 files changed** (+1341 additions, -105 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/entity_anim_fixture.rs` (+1 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+8 -0) 📝 `crates/horizon-client/src/game/passengers.rs` (+1 -10) 📝 `crates/horizon-client/src/game/piglins.rs` (+2 -3) 📝 `crates/horizon-client/src/mobs.rs` (+30 -0) 📝 `crates/horizon-client/src/mobs/ai.rs` (+7 -14) 📝 `crates/horizon-client/src/mobs/piglin.rs` (+1120 -75) 📝 `crates/horizon-client/src/mobs/riders.rs` (+153 -2) 📝 `crates/horizon-client/src/mobs/world.rs` (+19 -1) </details> ### 📄 Description ## What and why - Brain state: piglins and hoglins now count the adult piglins and hoglins they can see, keep an avoid target that expires, and note which activity they are in. Players saw mobs that had no idea who was around them. Ported as the HoglinSpecificSensor and PiglinSpecificSensor memories ticked from customServerAiStep. - Retreat: hoglins, baby hoglins and piglins now walk away from their avoid target (hoglin at 1.3 up to 15 blocks, piglin at 1.0 up to 12), copy a wither skeleton or zombified mob into the avoid target, and stop fleeing by the vanilla outnumbering tests. Before, baby hoglins panicked and piglins used a plain avoid goal. Idle behaviours and attack goals stay off during a retreat. - Avoid target and warning: a hoglin or piglin that decides to retreat picks its nearest target and warns the adults around it, which handle the warning on their next tick. - Hoglin hits a piglin: an outnumbered hoglin now retreats after hitting a piglin and warns the adult hoglins it sees, instead of fighting on. - Hurt hoglin: a hit baby hoglin flees and a hit adult retaliates only when vanilla allows it. Before, a baby never fled and an adult took on piglins and hoglins it should leave alone. - Hurt piglin: a hit piglin drops admiring and celebrating (except for a piglin attacker), a baby flees for 100 ticks and calls the adults, and an adult retreats from hoglins that outnumber piglins or retaliates only when vanilla allows it. - Activity grunts: piglins and hoglins now grunt when they start a fight, retreat, celebration or admiring, and their ambient grunt is the sound of the activity they are in (retreat, angry, admiring, celebrate, jealous). Before only the ambient roll played, and an angry grunt played whenever they had a target. - Hoglin spacing: idle adult hoglins walk away from the nearest visible adult piglin once it is closer than 8 blocks. - Gold watching: idle and celebrating piglins turn to look at a player within 14 blocks who holds gold or another loved item. - Hunt wait: the piglin's hunted-recently wait now counts down once per tick instead of twice, so the 30 to 120 second wait is the right length. - Riding: a mob's brain can now board another mob and get off it. A baby piglin that boards a hoglin goes on top of up to three piglins stacked on it; a hoglin seats its rider at 1.49375 (0.875 for a baby); a baby piglin hangs 0.1875 below its seat. - Riding pose: a piglin on a mount now sits (legs and arms bent) instead of standing stiff. - Ride activity: piglins get a ride target and a ride activity that is valid while the target exists, between celebrating and idle. - Baby piglin picks a mount: an idle baby piglin sometimes picks the nearest visible baby hoglin as its ride target for 10 to 30 seconds, every 10 to 40 seconds. - Mounting: a baby piglin walks to its ride target at 0.8 speed and boards it once closer than a block. - Dismounting: a riding piglin gets off when the vehicle is grown, dead, too far (8 blocks), the piglin was hurt in the last 40 ticks, or the vehicle is a piglin that rides nothing itself. - Baby ride ends: a baby piglin riding a baby comes off once its ride target ends, so a ride lasts as long as the 10 to 30 second memory. - Ride behaviours: a riding piglin only runs the ride activity's behaviours (no wandering or repellent avoidance), and looks at a player holding gold within 8 blocks, not 14. ## Vanilla reference - Sensing and activity memories: HoglinSpecificSensor.java, PiglinSpecificSensor.java, Hoglin.customServerAiStep (Hoglin.java), Piglin.customServerAiStep (Piglin.java) - Retreat activity: HoglinAi.initRetreatActivity (HoglinAi.java), PiglinAi.initRetreatActivity (PiglinAi.java), wantsToStopFleeing - Avoid target and warning: HoglinAi.setAvoidTarget (HoglinAi.java), PiglinAi.setAvoidTargetAndDontHuntForAWhile, retreatFromNearestTarget, broadcastRetreat (PiglinAi.java) - Hoglin hits piglin: HoglinAi.onHitTarget, Hoglin.doHurtTarget (HoglinAi.java, Hoglin.java) - Hurt hoglin: HoglinAi.wasHurtBy, Hoglin.hurtServer (HoglinAi.java, Hoglin.java) - Hurt piglin: PiglinAi.wasHurtBy, Piglin.hurtServer (PiglinAi.java, Piglin.java) - Activity grunts: HoglinAi.updateActivity, PiglinAi.updateActivity, getSoundForActivity (HoglinAi.java, PiglinAi.java) - Ambient grunt: Piglin.getAmbientSound, Hoglin.getAmbientSound, PiglinAi.getSoundForCurrentActivity, HoglinAi.getSoundForCurrentActivity (Piglin.java, Hoglin.java, PiglinAi.java, HoglinAi.java) - Hoglin spacing: HoglinAi.initIdleActivity, SetWalkTargetAwayFrom (HoglinAi.java) - Gold watching: PiglinAi.initIdleActivity, PiglinAi.initCelebrateActivity, SetEntityLookTarget, isPlayerHoldingLovedItem (PiglinAi.java) - Hunt wait: PiglinAi.setAvoidTargetAndDontHuntForAWhile, StartHuntingHoglin, PiglinAi.TIME_BETWEEN_HUNTS (PiglinAi.java) - Boarding: Entity.startRiding (Entity.java), Piglin.startRiding (Piglin.java), LivingEntity.stopRiding (LivingEntity.java), Animal.getDismountLocationForPassenger (Animal.java), Piglin.BABY_DIMENSIONS (Piglin.java) - Riding pose: PiglinModel.setupAnim, HumanoidModel.setupAnim (PiglinModel.java, HumanoidModel.java) - Ride activity: PiglinAi.getActivities, PiglinAi.updateActivity (PiglinAi.java) - Baby picks a mount: PiglinAi.babySometimesRideBabyHoglin, SetEntityLookTargetSometimes.Ticker, PiglinSpecificSensor (PiglinAi.java, SetEntityLookTargetSometimes.java, PiglinSpecificSensor.java) - Mounting: Mount.create (Mount.java), MoveToTargetSink (MoveToTargetSink.java) - Dismounting: DismountOrSkipMounting (DismountOrSkipMounting.java), PiglinAi.wantsToStopRiding (PiglinAi.java) - Baby ride ends: PiglinAi.updateActivity, PiglinAi.isBabyRidingBaby (PiglinAi.java) - Ride behaviours: PiglinAi.initRideHoglinActivity (PiglinAi.java) ## Self-check cargo check and clippy -D warnings pass for horizon-client; not run in game. Split out of #3926. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:11:40 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5306
No description provided.