Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
c5a10665b8
Spigot still maintains some partial implementation of "tick skipping", a practice in which the MinecraftServer.currentTick field is updated not by an increment of one per actual tick, but instead set to System.currentTimeMillis() / 50. This behaviour means that the tracked tick may "skip" a tick value in case a previous tick took more than the expected 50ms. To compensate for this in important paths, spigot/craftbukkit implements "wall-time". Instead of incrementing/decrementing ticks on block entities/entities by one for each call to their tick() method, they instead increment/decrement important values, like an ItemEntity's age or pickupDelay, by the difference of `currentTick - lastTick`, where `lastTick` is the value of `currentTick` during the last tick() call. These "fixes" however do not play nicely with minecraft's simulation distance as entities/block entities implementing the above behaviour would "catch up" their values when moving from a non-ticking chunk to a ticking one as their `lastTick` value remains stuck on the last tick in a ticking chunk and hence lead to a large "catch up" once ticked again. Paper completely removes the "tick skipping" behaviour (See patch "Further-improve-server-tick-loop"), making the above precautions completely unnecessary, which also rids paper of the previous described incompatibility with non-ticking chunks.
41 Zeilen
2.1 KiB
Diff
41 Zeilen
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
Date: Wed, 19 Aug 2020 05:05:54 +0100
|
|
Subject: [PATCH] Buffer joins to world
|
|
|
|
This patch buffers the number of logins which will attempt to join
|
|
the world per tick, this attempts to reduce the impact that join floods
|
|
has on the server
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
|
|
index 38947f40864f3661df2eb4baa0aef5740b82f9d9..134810ac91d828d67759cd1ed56f11b71e292917 100644
|
|
--- a/src/main/java/net/minecraft/network/Connection.java
|
|
+++ b/src/main/java/net/minecraft/network/Connection.java
|
|
@@ -445,12 +445,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
}
|
|
|
|
+ private static final int MAX_PER_TICK = io.papermc.paper.configuration.GlobalConfiguration.get().misc.maxJoinsPerTick; // Paper - Buffer joins to world
|
|
+ private static int joinAttemptsThisTick; // Paper - Buffer joins to world
|
|
+ private static int currTick; // Paper - Buffer joins to world
|
|
public void tick() {
|
|
this.flushQueue();
|
|
+ // Paper start - Buffer joins to world
|
|
+ if (Connection.currTick != net.minecraft.server.MinecraftServer.currentTick) {
|
|
+ Connection.currTick = net.minecraft.server.MinecraftServer.currentTick;
|
|
+ Connection.joinAttemptsThisTick = 0;
|
|
+ }
|
|
+ // Paper end - Buffer joins to world
|
|
PacketListener packetlistener = this.packetListener;
|
|
|
|
if (packetlistener instanceof TickablePacketListener tickablepacketlistener) {
|
|
+ // Paper start - Buffer joins to world
|
|
+ if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener)
|
|
+ || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING
|
|
+ || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) {
|
|
tickablepacketlistener.tick();
|
|
+ } // Paper end - Buffer joins to world
|
|
}
|
|
|
|
if (!this.isConnected() && !this.disconnectionHandled) {
|