Sk1erLLC / Patcher

A Forge mod full of Vanilla bug fixes, Quality of Life improvements, and performance enhancements.
Other
228 stars 59 forks source link

Fix compact chat scrolling #185

Open Alexdoru opened 1 month ago

Alexdoru commented 1 month ago

When removing ChatLines from the drawChatLines of GuiNewWhat, if you have your chat opened and scrolled up somewhere, your whole chat will move.

This part of the code needs to be changed : https://github.com/Sk1erLLC/Patcher/blob/4ce6e196e5ad1339f8a0ab96eb5680c2f6464583/src/main/java/club/sk1er/patcher/util/chat/ChatHandler.java#L231

Current :

chatLinesWrapped.remove(index);
index--;

Fixed :

chatLinesWrapped.remove(index);
index--;
if (mc.ingameGUI.getChatGUI().getChatOpen()) {
    mc.ingameGUI.getChatGUI().scroll(-1);
}

In the method GuiNewChat.setLine, you can see that the vanilla code is doing the opposite operation to avoid the same problem when adding chat lines.

if (this.getChatOpen() && this.scrollPos > 0)
{
    this.isScrolled = true;
    this.scroll(1);
}