From 97c4dbacc883ccaaebcda0c9ee9dae3bf8dab9f2 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 13:06:54 +0600 Subject: [PATCH 01/12] Update HUD Config Screen --- .../client/gui/hud/HUDConfigScreen.java | 102 +++--------------- 1 file changed, 13 insertions(+), 89 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java b/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java index ecf3d67..10f500e 100644 --- a/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java +++ b/src/main/java/net/silentclient/client/gui/hud/HUDConfigScreen.java @@ -5,14 +5,10 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; -import net.silentclient.client.gui.elements.Button; -import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.font.SilentFontRenderer.FontType; -import net.silentclient.client.gui.lite.clickgui.ModSettings; -import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; -import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.CustomFontRenderer.RenderMode; import net.silentclient.client.mods.Mod; @@ -26,17 +22,12 @@ import net.silentclient.client.utils.Sounds; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.awt.*; import java.io.IOException; -import java.text.DecimalFormat; public class HUDConfigScreen extends GuiScreen { private final GuiScreen screen; - private CustomFontRenderer font; - - private boolean tutorial = false; private Mod mod = null; @Override @@ -44,11 +35,9 @@ public class HUDConfigScreen extends GuiScreen { MenuBlurUtils.loadBlur(); super.initGui(); - this.tutorial = false; this.mod = null; ScaledResolution scaledresolution = new ScaledResolution(this.mc); - this.buttonList.add(new Button(0, scaledresolution.getScaledWidth() / 2 - 50, scaledresolution.getScaledHeight() - 65, 100, 20, "Back")); - this.buttonList.add(new Button(1, scaledresolution.getScaledWidth() / 2 - 50, scaledresolution.getScaledHeight() - 88, 100, 20, "Help")); + this.buttonList.add(new IconButton(0, scaledresolution.getScaledWidth() / 2 - 10, scaledresolution.getScaledHeight() - 80, 30, 30, 22, 22, new ResourceLocation("silentclient/icons/back.png"))); this.font = new CustomFontRenderer(); font.setRenderMode(RenderMode.CUSTOM); @@ -99,6 +88,7 @@ public class HUDConfigScreen extends GuiScreen { } if(((ModDraggable) m).isDragging()) { + this.mod = m; ((ModDraggable) m).setPos(new ScreenPosition(mouseX + ((ModDraggable) m).getDraggingX(), mouseY + ((ModDraggable) m).getDraggingY())); } @@ -117,49 +107,12 @@ public class HUDConfigScreen extends GuiScreen { } } + if(mod != null && !((ModDraggable) mod).isDragging()) { + this.mod = null; + } + Client.getInstance().getMouseCursorHandler().enableCursor(cursorType); - if (this.buttonList != null && this.buttonList.size() != 0) - { - if (this.tutorial) - { - int i = scaledresolution.getScaledWidth() / 2 - 70; - int j = scaledresolution.getScaledHeight() / 2 - 45; - i = i - 4; - int currentY = j + 2; - font.drawString("Gui Editing Explained", i, currentY, 16, SilentFontRenderer.FontType.HEADER, -1, false); - currentY = currentY + 20; - i = i + (font.getStringWidth("Gui Editing Explained", 16, FontType.HEADER) / 2); - font.drawString("Mouse 1 - Hold | drag mod", i - (font.getStringWidth("Mouse 1 - Hold | drag mod", 12, FontType.TITLE) / 2), currentY, 12, SilentFontRenderer.FontType.TITLE, -1, false); - currentY = currentY + 12; - font.drawString("Mouse 2 - Click | scale mod", i - (font.getStringWidth("Mouse 2 - Click | scale mod", 12, FontType.TITLE) / 2), currentY, 12, SilentFontRenderer.FontType.TITLE, -1, false); - - } - - if(this.mod != null) { - Setting setting = Client.getInstance().getSettingsManager().getSettingByName(mod, "Scale"); - int left = scaledresolution.getScaledWidth() / 2 - 60; - font.drawString("Scale of " + mod.getName(), left + 60 - (font.getStringWidth("Scale of " + mod.getName(), 16, FontType.HEADER) / 2), (scaledresolution.getScaledHeight() / 2) - 30, 16, SilentFontRenderer.FontType.HEADER, -1, false); - - RenderUtils.drawRect(left, (scaledresolution.getScaledHeight() / 2) - 1, 90, 9, Color.black.getRGB()); - RenderUtils.drawRect(left, (scaledresolution.getScaledHeight() / 2) - 1, 90F * (float) (setting.getValFloat() / setting.getMax()), 9, -1); - boolean drag = MouseUtils.isInside(mouseX, mouseY, left, (scaledresolution.getScaledHeight() / 2) - 1, 90, 9) && Mouse.isButtonDown(0); - if (drag) { - double diff = setting.getMax() - setting.getMin(); - double mouse = MathHelper.clamp_double((mouseX - left) / 90D, 0, 1); - double newVal = setting.getMin() + mouse * diff; - setting.setValDouble(newVal); - } - - int textLeft = left + 100; - Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(setting.getValDouble()), textLeft, scaledresolution.getScaledHeight() / 2 - 2, 12, FontType.TITLE); - } - } - else - { - this.initGui(); - } - super.drawScreen(mouseX, mouseY, partialTicks); this.zLevel = zBackup; GlStateManager.disableAlpha(); @@ -171,29 +124,7 @@ public class HUDConfigScreen extends GuiScreen { super.actionPerformed(button); switch(button.id) { case 0: - if(this.tutorial) { - this.tutorial = false; - this.mod = null; - this.buttonList.get(1).displayString = "Help"; - this.buttonList.get(1).visible = true; - } else if(this.mod != null) { - this.tutorial = false; - this.mod = null; - this.buttonList.get(1).visible = true; - this.buttonList.get(1).displayString = "Help"; - } else { - mc.displayGuiScreen(screen); - } - break; - case 1: - if(this.mod != null) { - mc.displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ModSettings(mod, this) : new net.silentclient.client.gui.modmenu.ModSettings(mod, this)); - } else { - this.tutorial = true; - this.mod = null; - this.buttonList.get(1).visible = false; - this.buttonList.get(1).displayString = "Help"; - } + mc.displayGuiScreen(screen); break; } } @@ -241,17 +172,10 @@ public class HUDConfigScreen extends GuiScreen { } boolean hovered = ((ModDraggable) m).isHovered(mouseX, mouseY, scaledResolution); - if(hovered) { - if(mouseButton == 1) { - this.tutorial = false; - this.mod = m; - this.buttonList.get(1).visible = true; - this.buttonList.get(1).displayString = "Mod Settings"; - } else if(mouseButton == 0) { - ((ModDraggable) m).setDragging(true); - ((ModDraggable) m).setDraggingX(((ModDraggable) m).getPos().getAbsoluteX() - mouseX); - ((ModDraggable) m).setDraggingY(((ModDraggable) m).getPos().getAbsoluteY() - mouseY); - } + if(hovered && mouseButton == 0) { + ((ModDraggable) m).setDragging(true); + ((ModDraggable) m).setDraggingX(((ModDraggable) m).getPos().getAbsoluteX() - mouseX); + ((ModDraggable) m).setDraggingY(((ModDraggable) m).getPos().getAbsoluteY() - mouseY); break; } } From c8297dbdb925eeec23f7c110eb9c39d1710c805f Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 13:11:03 +0600 Subject: [PATCH 02/12] New Slider --- .../net/silentclient/client/gui/modmenu/ModSettings.java | 2 +- .../silentclient/client/gui/modmenu/RegularSlider.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java b/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java index 769656e..854910b 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/ModSettings.java @@ -117,7 +117,7 @@ public class ModSettings extends SilentScreen { if(RegularSlider.isDrag(mouseX, mouseY, 3, settingY, 144) && (System.currentTimeMillis() - initTime) > 500) { double diff = setting.getMax() - setting.getMin(); - double mouse = MathHelper.clamp_double((mouseX - 3) / 90D, 0, 1); + double mouse = MathHelper.clamp_double((mouseX - 3) / 144D, 0, 1); double newVal = setting.getMin() + mouse * diff; if(newVal != setting.getValDouble()) { setting.setValDouble(newVal); diff --git a/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java index c7e2239..783a12a 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java @@ -3,7 +3,6 @@ package net.silentclient.client.gui.modmenu; import net.silentclient.client.Client; import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; -import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.util.RenderUtil; import org.lwjgl.input.Mouse; @@ -14,16 +13,16 @@ public class RegularSlider { public static void render(float x, float y, int width, String name, double max, double value) { Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE); - RenderUtil.drawRoundedRect(x, y + 15, 100, 9, 3, Color.black.getRGB()); + RenderUtil.drawRoundedRect(x, y + 15, 144, 9, 3, Color.black.getRGB()); if(value != 0) { - RenderUtil.drawRoundedRect(x, y + 15, 100F * (float) (value / max), 9, 3, -1); + RenderUtil.drawRoundedRect(x, y + 15, 144F * (float) (value / max), 9, 3, -1); } float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE); - Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y + 14, 12, SilentFontRenderer.FontType.TITLE); + Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE); } public static boolean isDrag(int mouseX, int mouseY, float x, float y, int width) { - return MouseUtils.isInside(mouseX, mouseY, x, y + 15, 100, 9) && Mouse.isButtonDown(0); + return MouseUtils.isInside(mouseX, mouseY, x, y + 15, 144, 9) && Mouse.isButtonDown(0); } } From ce02daf2e05af27b0844261d15ca8a488e41b4d1 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 14:00:10 +0600 Subject: [PATCH 03/12] New Lite Main Menu --- .../client/gui/lite/LiteMainMenu.java | 457 ++++-------------- 1 file changed, 91 insertions(+), 366 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index 30ce434..d81f5df 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -1,408 +1,133 @@ package net.silentclient.client.gui.lite; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.resources.I18n; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.realms.RealmsBridge; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import net.minecraft.world.demo.DemoWorldServer; -import net.minecraft.world.storage.ISaveFormat; -import net.minecraft.world.storage.WorldInfo; import net.silentclient.client.Client; import net.silentclient.client.cosmetics.gui.CosmeticsGui; +import net.silentclient.client.gui.animation.SimpleAnimation; 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.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; import net.silentclient.client.gui.util.RenderUtil; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.opengl.GLContext; import java.io.IOException; import java.net.URI; -import java.util.Random; -public class LiteMainMenu extends GuiScreen implements GuiYesNoCallback +public class LiteMainMenu extends GuiScreen { - private static final Logger logger = LogManager.getLogger(); - private static final Random RANDOM = new Random(); + private SimpleAnimation bannerAnimation; - /** Counts the number of screen updates. */ - private float updateCounter; - - /** The splash message. */ - private String splashText; - private GuiButton buttonResetDemo; - - /** Timer used to rotate the panorama, increases every tick. */ - - /** - * Texture allocated for the current viewport of the main menu's panorama background. - */ - - /** - * The Object object utilized as a thread lock when performing non thread-safe operations - */ - private final Object threadLock = new Object(); - - /** OpenGL graphics card warning. */ - private String openGLWarning1; - - /** OpenGL graphics card warning. */ - private String openGLWarning2; - - /** Link to the Mojang Support about minimum requirements */ - private String openGLWarningLink; - private static final ResourceLocation minecraftTitleTextures = new ResourceLocation("silentclient/logos/menu_logo.png"); - - /** An array of all the paths to the panorama pictures. */ - public static final String field_96138_a = "Please click " + EnumChatFormatting.UNDERLINE + "here" + EnumChatFormatting.RESET + " for more information."; - private int field_92024_r; - private int field_92023_s; - private int field_92022_t; - private int field_92021_u; - private int field_92020_v; - private int field_92019_w; - - private GuiButton singlePlayer; - private GuiButton multiPlayer; - private GuiButton options; - private GuiButton cosmetics; - - /** Minecraft Realms button. */ - private GuiButton realmsButton; - public LiteMainMenu() { - this.openGLWarning2 = field_96138_a; - this.splashText = ""; - this.setUpdateCounter(RANDOM.nextFloat()); - this.openGLWarning1 = ""; - - if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) - { - this.openGLWarning1 = I18n.format("title.oldgl1"); - this.openGLWarning2 = I18n.format("title.oldgl2"); - this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game"; - } - } - - public LiteMainMenu(boolean firstTime) - { - this.openGLWarning2 = field_96138_a; - this.splashText = ""; - this.setUpdateCounter(RANDOM.nextFloat()); - this.openGLWarning1 = ""; - - if (!GLContext.getCapabilities().OpenGL20 && !OpenGlHelper.areShadersSupported()) - { - this.openGLWarning1 = I18n.format("title.oldgl1"); - this.openGLWarning2 = I18n.format("title.oldgl2"); - this.openGLWarningLink = "https://help.mojang.com/customer/portal/articles/325948?ref=game"; - } - } - - /** - * Called from the main game loop to update the screen. - */ - public void updateScreen() - { - Client.backgroundPanorama.tickPanorama(); - } - - /** - * Returns true if this GUI should pause the game when it is displayed in single-player - */ - public boolean doesGuiPauseGame() - { - return false; - } - - /** - * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of - * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code) - */ - protected void keyTyped(char typedChar, int keyCode) throws IOException - { - } - - /** - * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the - * window resizes, the buttonList is cleared beforehand. - */ - public void initGui() - { - int j = this.height / 4 + 48; + @Override + public void initGui() { + super.initGui(); + this.bannerAnimation = new SimpleAnimation(0); Client.backgroundPanorama.updateWidthHeight(this.width, this.height); - - this.buttonList.add(new IconButton(88, 4, 5, new ResourceLocation("silentclient/icons/news.png"))); - this.buttonList.add(cosmetics = new IconButton(87, 26, 5, new ResourceLocation("silentclient/icons/settings/cosmetics.png"))); - this.buttonList.add(new IconButton(991, 48, 5, new ResourceLocation("silentclient/icons/store_icon.png"))); - this.buttonList.add(new IconButton(992, 70, 5, new ResourceLocation("silentclient/icons/language.png"))); - this.buttonList.add(new IconButton(89, 92, 5, new ResourceLocation("silentclient/icons/back.png"))); - if (this.mc.isDemo()) - { - this.addDemoButtons(j, 24); - } - else - { - this.addSingleplayerMultiplayerButtons(j, 24); - } - this.buttonList.add(options = new Button(0, this.width / 2 - 100, j + 52, 98, 20, "Options")); - this.buttonList.add(new Button(4, this.width / 2 + 2, j + 52, 98, 20, "Quit Game")); + this.buttonList.clear(); + this.buttonList.add(new IconButton(1, 4, 5, new ResourceLocation("silentclient/icons/news.png"))); + this.buttonList.add(new IconButton(2, 26, 5, new ResourceLocation("silentclient/icons/settings/cosmetics.png"))); + this.buttonList.add(new IconButton(3, 48, 5, new ResourceLocation("silentclient/icons/store_icon.png"))); + this.buttonList.add(new IconButton(4, 70, 5, new ResourceLocation("silentclient/icons/language.png"))); + this.buttonList.add(new IconButton(5, 92, 5, new ResourceLocation("silentclient/icons/back.png"))); - synchronized (this.threadLock) - { - this.field_92023_s = this.fontRendererObj.getStringWidth(this.openGLWarning1); - this.field_92024_r = this.fontRendererObj.getStringWidth(this.openGLWarning2); - int k = Math.max(this.field_92023_s, this.field_92024_r); - this.field_92022_t = (this.width - k) / 2; - this.field_92021_u = ((GuiButton)this.buttonList.get(0)).yPosition - 24; - this.field_92020_v = this.field_92022_t + k; - this.field_92019_w = this.field_92021_u + 24; - } + this.buttonList.add(new Button(6, this.width / 2 - 90, this.height / 2 - 18, 180, 18, "Singleplayer")); + this.buttonList.add(new Button(7, this.width / 2 - 90, this.height / 2 + 5, 180, 18, "Multiplayer")); - this.mc.setConnectedToRealms(false); + this.buttonList.add(new Button(8, this.width / 2 - 90, this.height / 2 + 28, 87, 18, "Options")); + this.buttonList.add(new Button(9, this.width / 2 + 2, this.height / 2 + 28, 88, 18, "Quit Game")); } - /** - * Adds Singleplayer and Multiplayer buttons on Main Menu for players who have bought the game. - */ - private void addSingleplayerMultiplayerButtons(int p_73969_1_, int p_73969_2_) - { - this.buttonList.add(singlePlayer = new Button(1, this.width / 2 - 100, p_73969_1_, "Singleplayer")); - this.buttonList.add(multiPlayer = new Button(2, this.width / 2 - 100, p_73969_1_ + p_73969_2_ * 1, "Multiplayer")); - } + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GuiNews.loadPanel(); + GlStateManager.disableAlpha(); + Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); + GlStateManager.enableAlpha(); + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); - /** - * Adds Demo buttons on Main Menu for players who are playing Demo. - */ - private void addDemoButtons(int p_73972_1_, int p_73972_2_) - { - this.buttonList.add(new Button(11, this.width / 2 - 100, p_73972_1_, I18n.format("menu.playdemo", new Object[0]))); - this.buttonList.add(this.buttonResetDemo = new Button(12, this.width / 2 - 100, p_73972_1_ + p_73972_2_ * 1, I18n.format("menu.resetdemo", new Object[0]))); - ISaveFormat isaveformat = this.mc.getSaveLoader(); - WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); + RenderUtil.drawImage(new ResourceLocation("silentclient/logos/menu_logo.png"), this.width / 2 - 80, 20, 160, 70); - if (worldinfo == null) - { - this.buttonResetDemo.enabled = false; - } - } + Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "SLC Lite 1.8.9", 12, SilentFontRenderer.FontType.TITLE); - /** - * Called by the controls from the buttonList when activated. (Mouse pressed for buttons) - */ - protected void actionPerformed(GuiButton button) throws IOException - { - if(button.id == 991) { - try { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://store.silentclient.net/")}); - } catch (Throwable err) { - err.printStackTrace(); + if(GuiNews.imageLocation != null) { + if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) { + this.bannerAnimation.setAnimation(4, 12); + } else { + this.bannerAnimation.setAnimation(0, 12); } - return; + RenderUtil.drawImage(GuiNews.imageLocation, this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, false); } - if(button.id == 992) { - mc.displayGuiScreen(new GuiLanguage(this, new GameSettings(), mc.getLanguageManager())); - return; - } - - if (button.id == 0) - { - this.mc.displayGuiScreen(new GuiOptions(this, this.mc.gameSettings)); - } - - if (button.id == 5) - { - this.mc.displayGuiScreen(new GuiLanguage(this, this.mc.gameSettings, this.mc.getLanguageManager())); - } - - if (button.id == 1) - { - this.mc.displayGuiScreen(new GuiSelectWorld(this)); - } - - if (button.id == 2) - { - this.mc.displayGuiScreen(new GuiMultiplayer(this)); - } - - if(button.id == 89) { - Client.getInstance().getGlobalSettings().setLite(false); - Client.getInstance().getGlobalSettings().save(); - mc.displayGuiScreen(new MainMenuConcept()); - } - - if (button.id == 14 && this.realmsButton.visible) - { - this.switchToRealms(); - } - - if (button.id == 4) - { - this.mc.shutdown(); - } - - if (button.id == 11) - { - this.mc.launchIntegratedServer("Demo_World", "Demo_World", DemoWorldServer.demoWorldSettings); - } - - if (button.id == 12) - { - ISaveFormat isaveformat = this.mc.getSaveLoader(); - WorldInfo worldinfo = isaveformat.getWorldInfo("Demo_World"); - - if (worldinfo != null) - { - GuiYesNo guiyesno = GuiSelectWorld.makeDeleteWorldYesNo(this, worldinfo.getWorldName(), 12); - this.mc.displayGuiScreen(guiyesno); - } - } - - if(button.id == 87) { - this.mc.displayGuiScreen(new CosmeticsGui()); - } - - if(button.id == 88) { - this.mc.displayGuiScreen(new GuiNews()); - } - } - - private void switchToRealms() - { - RealmsBridge realmsbridge = new RealmsBridge(); - realmsbridge.switchToRealms(this); - } - - public void confirmClicked(boolean result, int id) - { - if (result && id == 12) - { - ISaveFormat isaveformat = this.mc.getSaveLoader(); - isaveformat.flushCache(); - isaveformat.deleteWorldDirectory("Demo_World"); - this.mc.displayGuiScreen(this); - } - else if (id == 13) - { - if (result) - { - try - { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(this.openGLWarningLink)}); - } - catch (Throwable throwable) - { - logger.error("Couldn\'t open link", throwable); - } - } - - this.mc.displayGuiScreen(this); - } - } - - - /** - * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks - */ - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - GlStateManager.disableAlpha(); - Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); - GlStateManager.enableAlpha(); - Tessellator tessellator = Tessellator.getInstance(); - tessellator.getWorldRenderer(); - int i = 274; - int j = this.width / 2 - i / 2; - int k = 30; - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); - - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - - singlePlayer.visible = true; - multiPlayer.visible = true; - options.visible = true; - cosmetics.visible = true; - - RenderUtil.drawImage(minecraftTitleTextures, j + 30, k - 25, 220, 95); - - GlStateManager.pushMatrix(); - GlStateManager.translate((float)(this.width / 2 + 90), 70.0F, 0.0F); - GlStateManager.rotate(-20.0F, 0.0F, 0.0F, 1.0F); - float f = 1.8F - MathHelper.abs(MathHelper.sin((float)(Minecraft.getSystemTime() % 1000L) / 1000.0F * (float)Math.PI * 2.0F) * 0.1F); - f = f * 100.0F / (float)(this.fontRendererObj.getStringWidth(this.splashText) + 32); - GlStateManager.scale(f, f, f); - GlStateManager.popMatrix(); - String s = "SC Lite 1.8.9"; - - if (this.mc.isDemo()) - { - s = s + " Demo"; - } - - Client.getInstance().getSilentFontRenderer().drawString(s, 2, this.height - 14, 14, SilentFontRenderer.FontType.TITLE); - - if(GuiNews.imageLocation != null) { - RenderUtil.drawImage(new ResourceLocation(Client.getInstance().getAccount().discord_id != null ? GuiNews.imageLocation.getResourcePath() : "silentclient/images/discord.png"), this.width - 73, this.height - 42, 71, 40, false); - } - - if (this.openGLWarning1 != null && this.openGLWarning1.length() > 0) - { - drawRect(this.field_92022_t - 2, this.field_92021_u - 2, this.field_92020_v + 2, this.field_92019_w - 1, 1428160512); - this.drawString(this.fontRendererObj, this.openGLWarning1, this.field_92022_t, this.field_92021_u, -1); - this.drawString(this.fontRendererObj, this.openGLWarning2, (this.width - this.field_92024_r) / 2, ((GuiButton)this.buttonList.get(0)).yPosition - 12, -1); - } - super.drawScreen(mouseX, mouseY, partialTicks); } - /** - * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton - */ - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException - { - super.mouseClicked(mouseX, mouseY, mouseButton); - - if(MouseUtils.isInside(mouseX, mouseY, this.width - 73, this.height - 42, 71, 40) && GuiNews.news != null) { - try { - Class oclass = Class.forName("java.awt.Desktop"); - Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); - oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI(Client.getInstance().getAccount().discord_id != null ? "https://silentclient.net/news/" + + GuiNews.news.getItem().id : "https://silentclient.net/news/4")}); - } catch (Throwable err) { - err.printStackTrace(); - } + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + switch (button.id) { + case 1: + mc.displayGuiScreen(new GuiNews()); + break; + case 2: + mc.displayGuiScreen(new CosmeticsGui()); + break; + case 3: + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://store.silentclient.net/")}); + } catch (Throwable err) { + err.printStackTrace(); + } + break; + case 4: + mc.displayGuiScreen(new GuiLanguage(this, mc.gameSettings, mc.getLanguageManager())); + break; + case 5: + Client.getInstance().getGlobalSettings().setLite(false); + Client.getInstance().getGlobalSettings().save(); + mc.displayGuiScreen(new MainMenuConcept()); + break; + case 6: + mc.displayGuiScreen(new GuiSelectWorld(this)); + break; + case 7: + mc.displayGuiScreen(new GuiMultiplayer(this)); + break; + case 8: + mc.displayGuiScreen(new GuiOptions( this, mc.gameSettings)); + break; + case 9: + mc.shutdown(); + break; } + } - synchronized (this.threadLock) - { - if (this.openGLWarning1.length() > 0 && mouseX >= this.field_92022_t && mouseX <= this.field_92020_v && mouseY >= this.field_92021_u && mouseY <= this.field_92019_w) - { - GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.openGLWarningLink, 13, true); - guiconfirmopenlink.disableSecurityWarning(); - this.mc.displayGuiScreen(guiconfirmopenlink); + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) { + try { + Class oclass = Class.forName("java.awt.Desktop"); + Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]); + oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("https://silentclient.net/news/" + GuiNews.news.getItem().id)}); + } catch (Throwable err) { + err.printStackTrace(); } } } - public float getUpdateCounter() { - return updateCounter; - } + @Override + public void updateScreen() { + super.updateScreen(); + Client.backgroundPanorama.tickPanorama(); + } - public void setUpdateCounter(float updateCounter) { - this.updateCounter = updateCounter; - } + @Override + public boolean doesGuiPauseGame() { + return false; + } } From 3d83f14faa22d3bd7f33a24ede21cbc4ef66559a Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 14:12:38 +0600 Subject: [PATCH 04/12] Update LiteMainMenu.java --- .../silentclient/client/gui/lite/LiteMainMenu.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index d81f5df..63d69c0 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -33,11 +33,17 @@ public class LiteMainMenu extends GuiScreen this.buttonList.add(new IconButton(4, 70, 5, new ResourceLocation("silentclient/icons/language.png"))); this.buttonList.add(new IconButton(5, 92, 5, new ResourceLocation("silentclient/icons/back.png"))); - this.buttonList.add(new Button(6, this.width / 2 - 90, this.height / 2 - 18, 180, 18, "Singleplayer")); - this.buttonList.add(new Button(7, this.width / 2 - 90, this.height / 2 + 5, 180, 18, "Multiplayer")); + int buttonY = this.height / 2 - 18; - this.buttonList.add(new Button(8, this.width / 2 - 90, this.height / 2 + 28, 87, 18, "Options")); - this.buttonList.add(new Button(9, this.width / 2 + 2, this.height / 2 + 28, 88, 18, "Quit Game")); + if(buttonY - 90 > 50) { + buttonY = 110; + } + + this.buttonList.add(new Button(6, this.width / 2 - 90, buttonY, 180, 18, "Singleplayer")); + this.buttonList.add(new Button(7, this.width / 2 - 90, buttonY + 18 + 5, 180, 18, "Multiplayer")); + + this.buttonList.add(new Button(8, this.width / 2 - 90, buttonY + 18 + 5 + 18 + 5, 87, 18, "Options")); + this.buttonList.add(new Button(9, this.width / 2 + 2, buttonY + 18 + 5 + 18 + 5, 88, 18, "Quit Game")); } @Override From 0d1dc4f7ed005ce116c125302b491318d0518894 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 15:00:46 +0600 Subject: [PATCH 05/12] Added Description to Lite Main Menu --- .../net/silentclient/client/gui/lite/LiteMainMenu.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index 63d69c0..d848b47 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -12,7 +12,9 @@ import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; import net.silentclient.client.gui.util.RenderUtil; +import net.silentclient.client.utils.ColorUtils; +import java.awt.*; import java.io.IOException; import java.net.URI; @@ -36,7 +38,7 @@ public class LiteMainMenu extends GuiScreen int buttonY = this.height / 2 - 18; if(buttonY - 90 > 50) { - buttonY = 110; + buttonY = 120; } this.buttonList.add(new Button(6, this.width / 2 - 90, buttonY, 180, 18, "Singleplayer")); @@ -55,7 +57,10 @@ public class LiteMainMenu extends GuiScreen this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); RenderUtil.drawImage(new ResourceLocation("silentclient/logos/menu_logo.png"), this.width / 2 - 80, 20, 160, 70); + ColorUtils.setColor(new Color(115, 117, 119).getRGB()); + Client.getInstance().getSilentFontRenderer().drawCenteredString("The most complete all-in-one mod library for Minecraft", this.width / 2, 87, 10, SilentFontRenderer.FontType.TITLE); + ColorUtils.setColor(-1); Client.getInstance().getSilentFontRenderer().drawString(3, height - 14, "SLC Lite 1.8.9", 12, SilentFontRenderer.FontType.TITLE); if(GuiNews.imageLocation != null) { From abcb6872bb1f2cec65154ec97559ed13fbd94fe2 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 15:54:52 +0600 Subject: [PATCH 06/12] Better Panorama --- .../client/cosmetics/gui/CosmeticsGui.java | 6 +++++- .../client/cosmetics/gui/NewOutfitModal.java | 7 ++++++- .../client/cosmetics/gui/OutfitsGui.java | 6 +++++- .../net/silentclient/client/gui/GuiError.java | 15 +++++++++------ .../net/silentclient/client/gui/lite/GuiNews.java | 7 ++++++- .../client/gui/lite/LiteMainMenu.java | 6 +++++- .../gui/silentmainmenu/MainMenuConcept.java | 2 +- .../client/premium/PremiumCosmeticsGui.java | 7 ++++++- 8 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java index c9bee0d..26b527e 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java @@ -238,7 +238,11 @@ public class CosmeticsGui extends SilentScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } } else { MenuBlurUtils.renderBackground(this); } diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java index 7eade9d..8da0c24 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java @@ -17,6 +17,7 @@ import net.silentclient.client.utils.MenuBlurUtils; import net.silentclient.client.utils.NotificationUtils; import org.lwjgl.input.Keyboard; +import java.awt.*; import java.io.IOException; public class NewOutfitModal extends SilentScreen { @@ -83,7 +84,11 @@ public class NewOutfitModal extends SilentScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } } else { MenuBlurUtils.renderBackground(this); } diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java index 09368a9..db3494d 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java @@ -57,7 +57,11 @@ public class OutfitsGui extends SilentScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } } else { MenuBlurUtils.renderBackground(this); } diff --git a/src/main/java/net/silentclient/client/gui/GuiError.java b/src/main/java/net/silentclient/client/gui/GuiError.java index 71cffcc..0d78db7 100644 --- a/src/main/java/net/silentclient/client/gui/GuiError.java +++ b/src/main/java/net/silentclient/client/gui/GuiError.java @@ -1,16 +1,15 @@ package net.silentclient.client.gui; -import java.io.IOException; - -import net.minecraft.client.gui.Gui; -import net.silentclient.client.gui.elements.Button; - import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.silentclient.client.Client; +import net.silentclient.client.gui.elements.Button; import net.silentclient.client.gui.font.SilentFontRenderer; +import java.awt.*; +import java.io.IOException; + public class GuiError extends GuiScreen { private final String error; @@ -24,7 +23,11 @@ public class GuiError extends GuiScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/src/main/java/net/silentclient/client/gui/lite/GuiNews.java b/src/main/java/net/silentclient/client/gui/lite/GuiNews.java index ca01b27..7765253 100644 --- a/src/main/java/net/silentclient/client/gui/lite/GuiNews.java +++ b/src/main/java/net/silentclient/client/gui/lite/GuiNews.java @@ -16,6 +16,7 @@ import net.silentclient.client.utils.SCTextureManager; import net.silentclient.client.utils.TimerUtils; import net.silentclient.client.utils.types.NewsResponse; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URI; @@ -61,7 +62,11 @@ public class GuiNews extends SilentScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if(imageLocation != null) { diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index d848b47..31c72e0 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -54,7 +54,11 @@ public class LiteMainMenu extends GuiScreen GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } RenderUtil.drawImage(new ResourceLocation("silentclient/logos/menu_logo.png"), this.width / 2 - 80, 20, 160, 70); ColorUtils.setColor(new Color(115, 117, 119).getRGB()); diff --git a/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java b/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java index 786e27c..e1b3bef 100644 --- a/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java +++ b/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java @@ -82,7 +82,7 @@ public class MainMenuConcept extends SilentScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); if(imageLocation != null) { RenderUtil.drawImage(imageLocation, width - 120, height / 2 - (75), 62, 150, false); diff --git a/src/main/java/net/silentclient/client/premium/PremiumCosmeticsGui.java b/src/main/java/net/silentclient/client/premium/PremiumCosmeticsGui.java index fa33615..aabb827 100644 --- a/src/main/java/net/silentclient/client/premium/PremiumCosmeticsGui.java +++ b/src/main/java/net/silentclient/client/premium/PremiumCosmeticsGui.java @@ -14,6 +14,7 @@ import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.utils.types.PremiumCosmeticsResponse; +import java.awt.*; import java.io.IOException; import java.time.LocalDate; @@ -35,7 +36,11 @@ public class PremiumCosmeticsGui extends GuiScreen { GlStateManager.disableAlpha(); Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); GlStateManager.enableAlpha(); - this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + if(Client.getInstance().getGlobalSettings().isLite()) { + this.drawGradientRect(0, 0, this.width, this.height, new Color(0, 0, 0, 127).getRGB(), new Color(0, 0, 0, 200).getRGB()); + } else { + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } ScaledResolution scaledResolution = new ScaledResolution(mc); super.drawScreen(mouseX, mouseY, partialTicks); String month = ""; From 443b4b29ab69597dbfe2cb089e09315aad04ffd6 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 16:53:01 +0600 Subject: [PATCH 07/12] Account Picker in Lite Menu --- .../client/cosmetics/gui/NewOutfitModal.java | 4 +- .../client/gui/elements/Button.java | 16 +- .../client/gui/lite/LiteAccountPicker.java | 156 ++++++++++++++++++ .../client/gui/lite/LiteMainMenu.java | 21 ++- .../gui/silentmainmenu/MainMenuConcept.java | 9 +- .../components/AccountPicker.java | 6 +- .../silentclient/icons/dropdown-icon.png | Bin 2093 -> 2088 bytes .../silentclient/images/steve_head.png | Bin 0 -> 972 bytes 8 files changed, 190 insertions(+), 22 deletions(-) create mode 100644 src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java mode change 100755 => 100644 src/main/resources/assets/minecraft/silentclient/icons/dropdown-icon.png create mode 100644 src/main/resources/assets/minecraft/silentclient/images/steve_head.png diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java index 8da0c24..8580958 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java @@ -28,7 +28,7 @@ public class NewOutfitModal extends SilentScreen { public NewOutfitModal(GuiScreen parentScreen) { this.parentScreen = parentScreen; this.modalWidth = 200; - this.modalHeight = 90; + this.modalHeight = 70; } @Override @@ -98,7 +98,7 @@ public class NewOutfitModal extends SilentScreen { // Header RenderUtils.drawRect(x, y, this.modalWidth, this.modalHeight, Theme.backgroundColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawString("New Config", x + 3, y + 3, 14, SilentFontRenderer.FontType.TITLE); + Client.getInstance().getSilentFontRenderer().drawString("New Outfit", x + 3, y + 3, 14, SilentFontRenderer.FontType.TITLE); // Content this.silentInputs.get(0).render(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6); diff --git a/src/main/java/net/silentclient/client/gui/elements/Button.java b/src/main/java/net/silentclient/client/gui/elements/Button.java index b17d518..8f66c4b 100644 --- a/src/main/java/net/silentclient/client/gui/elements/Button.java +++ b/src/main/java/net/silentclient/client/gui/elements/Button.java @@ -18,7 +18,7 @@ import java.awt.*; public class Button extends GuiButton { - protected int animatedOpcaity = 0; + protected int animatedOpacity = 0; private boolean escMenu = false; private int fontSize; @@ -67,27 +67,27 @@ public class Button extends GuiButton this.hovered = mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width && mouseY < this.yPosition + this.height; ColorUtils.setColor(theme.getBackgroundColor().getRGB()); RenderUtil.drawRoundedRect((float) xPosition, (float)yPosition, width, height, (float)3, theme.getBackgroundColor().getRGB()); - ColorUtils.setColor(theme.getHoveredBackgroundColor(this.enabled ? animatedOpcaity : 0).getRGB()); - RenderUtil.drawRoundedRect((float) xPosition, (float)yPosition, width, height, (float)3, theme.getHoveredBackgroundColor(this.enabled ? animatedOpcaity : 0).getRGB()); + ColorUtils.setColor(theme.getHoveredBackgroundColor(this.enabled ? animatedOpacity : 0).getRGB()); + RenderUtil.drawRoundedRect((float) xPosition, (float)yPosition, width, height, (float)3, theme.getHoveredBackgroundColor(this.enabled ? animatedOpacity : 0).getRGB()); ColorUtils.setColor(this.enabled ? new Color(214, 213, 210, 255).getRGB() : new Color(255,255,255,50).getRGB()); RenderUtil.drawRoundedOutline(xPosition, yPosition, width, height, 3, 1, theme.getBorderColor().getRGB()); this.mouseDragged(mc, mouseX, mouseY); if (this.hovered && this.enabled) { - if (this.animatedOpcaity < 75 && animateTimer.delay(30)) { - this.animatedOpcaity += 15; + if (this.animatedOpacity < 75 && animateTimer.delay(30)) { + this.animatedOpacity += 15; animateTimer.reset(); } } else { - if (this.animatedOpcaity != 0 && animateTimer.delay(30)) { - this.animatedOpcaity -= 15; + if (this.animatedOpacity != 0 && animateTimer.delay(30)) { + this.animatedOpacity -= 15; animateTimer.reset(); } } this.drawButtonContent(); } else { - this.animatedOpcaity = 0; + this.animatedOpacity = 0; } } diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java b/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java new file mode 100644 index 0000000..77887ca --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java @@ -0,0 +1,156 @@ +package net.silentclient.client.gui.lite; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.util.ResourceLocation; +import net.silentclient.client.Client; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; +import net.silentclient.client.gui.silentmainmenu.components.AccountPicker; +import net.silentclient.client.gui.theme.button.DefaultButtonTheme; +import net.silentclient.client.gui.theme.button.IButtonTheme; +import net.silentclient.client.gui.util.RenderUtil; +import net.silentclient.client.utils.AccountManager; +import net.silentclient.client.utils.ColorUtils; +import net.silentclient.client.utils.SCTextureManager; +import net.silentclient.client.utils.TimerUtils; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.HashMap; +import java.util.Random; + +public class LiteAccountPicker extends AccountPicker { + public static HashMap avatars = new HashMap<>(); + public static boolean loading; + protected int animatedOpacity = 0; + protected TimerUtils animateTimer = new TimerUtils(); + + public LiteAccountPicker(int x, int y) { + super(x, y); + } + + public void draw(Minecraft mc, int mouseX, int mouseY) { + IButtonTheme theme = new DefaultButtonTheme(); + ColorUtils.setColor(theme.getBackgroundColor().getRGB()); + RenderUtil.drawRoundedRect(x, y, 100, 18, 3, theme.getBackgroundColor().getRGB()); + ColorUtils.setColor(theme.getHoveredBackgroundColor(animatedOpacity).getRGB()); + RenderUtil.drawRoundedRect(x, y, 100, 18, 3, theme.getHoveredBackgroundColor(animatedOpacity ).getRGB()); + ColorUtils.setColor(theme.getBorderColor().getRGB()); + RenderUtil.drawRoundedOutline(x, y, 100, 18, 3, 1, theme.getBorderColor().getRGB()); + + if(!avatars.containsKey(Client.getInstance().getAccount().original_username)) { + avatars.put(Client.getInstance().getAccount().original_username, new MinecraftAvatar(Client.getInstance().getAccount().original_username)); + } + + if(!avatars.get(Client.getInstance().getAccount().original_username).initSkin) { + avatars.get(Client.getInstance().getAccount().original_username).loadSkin(); + } + + RenderUtil.drawImage(avatars.get(Client.getInstance().getAccount().original_username).imageLocation, x + 2, y + 2, 14, 14, false); + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/dropdown-icon.png"), x + 100 - 16, y + 2, 14, 14, false); + + Client.getInstance().getSilentFontRenderer().drawString(Client.getInstance().getAccount().original_username, x + 18, y + 9 - 6, 12, SilentFontRenderer.FontType.TITLE, 70); + + if(MouseUtils.isInside(mouseX, mouseY, x, y, 100, 18)) { + if (this.animatedOpacity < 75 && animateTimer.delay(30)) { + this.animatedOpacity += 15; + animateTimer.reset(); + } + } else { + if (this.animatedOpacity != 0 && animateTimer.delay(30)) { + this.animatedOpacity -= 15; + animateTimer.reset(); + } + } + + if(this.open) { + int accountY = y + 20; + RenderUtil.drawRoundedRect(x, y + 20, 100, (Client.getInstance().getAccountManager().getAccounts().size() - 1) * 18, 3, new Color(20, 20, 20).getRGB()); + for(AccountManager.AccountType account : Client.getInstance().getAccountManager().getAccounts()) { + if(Client.getInstance().getAccount().getUsername().equalsIgnoreCase(account.username)) { + continue; + } + if(!avatars.containsKey(account.username)) { + avatars.put(account.username, new MinecraftAvatar(account.username)); + } + + if(!avatars.get(account.username).initSkin) { + avatars.get(account.username).loadSkin(); + } + + if(MouseUtils.isInside(mouseX, mouseY, x, accountY, 100, 18)) { + RenderUtil.drawRoundedRect(x, accountY, 100, 18, 3, theme.getHoveredBackgroundColor(75).getRGB()); + } + + RenderUtil.drawImage(avatars.get(account.username).imageLocation, x + 2, accountY + 2, 14, 14, false); + Client.getInstance().getSilentFontRenderer().drawString(account.username, x + 18, accountY + 9 - 6, 12, SilentFontRenderer.FontType.TITLE, 70); + accountY += 18; + } + } + } + + public void onClick(Minecraft mc, int mouseX, int mouseY) { + if(MouseUtils.isInside(mouseX, mouseY, x, y, 100, 18)) { + this.open = !this.open; + (new Thread(() -> { + Client.getInstance().getAccountManager().updateAccounts(); + })).start(); + return; + } + + if(this.open) { + int accountY = y + 20; + int accountIndex = 0; + for(AccountManager.AccountType account : Client.getInstance().getAccountManager().getAccounts()) { + if(Client.getInstance().getAccount().getUsername().equalsIgnoreCase(account.username)) { + accountIndex += 1; + continue; + } + if(MouseUtils.isInside(mouseX, mouseY, x, accountY, 100, 18)) { + Client.getInstance().getAccountManager().setSelected(account, accountIndex, false); + break; + } + accountY += 18; + } + } + + this.open = false; + } + + public class MinecraftAvatar { + public ResourceLocation imageLocation = new ResourceLocation("silentclient/images/steve_head.png"); + public BufferedImage image = null; + public boolean initSkin = false; + private final String username; + + public MinecraftAvatar(String username) { + this.username = username; + } + + public void loadSkin() { + if(image == null && !LiteAccountPicker.loading && !initSkin) { + LiteAccountPicker.loading = true; + (new Thread("McAvatarThread") { + public void run() { + Client.logger.info(String.format("Downloading avatar %s...", username)); + BufferedImage avatar = SCTextureManager.getImage(String.format("https://mc-heads.net/avatar/%s/100.png", username)); + if(avatar != null) { + Client.logger.info(String.format("Avatar %s successfully downloaded!", username)); + image = avatar; + } else { + Client.logger.info(String.format("Avatar %s downloading failed!", username)); + initSkin = true; + } + LiteAccountPicker.loading = false; + } + }).start(); + } + if(image != null && !initSkin) { + Client.logger.info(String.format("Crating ResourceLocation of avatar %s...", username)); + imageLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("player_avatar_" + new Random().nextLong(), new DynamicTexture(image)); + initSkin = true; + } + } + } +} diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java index 31c72e0..6e1d499 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteMainMenu.java @@ -11,6 +11,7 @@ import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.font.SilentFontRenderer; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.silentmainmenu.MainMenuConcept; +import net.silentclient.client.gui.silentmainmenu.components.AccountPicker; import net.silentclient.client.gui.util.RenderUtil; import net.silentclient.client.utils.ColorUtils; @@ -21,19 +22,21 @@ import java.net.URI; public class LiteMainMenu extends GuiScreen { private SimpleAnimation bannerAnimation; + private AccountPicker accountPicker; @Override public void initGui() { super.initGui(); + this.accountPicker = new LiteAccountPicker(this.width - 100 - 4, 5); this.bannerAnimation = new SimpleAnimation(0); Client.backgroundPanorama.updateWidthHeight(this.width, this.height); this.buttonList.clear(); - this.buttonList.add(new IconButton(1, 4, 5, new ResourceLocation("silentclient/icons/news.png"))); - this.buttonList.add(new IconButton(2, 26, 5, new ResourceLocation("silentclient/icons/settings/cosmetics.png"))); - this.buttonList.add(new IconButton(3, 48, 5, new ResourceLocation("silentclient/icons/store_icon.png"))); - this.buttonList.add(new IconButton(4, 70, 5, new ResourceLocation("silentclient/icons/language.png"))); - this.buttonList.add(new IconButton(5, 92, 5, new ResourceLocation("silentclient/icons/back.png"))); + this.buttonList.add(new IconButton(1, 4, 5, 18, 18, 10, 10, new ResourceLocation("silentclient/icons/news.png"))); + this.buttonList.add(new IconButton(2, 24, 5, 18, 18, 10, 10, new ResourceLocation("silentclient/icons/settings/cosmetics.png"))); + this.buttonList.add(new IconButton(3, 44, 5, 18, 18, 10, 10, new ResourceLocation("silentclient/icons/store_icon.png"))); + this.buttonList.add(new IconButton(4, 64, 5, 18, 18, 10, 10, new ResourceLocation("silentclient/icons/language.png"))); + this.buttonList.add(new IconButton(5, 84, 5, 18, 18, 10, 10, new ResourceLocation("silentclient/icons/back.png"))); int buttonY = this.height / 2 - 18; @@ -69,13 +72,15 @@ public class LiteMainMenu extends GuiScreen if(GuiNews.imageLocation != null) { if(MouseUtils.isInside(mouseX, mouseY, this.width - 74, this.height - 42, 71, 40)) { - this.bannerAnimation.setAnimation(4, 12); + this.bannerAnimation.setAnimation(4, 20); } else { - this.bannerAnimation.setAnimation(0, 12); + this.bannerAnimation.setAnimation(0, 30); } RenderUtil.drawImage(GuiNews.imageLocation, this.width - 74 + (-this.bannerAnimation.getValue()), this.height - 42 + (-this.bannerAnimation.getValue()), 71, 40, false); } + accountPicker.draw(mc, mouseX, mouseY); + super.drawScreen(mouseX, mouseY, partialTicks); } @@ -133,6 +138,8 @@ public class LiteMainMenu extends GuiScreen err.printStackTrace(); } } + + accountPicker.onClick(mc, mouseX, mouseY); } @Override diff --git a/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java b/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java index e1b3bef..123f934 100644 --- a/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java +++ b/src/main/java/net/silentclient/client/gui/silentmainmenu/MainMenuConcept.java @@ -163,11 +163,16 @@ public class MainMenuConcept extends SilentScreen { // Functions private void loadSkin() { - if(image == null && !loading) { + if(image == null && !loading && !initSkin) { loading = true; (new Thread("SkinThread") { public void run() { - MainMenuConcept.image = SCTextureManager.getImage(String.format("https://mc-heads.net/body/%s/left/1000.png", Client.getInstance().getAccount().getUsername())); + BufferedImage skin = SCTextureManager.getImage(String.format("https://mc-heads.net/body/%s/left/1000.png", Client.getInstance().getAccount().getUsername())); + if(skin != null) { + MainMenuConcept.image = skin; + } else { + MainMenuConcept.initSkin = true; + } MainMenuConcept.loading = false; } }).start(); diff --git a/src/main/java/net/silentclient/client/gui/silentmainmenu/components/AccountPicker.java b/src/main/java/net/silentclient/client/gui/silentmainmenu/components/AccountPicker.java index 4e647d7..1dee7b9 100644 --- a/src/main/java/net/silentclient/client/gui/silentmainmenu/components/AccountPicker.java +++ b/src/main/java/net/silentclient/client/gui/silentmainmenu/components/AccountPicker.java @@ -10,9 +10,9 @@ import net.silentclient.client.utils.ColorUtils; import java.awt.*; public class AccountPicker { - private boolean open; - private final int x; - private final int y; + protected boolean open; + protected final int x; + protected final int y; public AccountPicker(int x, int y) { this.x = x; diff --git a/src/main/resources/assets/minecraft/silentclient/icons/dropdown-icon.png b/src/main/resources/assets/minecraft/silentclient/icons/dropdown-icon.png old mode 100755 new mode 100644 index 18c0ad0b47d64404b52ee2a450c9ea9be4924842..420b16d154dffe1c7ece49868edee6effac7f494 GIT binary patch literal 2088 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 literal 0 HcmV?d00001 From 6ec3475ed23e17a2bbf8f1c3c65ed39592dae61d Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 17:09:13 +0600 Subject: [PATCH 08/12] Better Buttons in Cosmetics --- .../client/cosmetics/gui/CosmeticsGui.java | 26 +++++++++---------- .../client/gui/lite/clickgui/ClickGUI.java | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java index 26b527e..74abeaa 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java @@ -61,32 +61,32 @@ public class CosmeticsGui extends SilentScreen { int height = addY * 2; int tabId = 1; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Capes", false, selectedCategory == "capes" ? new SelectedButtonTheme() : new DefaultButtonTheme())); - categoryOffsetY +=20; + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Capes", false, selectedCategory == "capes" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + categoryOffsetY +=23; tabId++; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Wings", false, selectedCategory == "wings" ? new SelectedButtonTheme() : new DefaultButtonTheme())); - categoryOffsetY +=20; + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Wings", false, selectedCategory == "wings" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + categoryOffsetY +=23; tabId++; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Bandanas", false, selectedCategory == "bandanas" ? new SelectedButtonTheme() : new DefaultButtonTheme())); - categoryOffsetY +=20; + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Bandanas", false, selectedCategory == "bandanas" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + categoryOffsetY +=23; tabId++; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Hats", false, selectedCategory == "hats" ? new SelectedButtonTheme() : new DefaultButtonTheme())); - categoryOffsetY +=20; + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Hats", false, selectedCategory == "hats" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + categoryOffsetY +=23; tabId++; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Shields", false, selectedCategory == "shields" ? new SelectedButtonTheme() : new DefaultButtonTheme())); - categoryOffsetY +=20; + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Shields", false, selectedCategory == "shields" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + categoryOffsetY +=23; tabId++; - this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 15, "Icons", false, selectedCategory == "icons" ? new SelectedButtonTheme() : new DefaultButtonTheme())); + this.buttonList.add(new Button(tabId, x + 5, y + categoryOffsetY, 75, 18, "Icons", false, selectedCategory == "icons" ? new SelectedButtonTheme() : new DefaultButtonTheme())); tabId++; - this.buttonList.add(new Button(tabId, x + 5, (y + height) - 26, 75, 20, "Store")); + this.buttonList.add(new Button(tabId, x + 5, (y + height) - 24, 75, 18, "Store")); - this.buttonList.add(new Button(88, x + 380 - 140, y + 220 - 22, 135, 20, "Outfits")); + this.buttonList.add(new Button(88, x + 380 - 140, (y + height) - 24, 135, 18, "Outfits")); } @Override diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java index 6eea58c..6eec14f 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java @@ -124,7 +124,7 @@ public class ClickGUI extends SilentScreen { if(selectedCategory != ModCategory.PLUS && selectedCategory != ModCategory.CONFIGS) { for(Mod m : getMods()) { - if(mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue()), y + 25, height - 25) || mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue() + 70), y + 25, height - 25)) { + if(mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue()), y, height - 25) || mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue() + 70), y, height - 25)) { float switchX = modOffsetX + ((65 / 2) - (15 / 2)); float switchY = y + modOffsetY - scrollAnimation.getValue() + 55; boolean switchHovered = selectedCategory.equals(ModCategory.MODS) && Switch.isHovered(mouseX, mouseY, switchX, switchY) && !headerHovered; From 2f1ae8155bad575ba94c122e2cfdd08022140d20 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 19:00:51 +0600 Subject: [PATCH 09/12] Update ClickGUI.java --- .../net/silentclient/client/gui/lite/clickgui/ClickGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java index 6eec14f..58b52a0 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java @@ -124,7 +124,7 @@ public class ClickGUI extends SilentScreen { if(selectedCategory != ModCategory.PLUS && selectedCategory != ModCategory.CONFIGS) { for(Mod m : getMods()) { - if(mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue()), y, height - 25) || mouseInContent(x, (int) (modOffsetY - scrollAnimation.getValue() + 70), y, height - 25)) { + if(mouseInContent(x, (int) (y + modOffsetY - scrollAnimation.getValue()), y + 25, height - 25) || mouseInContent(x, (int) (y + modOffsetY - scrollAnimation.getValue() + 70), y + 25, height - 25)) { float switchX = modOffsetX + ((65 / 2) - (15 / 2)); float switchY = y + modOffsetY - scrollAnimation.getValue() + 55; boolean switchHovered = selectedCategory.equals(ModCategory.MODS) && Switch.isHovered(mouseX, mouseY, switchX, switchY) && !headerHovered; From 42a1c727a676007c4c3b2fb7aea7500cbc97285e Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 19:48:44 +0600 Subject: [PATCH 10/12] New Blur --- .../client/gui/minecraft/GuiIngameMenu.java | 10 +-- .../client/gui/util/BlurUtil.java | 79 +++++++++++++++++++ .../client/mixin/ducks/MinecraftExt.java | 1 + .../client/mixin/mixins/MinecraftMixin.java | 8 ++ .../client/mixin/mixins/ShaderGroupMixin.java | 9 +++ .../client/mods/util/IMixinShaderGroup.java | 5 +- .../client/utils/MenuBlurUtils.java | 19 ++--- 7 files changed, 114 insertions(+), 17 deletions(-) create mode 100644 src/main/java/net/silentclient/client/gui/util/BlurUtil.java diff --git a/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java b/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java index 67f2a2a..067d0e7 100644 --- a/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java +++ b/src/main/java/net/silentclient/client/gui/minecraft/GuiIngameMenu.java @@ -1,6 +1,5 @@ package net.silentclient.client.gui.minecraft; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.*; import net.minecraft.client.gui.achievement.GuiAchievements; import net.minecraft.client.gui.achievement.GuiStats; @@ -21,7 +20,6 @@ import net.silentclient.client.gui.hud.Watermark; import net.silentclient.client.gui.lite.clickgui.ClickGUI; import net.silentclient.client.gui.modmenu.ModMenu; import net.silentclient.client.mods.ModCategory; -import net.silentclient.client.mods.settings.GeneralMod; import net.silentclient.client.utils.MenuBlurUtils; import java.io.IOException; @@ -34,7 +32,7 @@ public class GuiIngameMenu extends GuiScreen */ public void initGui() { - MenuBlurUtils.loadBlur(); +// MenuBlurUtils.loadBlur(); this.buttonList.clear(); int i = -16; this.buttonList.add(new Button(1, this.width / 2 - 100, this.height / 4 + 120 + i, "Save and Quit to Title", true)); @@ -167,9 +165,9 @@ public class GuiIngameMenu extends GuiScreen @Override public void onGuiClosed() { - if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { - Minecraft.getMinecraft().entityRenderer.loadEntityShader(null); - } +// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { +// Minecraft.getMinecraft().entityRenderer.loadEntityShader(null); +// } super.onGuiClosed(); } } diff --git a/src/main/java/net/silentclient/client/gui/util/BlurUtil.java b/src/main/java/net/silentclient/client/gui/util/BlurUtil.java new file mode 100644 index 0000000..36c7f01 --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/util/BlurUtil.java @@ -0,0 +1,79 @@ +package net.silentclient.client.gui.util; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.ShaderGroup; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Timer; +import net.silentclient.client.mixin.ducks.MinecraftExt; +import net.silentclient.client.mods.util.IMixinShaderGroup; +import org.lwjgl.opengl.GL11; + +public class BlurUtil { + private static int lastScale; + + private static int lastScaleWidth; + + private static int lastScaleHeight; + + private static Framebuffer buffer; + + private static ShaderGroup blurShader; + + + private static final ResourceLocation shader = new ResourceLocation("shaders/post/menu_blur.json"); + + public static void initFboAndShader() { + Minecraft mc = Minecraft.getMinecraft(); + try { + blurShader = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), shader); + blurShader.createBindFramebuffers(mc.displayWidth, mc.displayHeight); + buffer = (Framebuffer) ((IMixinShaderGroup) blurShader).getMainFramebuffer(); + } catch (Exception e) { + e.printStackTrace(); + } + } + public static void crop(float x, float y, float x2, float y2) { + Minecraft mc = Minecraft.getMinecraft(); + ScaledResolution scaledResolution = new ScaledResolution(mc); + int factor = scaledResolution.getScaleFactor(); + GL11.glScissor((int)(x * factor), (int)((scaledResolution.getScaledHeight() - y2) * factor), (int)((x2 - x) * factor), (int)((y2 - y) * factor)); + } + + public static void blur(float x, float y, float x2, float y2, ScaledResolution sr){ + Minecraft mc = Minecraft.getMinecraft(); + + int factor = sr.getScaleFactor(); + int factor2 = sr.getScaledWidth(); + int factor3 = sr.getScaledHeight(); + if (lastScale != factor || lastScaleWidth != factor2 || lastScaleHeight != factor3 || buffer == null || blurShader == null) + initFboAndShader(); + lastScale = factor; + lastScaleWidth = factor2; + lastScaleHeight = factor3; + GL11.glEnable(3089); + crop(x, y, x2, y2); + buffer.framebufferHeight = mc.displayHeight; + buffer.framebufferWidth = mc.displayWidth; + GlStateManager.resetColor(); + blurShader.loadShaderGroup(((Timer) ((MinecraftExt) mc).getTimer()).renderPartialTicks); + buffer.bindFramebuffer(true); + mc.getFramebuffer().bindFramebuffer(true); + GL11.glDisable(3089); + } + + public static void blur(float x, float y, float x2, float y2) { + Minecraft mc = Minecraft.getMinecraft(); + GlStateManager.disableAlpha(); + blur(x, y, x2, y2, new ScaledResolution(mc)); + GlStateManager.enableAlpha(); + } + public static void blur2(float x, float y, float x2, float y2, float h, float w) { + Minecraft mc = Minecraft.getMinecraft(); + GlStateManager.disableAlpha(); + blur(x, y, x2 + w, y2 + h, new ScaledResolution(mc)); + GlStateManager.enableAlpha(); + } +} \ No newline at end of file diff --git a/src/main/java/net/silentclient/client/mixin/ducks/MinecraftExt.java b/src/main/java/net/silentclient/client/mixin/ducks/MinecraftExt.java index e5948d9..79fb7c8 100644 --- a/src/main/java/net/silentclient/client/mixin/ducks/MinecraftExt.java +++ b/src/main/java/net/silentclient/client/mixin/ducks/MinecraftExt.java @@ -2,4 +2,5 @@ package net.silentclient.client.mixin.ducks; public interface MinecraftExt { void setSession(Object session); + Object getTimer(); } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/MinecraftMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/MinecraftMixin.java index 2f97dfe..4891ef2 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/MinecraftMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/MinecraftMixin.java @@ -16,6 +16,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.util.IChatComponent; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Session; +import net.minecraft.util.Timer; import net.minecraft.world.WorldSettings; import net.silentclient.client.Client; import net.silentclient.client.event.impl.*; @@ -128,6 +129,8 @@ public abstract class MinecraftMixin implements MinecraftExt { @Mutable @Shadow @Final private Session session; + @Shadow private Timer timer; + @Inject(method = "displayGuiScreen", at = @At("RETURN"), cancellable = true) public void displayGuiScreenInject(GuiScreen guiScreenIn, CallbackInfo ci) { if(Client.backgroundPanorama == null) { @@ -317,4 +320,9 @@ public abstract class MinecraftMixin implements MinecraftExt { return this.theWorld == null && this.currentScreen != null ? 30 : this.gameSettings.limitFramerate; } + + @Override + public Object getTimer() { + return this.timer; + } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/ShaderGroupMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/ShaderGroupMixin.java index b999e53..f237052 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/ShaderGroupMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/ShaderGroupMixin.java @@ -1,16 +1,25 @@ package net.silentclient.client.mixin.mixins; +import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.Shader; import net.minecraft.client.shader.ShaderGroup; import net.silentclient.client.mods.util.IMixinShaderGroup; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.gen.Accessor; import java.util.List; @Mixin(ShaderGroup.class) public abstract class ShaderGroupMixin implements IMixinShaderGroup { + @Shadow private Framebuffer mainFramebuffer; + @Override @Accessor public abstract List getListShaders(); + + @Override + public Object getMainFramebuffer() { + return this.mainFramebuffer; + } } diff --git a/src/main/java/net/silentclient/client/mods/util/IMixinShaderGroup.java b/src/main/java/net/silentclient/client/mods/util/IMixinShaderGroup.java index cb78c22..b96326b 100644 --- a/src/main/java/net/silentclient/client/mods/util/IMixinShaderGroup.java +++ b/src/main/java/net/silentclient/client/mods/util/IMixinShaderGroup.java @@ -1,9 +1,10 @@ package net.silentclient.client.mods.util; -import java.util.List; - import net.minecraft.client.shader.Shader; +import java.util.List; + public interface IMixinShaderGroup { List getListShaders(); + Object getMainFramebuffer(); } diff --git a/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java b/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java index e7acd94..a9c1121 100644 --- a/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java +++ b/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java @@ -1,11 +1,9 @@ package net.silentclient.client.utils; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.silentclient.client.Client; -import net.silentclient.client.cosmetics.StaticResourceLocation; +import net.silentclient.client.gui.util.BlurUtil; import net.silentclient.client.mixin.accessors.GuiAccessor; -import net.silentclient.client.mixin.ducks.EntityRendererExt; import net.silentclient.client.mods.settings.GeneralMod; import java.awt.*; @@ -16,12 +14,15 @@ public class MenuBlurUtils { } public static void loadBlur(boolean force) { - if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) { - ((EntityRendererExt) Minecraft.getMinecraft().entityRenderer).silent$loadShader(new StaticResourceLocation("shaders/post/menu_blur.json")); - } +// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) { +// ((EntityRendererExt) Minecraft.getMinecraft().entityRenderer).silent$loadShader(new StaticResourceLocation("shaders/post/menu_blur.json")); +// } } public static void renderBackground(GuiScreen instance) { + if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { + BlurUtil.blur2(0, 0, 1920, 1080, 0, 0); + } if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() && !Client.getInstance().getGlobalSettings().isLite()) { ((GuiAccessor) instance).silent$drawGradientRect(0, 0, instance.width, instance.height, new Color(0, 0, 0, 0).getRGB(), new Color(0, 0, 0, 0).getRGB()); } else { @@ -34,8 +35,8 @@ public class MenuBlurUtils { } public static void unloadBlur(boolean force) { - if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) { - Minecraft.getMinecraft().entityRenderer.loadEntityShader(null); - } +// if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() || force) { +// Minecraft.getMinecraft().entityRenderer.loadEntityShader(null); +// } } } From de9212fdab3a105b117f965a65f0016e0af6a26d Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 19:52:15 +0600 Subject: [PATCH 11/12] Update MenuBlurUtils.java --- src/main/java/net/silentclient/client/utils/MenuBlurUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java b/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java index a9c1121..7eee68c 100644 --- a/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java +++ b/src/main/java/net/silentclient/client/utils/MenuBlurUtils.java @@ -22,8 +22,6 @@ public class MenuBlurUtils { public static void renderBackground(GuiScreen instance) { if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) { BlurUtil.blur2(0, 0, 1920, 1080, 0, 0); - } - if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean() && !Client.getInstance().getGlobalSettings().isLite()) { ((GuiAccessor) instance).silent$drawGradientRect(0, 0, instance.width, instance.height, new Color(0, 0, 0, 0).getRGB(), new Color(0, 0, 0, 0).getRGB()); } else { instance.drawDefaultBackground(); From f7daefc9c2ff3ad0734942a0ed295703fe5f18df Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Sun, 6 Aug 2023 20:01:53 +0600 Subject: [PATCH 12/12] Fix --- .../net/silentclient/client/gui/util/BlurUtil.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/net/silentclient/client/gui/util/BlurUtil.java b/src/main/java/net/silentclient/client/gui/util/BlurUtil.java index 36c7f01..3e2c54e 100644 --- a/src/main/java/net/silentclient/client/gui/util/BlurUtil.java +++ b/src/main/java/net/silentclient/client/gui/util/BlurUtil.java @@ -3,10 +3,13 @@ package net.silentclient.client.gui.util; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.settings.GameSettings; import net.minecraft.client.shader.Framebuffer; import net.minecraft.client.shader.ShaderGroup; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Timer; +import net.silentclient.client.Client; +import net.silentclient.client.mixin.SilentClientTweaker; import net.silentclient.client.mixin.ducks.MinecraftExt; import net.silentclient.client.mods.util.IMixinShaderGroup; import org.lwjgl.opengl.GL11; @@ -43,6 +46,13 @@ public class BlurUtil { } public static void blur(float x, float y, float x2, float y2, ScaledResolution sr){ + try { + if(SilentClientTweaker.hasOptifine && GameSettings.class.getDeclaredField("ofFastRender").getBoolean("ofFastRender")) { + return; + } + } catch (Exception err) { + Client.logger.catching(err); + } Minecraft mc = Minecraft.getMinecraft(); int factor = sr.getScaleFactor();