Paper/Spigot-Server-Patches/0589-Fixed-TileEntityBell-memory-leak.patch

57 lines
2.6 KiB
Diff
Raw Normal View History

2020-10-10 12:23:52 +02:00
From 0000000000000000000000000000000000000000 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] Fixed TileEntityBell memory leak
TileEntityBell 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.
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
index e97d229da3cf7631555f418a73bc74255494cc01..84f9f52c5b632621b509448ac1c760f64de6b062 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityBell.java
@@ -27,8 +27,8 @@ public class TileEntityBell extends TileEntity implements ITickable {
2020-10-10 12:23:52 +02:00
public int a;
public boolean b;
public EnumDirection c;
- private List<EntityLiving> h;
- private boolean i;
+ private List<EntityLiving> h; private List<EntityLiving> getEntitiesAtRing() { return this.h; } // Paper - OBFHELPER
+ private boolean i; private boolean getShouldReveal() { return this.i; } // Paper - OBFHELPER
private int j;
public TileEntityBell() {
@@ -57,6 +57,11 @@ public class TileEntityBell extends TileEntity implements ITickable {
2020-10-10 12:23:52 +02:00
if (this.a >= 50) {
this.b = false;
+ // Paper start
+ if (!this.getShouldReveal()) {
+ this.getEntitiesAtRing().clear();
+ }
+ // Paper end
this.a = 0;
}
@@ -71,6 +76,7 @@ public class TileEntityBell extends TileEntity implements ITickable {
2020-10-10 12:23:52 +02:00
} else {
this.a(this.world);
this.b(this.world);
+ this.getEntitiesAtRing().clear(); // Paper
this.i = false;
}
}
@@ -111,11 +117,12 @@ public class TileEntityBell extends TileEntity implements ITickable {
2020-10-10 12:23:52 +02:00
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving.isAlive() && !entityliving.dead && blockposition.a((IPosition) entityliving.getPositionVector(), 32.0D)) {
- entityliving.getBehaviorController().setMemory(MemoryModuleType.HEARD_BELL_TIME, (Object) this.world.getTime());
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.HEARD_BELL_TIME, this.world.getTime()); // Paper - decompile fix
}
}
}
+ this.getEntitiesAtRing().removeIf(e -> !e.isAlive()); // Paper
}
private boolean h() {