mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
Modify the block placement limit to allow for the odd random packet or two
When the connection between a minecraft client and a server (e.g. me and the spigot test server) is bad sometimes two placement packets will arrive at the same time. When the extra one gets canceled any blocks placed against it get rejected by the server causing the whole chain to disappear. This fixes this by allowing more packets to occur whilst making the window wider (since the client seems to be capped at about one placement every 100ms on a normal connection)
This commit is contained in:
parent
5c48793ecf
commit
7768676ae2
1 changed files with 9 additions and 7 deletions
|
@ -1,33 +1,35 @@
|
|||
From f6eb9e31fca92d09625a8ed923e230669eace264 Mon Sep 17 00:00:00 2001
|
||||
From ae902e1db40476e4a91c80c47ba783816c03cc0d Mon Sep 17 00:00:00 2001
|
||||
From: Thinkofdeath <thinkofdeath@spigotmc.org>
|
||||
Date: Sun, 29 Jun 2014 21:10:34 +0100
|
||||
Subject: [PATCH] Limit block placement/interaction packets
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index b723b73..9a7b256 100644
|
||||
index 9491101..20c49e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -573,7 +573,18 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
@@ -573,7 +573,20 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Spigot start - limit place/interactions
|
||||
+ private long lastPlace = -1;
|
||||
+ private int packets = 0;
|
||||
+
|
||||
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
+ boolean throttled = false;
|
||||
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 5) {
|
||||
+ if (lastPlace != -1 && packetplayinblockplace.timestamp - lastPlace < 30 && packets++ >= 4) {
|
||||
+ throttled = true;
|
||||
+ } else
|
||||
+ } else if ( packetplayinblockplace.timestamp - lastPlace >= 30 || lastPlace == -1 )
|
||||
+ {
|
||||
+ lastPlace = packetplayinblockplace.timestamp;
|
||||
+ packets = 0;
|
||||
+ }
|
||||
+ // Spigot end
|
||||
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -616,10 +627,14 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
@@ -616,10 +629,14 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
|
||||
// CraftBukkit start
|
||||
int itemstackAmount = itemstack.count;
|
||||
|
@ -42,7 +44,7 @@ index b723b73..9a7b256 100644
|
|||
|
||||
// CraftBukkit - notch decrements the counter by 1 in the above method with food,
|
||||
// snowballs and so forth, but he does it in a place that doesn't cause the
|
||||
@@ -640,7 +655,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
@@ -640,7 +657,7 @@ public class PlayerConnection implements PacketPlayInListener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue