Skip to content

Commit 36af0e3

Browse files
authored
Fix Memory Leak Fix (#2823) (#2839)
1 parent bed7b73 commit 36af0e3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/gregtech/api/metatileentity/SyncedTileEntityBase.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
public abstract class SyncedTileEntityBase extends BlockStateTileEntity implements ISyncedTileEntity {
2828

29+
public static final int SIZE_THRESHOLD = 10;
2930
private final PacketDataList updates = new PacketDataList();
3031

3132
public @Nullable TileEntity getNeighbor(EnumFacing facing) {
@@ -65,7 +66,7 @@ private void notifyWorld() {
6566

6667
private boolean canNotifyWorld() {
6768
// short circuit with packet size to avoid too many hash lookups and instanceof casts
68-
if (updates.size() > 10 && getWorld() instanceof WorldServer server) {
69+
if (updates.size() > SIZE_THRESHOLD && getWorld() instanceof WorldServer server) {
6970
int x = getPos().getX() >> 4;
7071
int z = getPos().getZ() >> 4;
7172
if (server.getPlayerChunkMap().contains(x, z)) {
@@ -76,7 +77,8 @@ private boolean canNotifyWorld() {
7677
return false;
7778
}
7879
}
79-
return false;
80+
// assume we can send data regardless
81+
return true;
8082
}
8183

8284
@Override

0 commit comments

Comments
 (0)