Skip to content

Commit

Permalink
PaperMC - Buffer joins
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyGalbreath committed Aug 5, 2020
1 parent 3861e41 commit ae51c16
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 14 deletions.
2 changes: 1 addition & 1 deletion current-paper
@@ -1 +1 @@
1.16.1--d3a6e66f8d7bf9ae7937b7b6dad700d97cde34b8
1.16.1--6874b340330971b9934941a70410d110383d7e76
40 changes: 27 additions & 13 deletions patches/server/0001-Tuinity-Server-Changes.patch
Expand Up @@ -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<BaseBlockPosition> {
Expand All @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
49 changes: 49 additions & 0 deletions patches/server/0120-PaperMC-Buffer-joins.patch
@@ -0,0 +1,49 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
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<Packet<?>> {
}
// 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

0 comments on commit ae51c16

Please sign in to comment.