package me.nallar.patched;

import net.minecraft.network.TcpConnection;
import net.minecraft.server.ThreadMinecraftServer;
import net.minecraft.util.AxisAlignedBB;

public abstract class PatchTcpReaderThread extends ThreadMinecraftServer {
	final TcpConnection tcpConnection;

	public PatchTcpReaderThread(TcpConnection tcpConnection, String name) {
		super(null, name);
		this.tcpConnection = tcpConnection;
	}

	@Override
	public void run() {
		TcpConnection.field_74471_a.getAndIncrement();

		try {
			while (tcpConnection.isRunning()) {
				while (true) {
					if (!tcpConnection.readNetworkPacket()) {
						AxisAlignedBB.getAABBPool().cleanPool();
						try {
							sleep(2L);
						} catch (InterruptedException ignored) {
						}
					}
				}
			}
		} finally {
			TcpConnection.field_74471_a.getAndDecrement();
		}
	}
}

@@ -240,16 +240,29 @@
 rver %7B%0D%0A
+%09int count;%0D%0A
 %09final T
@@ -640,56 +640,8 @@
  %7B%0D%0A
-%09%09%09%09%09%09AxisAlignedBB.getAABBPool().cleanPool();%0D%0A
 %09%09%09%09
@@ -645,24 +645,24 @@
 %09%09%09%09%09try %7B%0D%0A
+
 %09%09%09%09%09%09%09sleep
@@ -712,24 +712,24 @@
 ignored) %7B%0D%0A
-
 %09%09%09%09%09%09%7D%0D%0A%09%09%09
@@ -729,24 +729,111 @@
 %09%7D%0D%0A%09%09%09%09%09%7D%0D%0A
+%09%09%09%09%09if (count++ %25 30 == 0) %7B%0D%0A%09%09%09%09%09%09AxisAlignedBB.getAABBPool().cleanPool();%0D%0A%09%09%09%09%09%7D%0D%0A
 %09%09%09%09%7D%0D%0A%09%09%09%7D%0D

Change AABB pool cleanup timing