Placing blocks on offhand reaches paacket limit more easily
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
The maximum speed of placing blocks with the main hand and the off hand should be the same
Observed/Actual behavior
It is easier to make blocks become "ghost blocks" when quickly placing blocks through an off hand. The main reason for blocks to become "ghost blocks" is that packets are sent up to the limit set by paper.
In ServerGamePacketListenerImpl code, can be noticed that:
// Spigot start - limit place/interactions
private int limitedPackets;
private long lastLimitedPacket = -1;
private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold
private boolean checkLimit(long timestamp) {
if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Configurable threshold; raise packet limit to 8
return false;
}
if (this.lastLimitedPacket == -1 || timestamp - this.lastLimitedPacket >= getSpamThreshold()) { // Paper - Configurable threshold
this.lastLimitedPacket = timestamp;
this.limitedPackets = 0;
return true;
}
return true;
}
// Spigot end
After testing, it was found that when the blocks are placed with off hand, the client sends packets to the server twice at the same time. The two sending packets are the main hand interaction and the off hand interaction. This brings the time line between packets directly to the set spam threshold.
Therefore, the repair method is very simple. It might be possible to check whether the two packets are sent separately for the main hand and off hand.
Steps/models to reproduce
Fast placing blocks with main hand and off hand, observe the difference. You can test this with an auto clicker and set the click per second to 10.
Plugin and Datapack List
pl
[04:52:10 INFO]: Server Plugins (5):
[04:52:10 INFO]: Bukkit Plugins:
[04:52:10 INFO]: - LuckPerms, packetevents, PlaceholderAPI, ViaBackwards, ViaVersion
datapack list
[04:52:14 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)]
[04:52:14 INFO]: There are no more data packs available
Paper version
This server is running Paper version 1.21.4-128-main@7e21cb8 (2025-01-26T22:08:28Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.1-DEV-b48403b (MC: 1.21.1)
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ServerGamePacketListenerImpl, focusing on checkLimit and the incoming packet threshold handling described in the issue. Reproduce fast main-hand and off-hand placement with an auto clicker at 10 clicks per second, then verify that both hand paths can place blocks at the same maximum speed without creating ghost blocks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100