⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@HaHaWTH
Copy link
Contributor

@HaHaWTH HaHaWTH commented Jan 11, 2026

This pull request closes #13482. (MC-305388)

Analysis

Mojang refactored how mob anger is stored to an absolute timestamp in 1.21.11. In previous versions, this was implemented with tick countdown. But the logic in updatePersistentAnger was flawed: it calls startPersistentAngerTimer() every tick as long as a target exists, completely ignoring the updateAnger parameter.

Bees specifically pass false to updatePersistentAnger inside their customServerAiStep.

    @Override
    protected void customServerAiStep(ServerLevel level) {
        /* other ai logic...*/

        this.updatePersistentAnger(level, false);
    }

The timer resets every tick even if updateAnger is false. This creates an infinite loop where isAngry() always returns true, preventing the bee from timing out its aggression.

Fix

We now call startPersistentAngerTimer() only if:

  • The target has changed (isNewTarget)
  • The updateAnger parameter is true (other mobs like polarbear, enderman).

This change restores the logic parity with 1.21.10.

@HaHaWTH HaHaWTH requested a review from a team as a code owner January 11, 2026 04:56
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Jan 11, 2026
@electronicboy
Copy link
Member

I don't think that the updateAnger check should be in there, should just not just be moved back into the block below where it sets the anger target?

@HaHaWTH
Copy link
Contributor Author

HaHaWTH commented Jan 12, 2026

I don't think that the updateAnger check should be in there, should just not just be moved back into the block below where it sets the anger target?

We need to handle two cases to start the timer:

updateAnger is true (forced update, this will reset the timer every tick) or the target has changed.
If we move the check inside the setPersistentAngerTarget block, timer won't get reset for non-timeout animals like polarbears(which passes true to updateAnger param), causing them to stop being angry after 30 seconds.

Copy link
Contributor

@lynxplay lynxplay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks correct, can you tighten the diff comments a bit?

Maybe

diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
index 0442ffc8a9..9e6dfed0fc 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
@@ -13,6 +13,18 @@
          }
      }
  
+@@ -63,9 +_,10 @@
+             if (target != null) {
+                 if (persistentAngerTarget == null || !persistentAngerTarget.matches(target)) {
+                     this.setPersistentAngerTarget(EntityReference.of(target));
++                    this.startPersistentAngerTimer(); // Paper - Fix MC-305388 - a new target was selected, start anger timer
+                 }
+ 
+-                this.startPersistentAngerTimer();
++                else if (updateAnger) this.startPersistentAngerTimer(); // Paper - Fix MC-305388 - existing target should still be angered towards due to bool param
+             }
+ 
+             if (persistentAngerTarget != null && !this.isAngry() && (target == null || !isValidPlayerTarget(target) || !updateAnger)) {
 @@ -120,7 +_,7 @@
      default void stopBeingAngry() {
          this.setLastHurtByMob(null);

@HaHaWTH
Copy link
Contributor Author

HaHaWTH commented Jan 16, 2026

Generally looks correct, can you tighten the diff comments a bit?

Maybe

diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
index 0442ffc8a9..9e6dfed0fc 100644
--- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
+++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch
@@ -13,6 +13,18 @@
          }
      }
  
+@@ -63,9 +_,10 @@
+             if (target != null) {
+                 if (persistentAngerTarget == null || !persistentAngerTarget.matches(target)) {
+                     this.setPersistentAngerTarget(EntityReference.of(target));
++                    this.startPersistentAngerTimer(); // Paper - Fix MC-305388 - a new target was selected, start anger timer
+                 }
+ 
+-                this.startPersistentAngerTimer();
++                else if (updateAnger) this.startPersistentAngerTimer(); // Paper - Fix MC-305388 - existing target should still be angered towards due to bool param
+             }
+ 
+             if (persistentAngerTarget != null && !this.isAngry() && (target == null || !isValidPlayerTarget(target) || !updateAnger)) {
 @@ -120,7 +_,7 @@
      default void stopBeingAngry() {
          this.setLastHurtByMob(null);

Done.

Mojang marked this ticket as Works As Intended, leaves a config option for this fix
@HaHaWTH
Copy link
Contributor Author

HaHaWTH commented Jan 16, 2026

Mojang marked this ticket as Works As Intended, I prefer to leave a config option for this fix.

@lynxplay
Copy link
Contributor

With the mojira ticket marked as WAI I am less excited about this PR, even as a config option.
I don't think paper generally re-enables a gameplay mechanic purely for gameplay reasons.
Thinks like legacy enderpeal behaviour exist as pearl chunk loading can be taxing on the server.
I am unsure how good the API surface here is to re-enable this via plugins. I presume it would be doable via PDC and a quick timer checking on bees.

Tho the WAI there seems interesting. I'll throw it at some other people for follow up to make sure this is a works as intended.

@Owen1212055
Copy link
Member

Yeah with Mojang marking this as working as intended, I am also in the agreement that we should probably close this-- as mojira is in general the source of truth with these behavior changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

bees aggression is not timed out and it is imposible to get away from them

4 participants