You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the default implementation, totalEntityAge only increments when an entity is actively ticked.
8
+
Consequently, if an entity resides in a weak-loaded chunk, its aging process effectively pauses, allowing it to exist far beyond the configured despawn time.
9
+
10
+
This patch addresses this discrepancy by synchronizing entity age with absolute server time:
11
+
Introduces lastTickTime to record the MinecraftServer.currentTick when an entity was last ticked.
12
+
Once the entity is ticked again or unloaded, the system calculates the elapsed time (currentTick - lastTickTime), and adds it to the totalEntityAge.
13
+
Also, it moves the despawn logic of projectiles to their own tick method (see ThrowableProjectile#tick), making it faster to despawn massive stuck projectiles.
14
+
15
+
Benchmarks (60,000 snowballs):
16
+
Before: Around 120 seconds, server thread is struggling to process projectile physics.
17
+
After: 1.5 seconds
18
+
6
19
Brings the ability to despawn weak-loaded entities once they are ticked,
7
20
a solution for https://github.com/PaperMC/Paper/issues/12986
8
21
@@ -27,14 +40,14 @@ index f58b91b277ba85fa7c0e7ad10157ecbf10023065..b7f9f22abf60c75bc09126d9168fda9a
27
40
for (Entity entity : passengerEntity.getPassengers()) {
28
41
this.tickPassenger(passengerEntity, entity, isActive); // Paper - EAR 2
index f6d619709d4e5b0e6d1b943226579d7388835cdb..fefd0df22b32bb6f933bbf9530584c2c9616bfb6 100644
43
+
index f6d619709d4e5b0e6d1b943226579d7388835cdb..137ec39c1458e6adc854df24807f0e26770d95da 100644
31
44
--- a/net/minecraft/world/entity/Entity.java
32
45
+++ b/net/minecraft/world/entity/Entity.java
33
46
@@ -373,6 +373,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
34
47
public boolean fixedPose = false; // Paper - Expand Pose API
35
48
private final int despawnTime; // Paper - entity despawn time limit
36
49
public int totalEntityAge; // Paper - age-like counter for all entities
37
-
+ private int lastTickTicks; // Leaf - Rewrite entity despawn time
50
+
+ private int lastTickTime; // Leaf - Rewrite entity despawn time
38
51
public boolean activatedPriorityReset = false; // Pufferfish - DAB
39
52
public int activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio; // Pufferfish - DAB (golf score)
40
53
public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges
@@ -54,7 +67,7 @@ index f6d619709d4e5b0e6d1b943226579d7388835cdb..fefd0df22b32bb6f933bbf9530584c2c
54
67
}
55
68
56
69
public boolean isColliding(BlockPos pos, BlockState state) {
57
-
@@ -887,15 +890,50 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
70
+
@@ -887,15 +890,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
58
71
}
59
72
60
73
public void tick() {
@@ -79,33 +92,29 @@ index f6d619709d4e5b0e6d1b943226579d7388835cdb..fefd0df22b32bb6f933bbf9530584c2c
79
92
+ if (this.despawnTime >= 0) {
80
93
+ int missedTicks = this.calculateMissedTicks();
81
94
+ if (missedTicks > 1) {
82
-
+ if ((this.totalEntityAge += missedTicks) >= this.despawnTime) {
0 commit comments