All Mods Resource Packs Data Packs Shaders Modpacks Plugins
Chat Lag Fix

Chat Lag Fix

by adryd • Downloads: 0 • Followers: 0
Description
Gallery
Changelog
Versions

Fixes Minecraft client lag from receiving chat messages

YOU DO NOT NEED THIS MOD ANYMORE ON 1.18

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.

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

This bug still affects 1.17 and 1.16 but only on the first chat message received: https://bugs.mojang.com/browse/MC-218167

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.

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.

A commented walkthrough of why the bug occurs
// A simplified view of the code.
private static final long BLOCKLIST_REQUEST_COOLDOWN = 120;
private Instant nextRequest;
private final blockList Set;

// This method is called when receiving a chat message public boolean isBlockedPlayer(UUID playerID) { // If we don't have the blocklist yet, fetch it // Note that when there's an error, fetchBlockList returns null // if (this.blockList == null) { this.blockList = fetchBlockList(); // If we still don't have it, assume the player is not blocked if (this.blockList == null) { return false; } } return this.blockList.contains(playerID); }

public Set fetchBlockList() { // Only check at least every 2 minutes. // This is why the lagspike only occurs every 2 minutes or later if (this.nextRequest == null || Instant.now().isAfter(this.nextRequest)) { return null; } // Reset the 2 minute timer this.nextRequest = Instant.now().plusSeconds(BLOCKLIST_REQUEST_COOLDOWN); try { // Make the HTTP request BlockListResponse response = minecraftClient.get(routeBlocklist, BlockListResponse.class); return response.getBlockedProfiles(); } catch (/ exception /) { // If there's an error return null return null; } }

If you'd like to see the unmodified for yourself, check out com.mojang.authlib.yggdrasil.YggdrasilUserApiService, remember that these methods get called on the render thread, thus blocking the frame from finishing.
GIF demonstration of the bug

How to Install Chat Lag Fix (Mod)

Chat Lag Fix by adryd is verified for Fabric across Minecraft versions 1.16.4, 1.16.5, 1.17, 1.17.1, 1.18, 1.18.1 (latest release: mc1.17-2.1.0, file size: 8 KB). Follow the steps below to install it safely from ModCraft.tv:

  1. Click the Download button above and select your Minecraft version (1.16.4, 1.16.5, 1.17, 1.17.1, 1.18, 1.18.1) and platform (Fabric).
  2. Make sure you have the compatible loader or environment installed for Fabric.
  3. Move the downloaded Chat Lag Fix file into your Minecraft .minecraft/mods folder and launch the game.

All Versions

+ Add Version
Name Game version Platforms Published Downloads Actions
1.17.x 1.16.x
Fabric
last yr. 1
1.16.x
Fabric
last yr. 1
1.17.x
Fabric
last yr. 1
1.18.x
Fabric
last yr. 1
1.18.x
Fabric
last yr. 1
1.18.x 1.17.x
Fabric
last yr. 1
[mc1.16.5-2.0.2] 2.0.2 by adryd on Jan 09, 2022
Download
Bring back support for 1.17 and add support for 1.16
[mc1.17.x-2.0.2] 2.0.2 by adryd on Jan 09, 2022
Download
Bring back support for 1.17 and add support for 1.16
[mc1.18.x-2.0.2] 2.0.2 by adryd on Jan 09, 2022
Download
Bring back support for 1.17 and add support for 1.16
[2.0.1] 2.0.1 by adryd on Jan 09, 2022
Download
  • 2.0.0**: Update mixin so when Mojang/Microsoft fixes their API, the blocklist should load as normal.
<br>
  • 2.0.1**: Fix for list being fetched after re-logging, It should now only be fetched once per game launch.
Chat Lag Fix Icon
Download Chat Lag Fix
Select game version
Select platform