Fixed Friends Overlay Scroll

This commit is contained in:
kirillsaint 2023-07-27 17:41:00 +06:00
parent 89d0d94416
commit 43df4014a3

View File

@ -7,17 +7,16 @@ import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.gui.animation.SimpleAnimation;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.notification.NotificationManager;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.theme.Theme;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.utils.ColorUtils;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.types.FriendsResponse;
@ -104,15 +103,14 @@ public class FriendsListOverlay extends GuiScreen {
GL11.glPopMatrix();
GlStateManager.popMatrix();
if(scrollY > height) {
scrollAnimation.setAnimation((float) scrollY, 16);
}
scrollAnimation.setAnimation((float) scrollY, 16);
}
@Override
public void handleMouseInput() throws IOException {
super.handleMouseInput();
int dw = Mouse.getEventDWheel();
double newScrollY = this.scrollY;
if(dw != 0) {
if (dw > 0) {
dw = -1;
@ -120,10 +118,19 @@ public class FriendsListOverlay extends GuiScreen {
dw = 1;
}
float amountScrolled = (float) (dw * 10);
if (scrollY + amountScrolled > 0)
scrollY += amountScrolled;
int friendsHeight = (showRequests ? Client.getInstance().getFriends().getRequests().size() : Client.getInstance().getFriends().getFriends().size()) * 25;
if (newScrollY + amountScrolled > 0)
newScrollY += amountScrolled;
else
scrollY = 0;
newScrollY = 0;
if((newScrollY < friendsHeight && friendsHeight > height - 46) || amountScrolled < 0) {
this.scrollY = (float) newScrollY;
if(this.scrollY < 0) {
this.scrollY = 0;
}
}
}
}