Paper/nms-patches/TickListServer.patch

85 lines
3.5 KiB
Diff
Raw Normal View History

2018-07-15 02:00:00 +02:00
--- a/net/minecraft/server/TickListServer.java
+++ b/net/minecraft/server/TickListServer.java
2019-04-23 04:00:00 +02:00
@@ -12,14 +12,15 @@
2018-07-15 02:00:00 +02:00
import java.util.function.Function;
import java.util.function.Predicate;
2019-04-23 04:00:00 +02:00
import java.util.stream.Stream;
2018-07-15 02:00:00 +02:00
+import org.bukkit.craftbukkit.util.HashTreeSet; // CraftBukkit
public class TickListServer<T> implements TickList<T> {
protected final Predicate<T> a;
protected final Function<T, MinecraftKey> b;
protected final Function<MinecraftKey, T> c;
- protected final Set<NextTickListEntry<T>> nextTickListHash = Sets.newHashSet();
- protected final TreeSet<NextTickListEntry<T>> nextTickList = new TreeSet();
+ // protected final Set<NextTickListEntry<T>> nextTickListHash = Sets.newHashSet();
+ protected final HashTreeSet<NextTickListEntry> nextTickList = new HashTreeSet<>(); // CraftBukkit - HashTreeSet
private final WorldServer f;
private final List<NextTickListEntry<T>> g = Lists.newArrayList();
private final Consumer<NextTickListEntry<T>> h;
2019-04-23 04:00:00 +02:00
@@ -35,16 +36,22 @@
2018-07-15 02:00:00 +02:00
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
}
2019-04-23 04:00:00 +02:00
this.f.getMethodProfiler().enter("cleaning");
2018-07-15 02:00:00 +02:00
- NextTickListEntry nextticklistentry;
+ NextTickListEntry<T> nextticklistentry; // CraftBukkit - decompile error
for (int j = 0; j < i; ++j) {
nextticklistentry = (NextTickListEntry) this.nextTickList.first();
2019-04-23 04:00:00 +02:00
@@ -53,7 +60,7 @@
2018-07-15 02:00:00 +02:00
}
this.nextTickList.remove(nextticklistentry);
- this.nextTickListHash.remove(nextticklistentry);
+ // this.nextTickListHash.remove(nextticklistentry); // CraftBukkit - use nextTickList
this.g.add(nextticklistentry);
}
2019-04-23 04:00:00 +02:00
@@ -122,7 +129,7 @@
2018-07-15 02:00:00 +02:00
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();
2019-04-23 04:00:00 +02:00
@@ -196,7 +203,7 @@
2018-07-15 02:00:00 +02:00
2019-04-23 04:00:00 +02:00
@Override
2018-07-15 02:00:00 +02:00
public boolean a(BlockPosition blockposition, T t0) {
2018-12-25 22:00:00 +01:00
- return this.nextTickListHash.contains(new NextTickListEntry<>(blockposition, t0));
+ return this.nextTickList.contains(new NextTickListEntry<>(blockposition, t0)); // CraftBukkit
2018-07-15 02:00:00 +02:00
}
2019-04-23 04:00:00 +02:00
@Override
@@ -220,8 +227,8 @@
}
2018-07-15 02:00:00 +02:00
2019-04-23 04:00:00 +02:00
private void a(NextTickListEntry<T> nextticklistentry) {
2018-07-15 02:00:00 +02:00
- if (!this.nextTickListHash.contains(nextticklistentry)) {
- this.nextTickListHash.add(nextticklistentry);
+ // CraftBukkit - use nextTickList
+ if (!this.nextTickList.contains(nextticklistentry)) {
this.nextTickList.add(nextticklistentry);
}