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.
This commit is contained in:
giacomo 2020-10-10 12:15:33 +02:00
parent 416280fc29
commit 053db61214

View File

@ -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<LivingEntity> hearingEntities) {
@@ -144,9 +151,13 @@
}
private static void makeRaidersGlow(Level world, BlockPos pos, List<LivingEntity> hearingEntities) {