--- a/net/minecraft/server/TickListServer.java +++ b/net/minecraft/server/TickListServer.java @@ -12,14 +12,15 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Stream; +import org.bukkit.craftbukkit.util.HashTreeSet; // CraftBukkit public class TickListServer implements TickList { protected final Predicate a; protected final Function b; protected final Function c; - protected final Set> nextTickListHash = Sets.newHashSet(); - protected final TreeSet> nextTickList = new TreeSet(); + // protected final Set> nextTickListHash = Sets.newHashSet(); + protected final HashTreeSet nextTickList = new HashTreeSet<>(); // CraftBukkit - HashTreeSet private final WorldServer f; private final List> g = Lists.newArrayList(); private final Consumer> h; @@ -35,16 +36,22 @@ public void a() { int i = this.nextTickList.size(); - if (i != this.nextTickListHash.size()) { + if (false) { // CraftBukkit throw new IllegalStateException("TickNextTick list out of synch"); } else { if (i > 65536) { - i = 65536; + // CraftBukkit start - If the server has too much to process over time, try to alleviate that + if (i > 20 * 65536) { + i = i / 20; + } else { + i = 65536; + } + // CraftBukkit end } this.f.getMethodProfiler().enter("cleaning"); - NextTickListEntry nextticklistentry; + NextTickListEntry nextticklistentry; // CraftBukkit - decompile error for (int j = 0; j < i; ++j) { nextticklistentry = (NextTickListEntry) this.nextTickList.first(); @@ -53,7 +60,7 @@ } this.nextTickList.remove(nextticklistentry); - this.nextTickListHash.remove(nextticklistentry); + // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList this.g.add(nextticklistentry); } @@ -122,7 +129,7 @@ if (blockposition.getX() >= structureboundingbox.a && blockposition.getX() < structureboundingbox.d && blockposition.getZ() >= structureboundingbox.c && blockposition.getZ() < structureboundingbox.f) { if (flag) { if (i == 0) { - this.nextTickListHash.remove(nextticklistentry); + // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - removed } iterator.remove(); @@ -196,7 +203,7 @@ @Override public boolean a(BlockPosition blockposition, T t0) { - return this.nextTickListHash.contains(new NextTickListEntry<>(blockposition, t0)); + return this.nextTickList.contains(new NextTickListEntry<>(blockposition, t0)); // CraftBukkit } @Override @@ -220,8 +227,8 @@ } private void a(NextTickListEntry nextticklistentry) { - if (!this.nextTickListHash.contains(nextticklistentry)) { - this.nextTickListHash.add(nextticklistentry); + // CraftBukkit - use nextTickList + if (!this.nextTickList.contains(nextticklistentry)) { this.nextTickList.add(nextticklistentry); }