├── .gitignore
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # gradle
2 |
3 | .gradle/
4 | build/
5 | out/
6 | classes/
7 |
8 | # eclipse
9 |
10 | *.launch
11 |
12 | # idea
13 |
14 | .idea/
15 | *.iml
16 | *.ipr
17 | *.iws
18 |
19 | # vscode
20 |
21 | .settings/
22 | .vscode/
23 | bin/
24 | .classpath
25 | .project
26 |
27 | # macos
28 |
29 | *.DS_Store
30 |
31 | # fabric
32 |
33 | run/
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright © 2022 adryd
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 |
5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 |
7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # chat-lag-fix
2 |
3 | Fixes Minecraft client lag from receiving chat messages
4 |
5 | ### YOU DO NOT NEED THIS MOD ANYMORE ON 1.18
6 |
7 | **Mojang has fixed the bug in their API that was causing it to return an error instead of an empty list. Minecraft will fetch the block-list once when joining the world. This mod may still improve world loading times by the time it takes to make that HTTP request; especially if you have a slow internet connection.**
8 |
9 | This comment by a Mojang employee confirms that the bug was fixed: https://bugs.mojang.com/browse/WEB-5587?focusedCommentId=1134973&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-1134973
10 |
11 | This mod still affects 1.17 and 1.16 but only on the first chat message received: https://bugs.mojang.com/browse/MC-218167
12 |
13 | **Technical Details**: When receiving a chat message, Minecraft sends a HTTP request in the render thread to check your player block list. The current frame does not finish rendering until this request has finished, causing a lag spike. This mod lets chat messages through until a block-list can be fetched.
14 |
15 | **Why is this happening now and not before?**: something happened to Mojang's API. When joining a world, the blocklist would usually load fine, but Mojang's API has started returning errors for users who have migrated to Microsoft accounts, causing the block list to be fetched in 2 minute intervals when receiving a message.
16 |
17 | **A commented walkthrough of why the bug occurs**
18 |
19 | ```java
20 | private static final long BLOCKLIST_REQUEST_COOLDOWN = 120;
21 | private Instant nextRequest;
22 | private final blockList Set;
23 |
24 | // This method is called when receiving a chat message
25 | public boolean isBlockedPlayer(UUID playerID) {
26 | // If we don't have the blocklist yet, fetch it
27 | // Note that when there's an error, fetchBlockList returns null
28 | //
29 | if (this.blockList == null) {
30 | this.blockList = fetchBlockList();
31 | // If we still don't have it, assume the player is not blocked
32 | if (this.blockList == null) {
33 | return false;
34 | }
35 | }
36 | return this.blockList.contains(playerID);
37 | }
38 |
39 | public Set fetchBlockList() {
40 | // Only check at least every 2 minutes.
41 | // This is why the lagspike only occurs every 2 minutes or later
42 | if (this.nextRequest == null || Instant.now().isAfter(this.nextRequest)) {
43 | return null;
44 | }
45 | // Reset the 2 minute timer
46 | this.nextRequest = Instant.now().plusSeconds(BLOCKLIST_REQUEST_COOLDOWN);
47 | try {
48 | // Make the HTTP request
49 | BlockListResponse response = minecraftClient.get(routeBlocklist, BlockListResponse.class);
50 | return response.getBlockedProfiles();
51 | } catch (/* exception */) {
52 | // If there's an error return null
53 | return null;
54 | }
55 | }
56 | ```
57 |
58 | **Downloads:**
59 | Modrinth: https://modrinth.com/mod/chat-lag-fix
60 | GitHub Releases: https://github.com/adryd325/chat-lag-fix/releases
61 | Curseforge: The site has such awful UX and is so slow that I can't be bothered.
62 |
63 | **Development is split into 3 branches:**
64 | **1.16/1.17**: https://github.com/adryd325/chat-lag-fix/tree/1.16
65 | ~~**1.18**: https://github.com/adryd325/chat-lag-fix/tree/1.18~~
66 |
67 | GIF Example of the bug showing that it occurs in vanilla as well as modded environments
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------