|
1 | 1 | --- a/net/minecraft/world/damagesource/CombatTracker.java |
2 | 2 | +++ b/net/minecraft/world/damagesource/CombatTracker.java |
3 | | -@@ -29,15 +_,24 @@ |
| 3 | +@@ -22,22 +_,40 @@ |
| 4 | + private static final Style INTENTIONAL_GAME_DESIGN_STYLE = Style.EMPTY |
| 5 | + .withClickEvent(new ClickEvent.OpenUrl(CommonLinks.INTENTIONAL_GAME_DESIGN_BUG)) |
| 6 | + .withHoverEvent(new HoverEvent.ShowText(Component.literal("MCPE-28723"))); |
| 7 | +- public final List<CombatEntry> entries = Lists.newArrayList(); |
| 8 | ++ public final List<CombatEntry> entries = new net.minecraft.util.ArrayListDeque<>(); // Paper - Fix mem leak (MC-301114); Use ArrayListDeque |
| 9 | + public final LivingEntity mob; |
| 10 | + private int lastDamageTime; |
| 11 | + private int combatStartTime; |
4 | 12 | private int combatEndTime; |
5 | 13 | public boolean inCombat; |
6 | 14 | public boolean takingDamage; |
|
22 | 30 | + public void recordDamageAndCheckCombatState(final CombatEntry entry) { |
23 | 31 | + final DamageSource source = entry.source(); |
24 | 32 | + // Paper end - Combat tracker API |
| 33 | ++ // Paper start - Fix mem leak (MC-301114) |
| 34 | ++ final io.papermc.paper.configuration.type.number.IntOr.Disabled maxTrackingCombatEntries; |
| 35 | ++ if (!this.entries.isEmpty() && (maxTrackingCombatEntries = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxTrackingCombatEntries).enabled()) { |
| 36 | ++ final int maxEntries = maxTrackingCombatEntries.intValue(); |
| 37 | ++ while (this.entries.size() > maxEntries) { |
| 38 | ++ this.entries.removeFirst(); |
| 39 | ++ } |
| 40 | ++ } |
| 41 | ++ // Paper end - Fix mem leak (MC-301114) |
25 | 42 | this.entries.add(entry); |
26 | 43 | this.lastDamageTime = this.mob.tickCount; |
27 | 44 | this.takingDamage = true; |
|
0 commit comments