From 053db6121449ab9e1745e452408306192536af5c Mon Sep 17 00:00:00 2001 From: giacomo <32515303+giacomozama@users.noreply.github.com> Date: Sat, 10 Oct 2020 12:15:33 +0200 Subject: [PATCH] Fix bell block entity memory leak BellBlockEntity has a list of entities (entitiesAtRing) that was not being cleared at the right time, causing leaks whenever a bell would be rung near a crowd of entities. --- .../block/entity/BellBlockEntity.java.patch | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch index fc0846a69..9a0f63263 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BellBlockEntity.java.patch @@ -1,6 +1,26 @@ --- a/net/minecraft/world/level/block/entity/BellBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BellBlockEntity.java -@@ -120,7 +120,7 @@ +@@ -63,6 +63,11 @@ + + if (blockEntity.ticks >= 50) { + blockEntity.shaking = false; ++ // Paper start - Fix bell block entity memory leak ++ if (!blockEntity.resonating) { ++ blockEntity.nearbyEntities.clear(); ++ } ++ // Paper end - Fix bell block entity memory leak + blockEntity.ticks = 0; + } + +@@ -76,6 +81,7 @@ + ++blockEntity.resonationTicks; + } else { + bellEffect.run(world, pos, blockEntity.nearbyEntities); ++ blockEntity.nearbyEntities.clear(); // Paper - Fix bell block entity memory leak + blockEntity.resonating = false; + } + } +@@ -120,11 +126,12 @@ LivingEntity entityliving = (LivingEntity) iterator.next(); if (entityliving.isAlive() && !entityliving.isRemoved() && blockposition.closerToCenterThan(entityliving.position(), 32.0D)) { @@ -9,7 +29,12 @@ } } } -@@ -144,9 +144,13 @@ + ++ this.nearbyEntities.removeIf(e -> !e.isAlive()); // Paper - Fix bell block entity memory leak + } + + private static boolean areRaidersNearby(BlockPos pos, List hearingEntities) { +@@ -144,9 +151,13 @@ } private static void makeRaidersGlow(Level world, BlockPos pos, List hearingEntities) {