From ae51c1626e447916a2bad8d05b2f2354e760c8dc Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Tue, 4 Aug 2020 20:39:00 -0500 Subject: [PATCH] PaperMC - Buffer joins --- current-paper | 2 +- .../server/0001-Tuinity-Server-Changes.patch | 40 ++++++++++----- .../server/0120-PaperMC-Buffer-joins.patch | 49 +++++++++++++++++++ 3 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 patches/server/0120-PaperMC-Buffer-joins.patch diff --git a/current-paper b/current-paper index fd450147f..dd9323dac 100644 --- a/current-paper +++ b/current-paper @@ -1 +1 @@ -1.16.1--d3a6e66f8d7bf9ae7937b7b6dad700d97cde34b8 +1.16.1--6874b340330971b9934941a70410d110383d7e76 diff --git a/patches/server/0001-Tuinity-Server-Changes.patch b/patches/server/0001-Tuinity-Server-Changes.patch index 9f3d0cf4b..bb04e984c 100644 --- a/patches/server/0001-Tuinity-Server-Changes.patch +++ b/patches/server/0001-Tuinity-Server-Changes.patch @@ -1623,7 +1623,7 @@ index ed9b2f9adf..d54bf71409 100644 return d0 >= this.minX && d0 < this.maxX && d1 >= this.minY && d1 < this.maxY && d2 >= this.minZ && d2 < this.maxZ; } diff --git a/src/main/java/net/minecraft/server/BaseBlockPosition.java b/src/main/java/net/minecraft/server/BaseBlockPosition.java -index 3b0c8971c6..4816493c6a 100644 +index 3b0c8971c6..e69b7dbc7a 100644 --- a/src/main/java/net/minecraft/server/BaseBlockPosition.java +++ b/src/main/java/net/minecraft/server/BaseBlockPosition.java @@ -16,9 +16,9 @@ public class BaseBlockPosition implements Comparable { @@ -1633,9 +1633,9 @@ index 3b0c8971c6..4816493c6a 100644 - private int a;public final void setX(final int x) { this.a = x; } // Paper - OBFHELPER - private int b;public final void setY(final int y) { this.b = y; } // Paper - OBFHELPER - private int e;public final void setZ(final int z) { this.e = z; } // Paper - OBFHELPER -+ protected int a;public final void setX(final int x) { this.a = x; } // Paper - OBFHELPER // Tuinity - private->protected -+ protected int b;public final void setY(final int y) { this.b = y; } // Paper - OBFHELPER // Tuinity - private->protected -+ protected int e;public final void setZ(final int z) { this.e = z; } // Paper - OBFHELPER // Tuinity - private->protected ++ protected int a; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the x coordinate - Also revert the decision to expose set on an immutable type ++ protected int b; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the y coordinate - Also revert the decision to expose set on an immutable type ++ protected int e; // Paper - OBFHELPER // Tuinity - private->protected - diff on change, this is the z coordinate - Also revert the decision to expose set on an immutable type // Paper start public boolean isValidLocation() { @@ -1902,7 +1902,7 @@ index 4bf66420f5..bf76615d72 100644 @Override diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java -index a2ee39b7ef..7bdefff433 100644 +index a2ee39b7ef..c77f71b6de 100644 --- a/src/main/java/net/minecraft/server/BlockPosition.java +++ b/src/main/java/net/minecraft/server/BlockPosition.java @@ -387,10 +387,10 @@ public class BlockPosition extends BaseBlockPosition { @@ -1957,27 +1957,41 @@ index a2ee39b7ef..7bdefff433 100644 } public BlockPosition.MutableBlockPosition c(EnumDirection enumdirection, int i) { -@@ -445,21 +454,19 @@ public class BlockPosition extends BaseBlockPosition { +@@ -445,21 +454,30 @@ public class BlockPosition extends BaseBlockPosition { } } - /* // Paper start - comment out useless overrides @Override - @Override -+ // Tuinity start - public void o(int i) { +- public void o(int i) { - super.o(i); -+ setX(i); ++ // Tuinity start ++ // only expose set on the mutable blockpos ++ public final void setX(int value) { ++ ((BaseBlockPosition)this).a = value; ++ } ++ public final void setY(int value) { ++ ((BaseBlockPosition)this).b = value; ++ } ++ public final void setZ(int value) { ++ ((BaseBlockPosition)this).e = value; } - @Override - public void p(int i) { +- public void p(int i) { - super.p(i); -+ setY(i); ++ public final void o(int i) { ++ ((BaseBlockPosition)this).a = i; // need cast thanks to name conflict ++ } ++ ++ public final void p(int i) { ++ ((BaseBlockPosition)this).b = i; } - public void q(int i) { +- public void q(int i) { - super.q(i); -+ setZ(i); ++ public final void q(int i) { ++ ((BaseBlockPosition)this).e = i; } - */ // Paper end + // Tuinity end diff --git a/patches/server/0120-PaperMC-Buffer-joins.patch b/patches/server/0120-PaperMC-Buffer-joins.patch new file mode 100644 index 000000000..e4e5a9fb1 --- /dev/null +++ b/patches/server/0120-PaperMC-Buffer-joins.patch @@ -0,0 +1,49 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Sun, 2 Aug 2020 18:27:13 +0100 +Subject: [PATCH] PaperMC - Buffer joins + + +diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java +index 54e374cc94..8bcba67e6b 100644 +--- a/src/main/java/net/minecraft/server/NetworkManager.java ++++ b/src/main/java/net/minecraft/server/NetworkManager.java +@@ -412,10 +412,24 @@ public class NetworkManager extends SimpleChannelInboundHandler> { + } + // Paper end + ++ private static final int MAX_PER_TICK = 3; // max joins per tick ++ private static int lastHit = 0; // unused for now ++ public static int thisTick; // current tick counter ++ private static int loginsThisTick = 0; ++ private static int currTick; + public void a() { ++ if (currTick != thisTick) { ++ currTick = thisTick; ++ loginsThisTick = 0; ++ } ++ + this.o(); + if (this.packetListener instanceof LoginListener) { +- ((LoginListener) this.packetListener).tick(); ++ if ( ((LoginListener) this.packetListener).getLoginState() != LoginListener.EnumProtocolState.READY_TO_ACCEPT ++ || (thisTick > lastHit + 10 || loginsThisTick++ < MAX_PER_TICK) ++ ) { ++ ((LoginListener) this.packetListener).tick(); ++ } + } + + if (this.packetListener instanceof PlayerConnection) { +diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java +index 0438126662..bb69477c41 100644 +--- a/src/main/java/net/minecraft/server/ServerConnection.java ++++ b/src/main/java/net/minecraft/server/ServerConnection.java +@@ -121,7 +121,7 @@ public class ServerConnection { + + public void c() { + List list = this.connectedChannels; +- ++ NetworkManager.thisTick++; //Paper + synchronized (this.connectedChannels) { + // Spigot Start + this.addPending(); // Paper