Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placing blocks on offhand reaches paacket limit more easily #12027

Open
LoliColleen opened this issue Jan 27, 2025 · 0 comments
Open

Placing blocks on offhand reaches paacket limit more easily #12027

LoliColleen opened this issue Jan 27, 2025 · 0 comments
Labels

Comments

@LoliColleen
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant