From 387e9ac10a1167ad30049b31150ddf3e85ec5237 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Tue, 25 Jul 2023 15:40:25 +0600 Subject: [PATCH] Outfits --- .../java/net/silentclient/client/Client.java | 22 +- .../client/admin/AdminRender.java | 2 +- .../client/config/ConfigManager.java | 11 +- .../client/cosmetics/Cosmetics.java | 3 + .../client/cosmetics/Outfits.java | 109 +++++++++ .../client/cosmetics/gui/CosmeticsGui.java | 9 +- .../client/cosmetics/gui/NewOutfitModal.java | 128 +++++++++++ .../client/cosmetics/gui/OutfitsGui.java | 216 ++++++++++++++++++ .../silentclient/client/gui/UserTutorial.java | 2 +- .../client/gui/lite/clickgui/ClickGUI.java | 2 +- .../client/gui/modmenu/ModMenu.java | 2 +- .../silentclient/client/utils/FileUtils.java | 17 ++ .../client/utils/types/GlobalSettings.java | 1 + 13 files changed, 506 insertions(+), 18 deletions(-) create mode 100644 src/main/java/net/silentclient/client/cosmetics/Outfits.java create mode 100644 src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java create mode 100644 src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index 4ce6693..6eecee6 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -60,7 +60,7 @@ public class Client { private BuildData buildData = new BuildData(); private UserData userData = new UserData(); - public File dir; + public File configDir; private SettingsManager settingsManager; public ConfigManager configManager; private ModInstances modInstances; @@ -158,9 +158,9 @@ public class Client { this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting() .enableComplexMapKeySerialization().create(); logger.info("INITIALISING > silent-directory"); - dir = new File(Minecraft.getMinecraft().mcDataDir, "SilentClient"); - if (!dir.exists()) { - dir.mkdirs(); + configDir = new File(Minecraft.getMinecraft().mcDataDir, "SilentClient-Configs"); + if (!configDir.exists()) { + configDir.mkdirs(); } globalSettingsFile = new File(Minecraft.getMinecraft().mcDataDir, "silent_settings.json"); if(!globalSettingsFile.exists()) { @@ -208,9 +208,8 @@ public class Client { content.append(inputLine); } - globalSettings.setConfig(new JSONObject(content.toString()).getString("config")); - globalSettings.setLite(new JSONObject(content.toString()).getBoolean("lite")); - globalSettings.setDisplayedTutorial(new JSONObject(content.toString()).getBoolean("displayedTutorial")); + globalSettings = gson.fromJson(content.toString(), GlobalSettings.class); + Client.getInstance().updateWindowTitle(); in.close(); } catch (Exception err) { Client.logger.catching(err); @@ -218,6 +217,15 @@ public class Client { globalSettings.save(); Client.getInstance().updateWindowTitle(); + if(!globalSettings.configsMigrated && new File(Minecraft.getMinecraft().mcDataDir, "SilentClient").exists() && new File(Minecraft.getMinecraft().mcDataDir, "SilentClient").isDirectory()) { + logger.info("STARTING > migrating-configs"); + for(String file : new File(Minecraft.getMinecraft().mcDataDir, "SilentClient").list()) { + Client.logger.info("STARTING > migrating-configs > " + file); + FileUtils.copyFile(new File(Minecraft.getMinecraft().mcDataDir, "SilentClient/" + file), new File(Minecraft.getMinecraft().mcDataDir, "SilentClient-Configs/" + file)); + } + globalSettings.configsMigrated = true; + globalSettings.save(); + } logger.info("STARTING > config-manager"); configManager = new ConfigManager(); logger.info("STARTING > texture-manager"); diff --git a/src/main/java/net/silentclient/client/admin/AdminRender.java b/src/main/java/net/silentclient/client/admin/AdminRender.java index 7b39443..62382a6 100644 --- a/src/main/java/net/silentclient/client/admin/AdminRender.java +++ b/src/main/java/net/silentclient/client/admin/AdminRender.java @@ -31,7 +31,7 @@ import net.silentclient.client.utils.FileUtils; import net.silentclient.client.utils.Players; public class AdminRender extends GuiScreen { - public static File adminRenderPath = new File(Client.getInstance().dir, "admin-render"); + public static File adminRenderPath = new File(Client.getInstance().configDir, "admin-render"); // Settings private boolean showSettings = false; diff --git a/src/main/java/net/silentclient/client/config/ConfigManager.java b/src/main/java/net/silentclient/client/config/ConfigManager.java index e591874..a14fe87 100644 --- a/src/main/java/net/silentclient/client/config/ConfigManager.java +++ b/src/main/java/net/silentclient/client/config/ConfigManager.java @@ -12,7 +12,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.gui.notification.NotificationManager; @@ -31,7 +30,7 @@ public final class ConfigManager { updateConfigs(); String config = Client.getInstance().getGlobalSettings().getConfig(); - configFile = new File(Client.getInstance().dir, config); + configFile = new File(Client.getInstance().configDir, config); if(!configFile.exists()) { @@ -51,7 +50,7 @@ public final class ConfigManager { public void updateConfigs() { Client.logger.info("Updating Config List"); - this.configs = Stream.of(Client.getInstance().dir.listFiles()) + this.configs = Stream.of(Client.getInstance().configDir.listFiles()) .filter(file -> !file.isDirectory()) .map(File::getName) .collect(Collectors.toSet()); @@ -59,7 +58,7 @@ public final class ConfigManager { public void deleteConfig(String name) { try { - new File(Client.getInstance().dir, name).delete(); + new File(Client.getInstance().configDir, name).delete(); } catch (Exception err) { err.printStackTrace(); } @@ -69,7 +68,7 @@ public final class ConfigManager { public void loadConfig(String name) { Client.logger.info("Loading Config: " + name); Client.getInstance().getGlobalSettings().setConfig(name); - configFile = new File(Client.getInstance().dir, name); + configFile = new File(Client.getInstance().configDir, name); if(!configFile.exists()) { try { configFile.createNewFile(); @@ -91,7 +90,7 @@ public final class ConfigManager { public String newConfig(String name, boolean clone) { Client.logger.info("Creating Config: " + name); - File testConfig = new File(Client.getInstance().dir, name); + File testConfig = new File(Client.getInstance().configDir, name); if(testConfig.exists()) { Client.logger.info("Creating Config Error: Config already exists."); return "Config already exists."; diff --git a/src/main/java/net/silentclient/client/cosmetics/Cosmetics.java b/src/main/java/net/silentclient/client/cosmetics/Cosmetics.java index 40a0840..c1f8b50 100644 --- a/src/main/java/net/silentclient/client/cosmetics/Cosmetics.java +++ b/src/main/java/net/silentclient/client/cosmetics/Cosmetics.java @@ -131,6 +131,9 @@ public class Cosmetics { }); } } + + Client.logger.info("STARTING > cosmeitcs > outfits"); + Outfits.loadOutfits(); } update(false); diff --git a/src/main/java/net/silentclient/client/cosmetics/Outfits.java b/src/main/java/net/silentclient/client/cosmetics/Outfits.java new file mode 100644 index 0000000..1498f89 --- /dev/null +++ b/src/main/java/net/silentclient/client/cosmetics/Outfits.java @@ -0,0 +1,109 @@ +package net.silentclient.client.cosmetics; + +import net.minecraft.client.Minecraft; +import net.silentclient.client.Client; +import net.silentclient.client.utils.Requests; + +import java.io.*; +import java.util.ArrayList; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class Outfits { + public static File outfitsDir; + public static ArrayList outfits = new ArrayList<>(); + + public static void loadOutfits() { + outfits.clear(); + if(outfitsDir == null) { + outfitsDir = new File(Minecraft.getMinecraft().mcDataDir, "SilentClient-Cosmetic-Outfits"); + } + if(!outfitsDir.exists()) { + outfitsDir.mkdirs(); + } + Set outfitsNames = Stream.of(outfitsDir.listFiles()) + .filter(file -> !file.isDirectory()) + .map(File::getName) + .collect(Collectors.toSet()); + outfitsNames.forEach((name) -> { + Client.logger.info("Loading Cosmetic Outfit: " + name); + try { + InputStream in = new FileInputStream(new File(outfitsDir, name)); + BufferedReader reader = new BufferedReader(new InputStreamReader(in)); + StringBuffer content = new StringBuffer(); + String inputLine; + while ((inputLine = reader.readLine()) != null) { + content.append(inputLine); + } + outfits.add(Client.getInstance().getGson().fromJson(content.toString(), Outfit.class)); + in.close(); + } catch (Exception err) { + Client.logger.catching(err); + } + }); + } + + public static void createOutfit(Outfit outfit) { + Client.logger.info("Creating Outfit: " + outfit.name); + try { + File outfitFile = new File(outfitsDir, outfit.name + ".json"); + + if(!outfitFile.exists()) { + outfitFile.createNewFile(); + } + + FileOutputStream outputStream = new FileOutputStream(outfitFile); + byte[] strToBytes = Client.getInstance().getGson().toJson(outfit).getBytes(); + outputStream.write(strToBytes); + + outputStream.close(); + outfits.add(outfit); + } catch (Exception err) { + Client.logger.catching(err); + } + } + + public static void loadOutfit(Outfit outfit) { + Client.logger.info("Loading Outfit: " + outfit.name); + Requests.post("https://api.silentclient.net/account/load_outfit", Client.getInstance().getGson().toJson(outfit)); + Client.getInstance().updateUserInformation(); + } + + public static ArrayList getOutfits() { + return outfits; + } + + public static void deleteOutfit(Outfit outfit) { + outfits.remove(outfit); + try { + new File(outfitsDir, outfit.name + ".json").delete(); + } catch (Exception err) { + Client.logger.catching(err); + } + } + + public static class Outfit { + public final String name; + public final int selected_cape; + public final int selected_wings; + public final int selected_icon; + public final int selected_bandana; + public final int selected_hat; + public final int selected_neck; + public final int selected_mask; + public final int selected_shield; + + public Outfit(String name, int selected_cape, int selected_wings, int selected_icon, int selected_bandana, int selected_hat, int selected_neck, int selected_mask, int selected_shield) { + this.name = name; + this.selected_cape = selected_cape; + this.selected_wings = selected_wings; + this.selected_icon = selected_icon; + this.selected_bandana = selected_bandana; + this.selected_hat = selected_hat; + this.selected_neck = selected_neck; + this.selected_mask = selected_mask; + this.selected_shield = selected_shield; + } + } +} 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 77fe209..39a9579 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/CosmeticsGui.java @@ -45,11 +45,12 @@ public class CosmeticsGui extends SilentScreen { rotate = 144; if(mc.thePlayer == null) { Client.backgroundPanorama.updateWidthHeight(this.width, this.height); + } else { + MenuBlurUtils.loadBlur(); } this.silentInputs.add(new Input("Search")); CosmeticsGui.scrollY = 0; CosmeticsGui.selectedCategory = "capes"; - MenuBlurUtils.loadBlur(); Client.getInstance().updateUserInformation(); int categoryOffsetY = 25; int addX = 190; @@ -84,6 +85,8 @@ public class CosmeticsGui extends SilentScreen { tabId++; this.buttonList.add(new Button(tabId, x + 5, (y + height) - 26, 75, 20, "Store")); + + this.buttonList.add(new Button(88, x + 380 - 140, y + 220 - 22, 135, 20, "Outfits")); } @Override @@ -173,6 +176,10 @@ public class CosmeticsGui extends SilentScreen { err.printStackTrace(); } } + + if(button.id == 88) { + mc.displayGuiScreen(new OutfitsGui(this)); + } } private ArrayList getItems() { diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java new file mode 100644 index 0000000..7eade9d --- /dev/null +++ b/src/main/java/net/silentclient/client/cosmetics/gui/NewOutfitModal.java @@ -0,0 +1,128 @@ +package net.silentclient.client.cosmetics.gui; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.silentclient.client.Client; +import net.silentclient.client.cosmetics.Outfits; +import net.silentclient.client.gui.SilentScreen; +import net.silentclient.client.gui.elements.Button; +import net.silentclient.client.gui.elements.IconButton; +import net.silentclient.client.gui.elements.Input; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; +import net.silentclient.client.gui.theme.Theme; +import net.silentclient.client.utils.MenuBlurUtils; +import net.silentclient.client.utils.NotificationUtils; +import org.lwjgl.input.Keyboard; + +import java.io.IOException; + +public class NewOutfitModal extends SilentScreen { + private final GuiScreen parentScreen; + private int modalWidth; + private int modalHeight; + + public NewOutfitModal(GuiScreen parentScreen) { + this.parentScreen = parentScreen; + this.modalWidth = 200; + this.modalHeight = 90; + } + + @Override + public void initGui() { + if(mc.thePlayer == null) { + Client.backgroundPanorama.updateWidthHeight(this.width, this.height); + } else { + MenuBlurUtils.loadBlur(); + } + int x = width / 2 - (this.modalWidth / 2); + int y = height / 2 - (this.modalHeight / 2); + this.buttonList.add(new IconButton(1, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png"))); + this.buttonList.add(new Button(2, x + 3, y + this.modalHeight - 23, this.modalWidth - 6, 20, "Done")); + this.silentInputs.add(new Input("Outfit Name")); + if(mc.thePlayer == null) { + Client.backgroundPanorama.updateWidthHeight(this.width, this.height); + } + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + switch (button.id) { + case 1: + mc.displayGuiScreen(parentScreen); + break; + case 2: + if(this.silentInputs.get(0).getValue().trim().length() == 0) { + NotificationUtils.showNotification("Error", "Please enter a Outfit Name"); + break; + } + if(Outfits.getOutfits().stream().filter((c) -> c.name.equals(this.silentInputs.get(0).getValue().trim())).findAny().isPresent()) { + NotificationUtils.showNotification("Error", "Outfit already exists."); + break; + } + Outfits.createOutfit(new Outfits.Outfit(this.silentInputs.get(0).getValue(), Client.getInstance().getAccount().selected_cape, Client.getInstance().getAccount().selected_wings, Client.getInstance().getAccount().selected_icon, Client.getInstance().getAccount().selected_bandana, Client.getInstance().getAccount().selected_hat, Client.getInstance().getAccount().selected_neck, Client.getInstance().getAccount().selected_mask, Client.getInstance().getAccount().selected_shield)); + mc.displayGuiScreen(parentScreen); + break; + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + if(mc.thePlayer == null) { + Client.backgroundPanorama.tickPanorama(); + } + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + if(mc.thePlayer == null) { + GlStateManager.disableAlpha(); + Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); + GlStateManager.enableAlpha(); + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } else { + MenuBlurUtils.renderBackground(this); + } + GlStateManager.pushMatrix(); + int x = width / 2 - (this.modalWidth / 2); + int y = height / 2 - (this.modalHeight / 2); + + // 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); + + // Content + this.silentInputs.get(0).render(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6); + + super.drawScreen(mouseX, mouseY, partialTicks); + + GlStateManager.popMatrix(); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + int x = width / 2 - (this.modalWidth / 2); + int y = height / 2 - (this.modalHeight / 2); + this.silentInputs.get(0).onClick(mouseX, mouseY, x + 3, y + 23, this.modalWidth - 6); + } + + @Override + public void onGuiClosed() { + MenuBlurUtils.unloadBlur(); + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (keyCode == Keyboard.KEY_ESCAPE) { + mc.displayGuiScreen(parentScreen); + return; + }; + + this.silentInputs.get(0).onKeyTyped(typedChar, keyCode); + } +} diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java new file mode 100644 index 0000000..8ba2013 --- /dev/null +++ b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java @@ -0,0 +1,216 @@ +package net.silentclient.client.cosmetics.gui; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.silentclient.client.Client; +import net.silentclient.client.cosmetics.Outfits; +import net.silentclient.client.gui.SilentScreen; +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.theme.Theme; +import net.silentclient.client.gui.util.RenderUtil; +import net.silentclient.client.utils.MenuBlurUtils; +import net.silentclient.client.utils.types.PlayerResponse; +import org.lwjgl.input.Keyboard; + +import java.awt.*; +import java.io.IOException; + +public class OutfitsGui extends SilentScreen { + private final GuiScreen parentScreen; + + public OutfitsGui(GuiScreen parentScreen) { + this.parentScreen = parentScreen; + } + + + @Override + public void initGui() { + super.initGui(); + if(mc.thePlayer == null) { + Client.backgroundPanorama.updateWidthHeight(this.width, this.height); + } else { + MenuBlurUtils.loadBlur(); + } + int width = 250; + int x = this.width / 2 - 125; + int y = this.height / 2 - 100; + this.buttonList.add(new IconButton(0, x + width - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png"))); + } + + @Override + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + if(mc.thePlayer == null) { + GlStateManager.disableAlpha(); + Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks); + GlStateManager.enableAlpha(); + this.drawGradientRect(0, 0, this.width, this.height, 0, Integer.MIN_VALUE); + } else { + MenuBlurUtils.renderBackground(this); + } + int width = 250; + int height = 200; + int x = this.width / 2 - 125; + int y = this.height / 2 - 100; + RenderUtil.drawRoundedRect(x, y, width, height, 4, Theme.backgroundColor().getRGB()); + Client.getInstance().getSilentFontRenderer().drawString(x + 3, y + 3, "Outfits", 14, SilentFontRenderer.FontType.TITLE); + super.drawScreen(mouseX, mouseY, partialTicks); + int outfitX = x + 3; + int outfitY = y + 20; + int outfitIndex = 0; + boolean isCreateHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80); + if(isCreateHovered) { + RenderUtil.drawRoundedRect(outfitX, outfitY, 80, 80, 3, new Color(255, 255, 255, 30).getRGB()); + } + RenderUtil.drawRoundedOutline(outfitX, outfitY, 80, 80, 3, 1, Theme.borderColor().getRGB()); + Client.getInstance().getSilentFontRenderer().drawCenteredString("Create New Outfit", outfitX + 40, outfitY + 40 - 6, 12, SilentFontRenderer.FontType.TITLE); + outfitX += 83; + outfitIndex += 1; + for(Outfits.Outfit outfit : Outfits.getOutfits()) { + boolean isHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80) && !MouseUtils.isInside(mouseX, mouseY, outfitX + 80 - 3 - 10, outfitY + 3, 10, 10); + if(isHovered) { + RenderUtil.drawRoundedRect(outfitX, outfitY, 80, 80, 3, new Color(255, 255, 255, 30).getRGB()); + } + RenderUtil.drawRoundedOutline(outfitX, outfitY, 80, 80, 3, 1, Theme.borderColor().getRGB()); + Client.getInstance().getSilentFontRenderer().drawString(outfit.name, outfitX + 3, outfitY + 3, 12, SilentFontRenderer.FontType.TITLE, 64); + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/trash-icon.png"), outfitX + 80 - 3 - 10, outfitY + 3, 10, 10); + + int cosmeticY = outfitY + 18; + + if(outfit.selected_cape != 0 && Client.getInstance().getCosmetics().getMyCapes().stream().filter((c) -> c.id == outfit.selected_cape).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyCapes().stream().filter((c) -> c.id == outfit.selected_cape).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_wings != 0 && Client.getInstance().getCosmetics().getMyWings().stream().filter((c) -> c.id == outfit.selected_wings).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyWings().stream().filter((c) -> c.id == outfit.selected_wings).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_bandana != 0 && Client.getInstance().getCosmetics().getMyBandanas().stream().filter((c) -> c.id == outfit.selected_bandana).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyBandanas().stream().filter((c) -> c.id == outfit.selected_bandana).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_hat != 0 && Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_hat).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_hat).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_neck != 0 && Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_neck).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_neck).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_mask != 0 && Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_mask).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyHats().stream().filter((c) -> c.id == outfit.selected_mask).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_shield != 0 && Client.getInstance().getCosmetics().getMyShields().stream().filter((c) -> c.id == outfit.selected_shield).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyShields().stream().filter((c) -> c.id == outfit.selected_shield).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + cosmeticY += 10; + } + + if(outfit.selected_icon != 0 && Client.getInstance().getCosmetics().getMyIcons().stream().filter((c) -> c.id == outfit.selected_icon).findFirst().isPresent()) { + PlayerResponse.Account.Cosmetics.CosmeticItem item = Client.getInstance().getCosmetics().getMyIcons().stream().filter((c) -> c.id == outfit.selected_icon).findFirst().get(); + + Client.getInstance().getSilentFontRenderer().drawString(item.name, outfitX + 3, cosmeticY, 10, SilentFontRenderer.FontType.TITLE, 75); + } + + outfitIndex += 1; + if(outfitIndex == 3) { + outfitIndex = 0; + outfitY += 85; + } else { + outfitX += 83; + } + } + } + + @Override + protected void actionPerformed(GuiButton button) throws IOException { + super.actionPerformed(button); + if(button.id == 0) { + mc.displayGuiScreen(parentScreen); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + int width = 250; + int height = 200; + int x = this.width / 2 - 125; + int y = this.height / 2 - 100; + int outfitX = x + 3; + int outfitY = y + 20; + int outfitIndex = 0; + if(MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80)) { + mc.displayGuiScreen(new NewOutfitModal(this)); + return; + } + outfitX += 83; + outfitIndex += 1; + for(Outfits.Outfit outfit : Outfits.getOutfits()) { + boolean isHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80) && !MouseUtils.isInside(mouseX, mouseY, outfitX + 80 - 3 - 10, outfitY + 3, 10, 10); + + if(isHovered) { + Outfits.loadOutfit(outfit); + mc.displayGuiScreen(parentScreen); + break; + } + + if(MouseUtils.isInside(mouseX, mouseY, outfitX + 80 - 3 - 10, outfitY + 3, 10, 10)) { + Outfits.deleteOutfit(outfit); + break; + } + + outfitIndex += 1; + if(outfitIndex == 3) { + outfitIndex = 0; + outfitY += 85; + } else { + outfitX += 83; + } + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + if(mc.thePlayer == null) { + Client.backgroundPanorama.tickPanorama(); + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (keyCode == Keyboard.KEY_ESCAPE) { + mc.displayGuiScreen(parentScreen); + } + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + MenuBlurUtils.unloadBlur(); + } +} diff --git a/src/main/java/net/silentclient/client/gui/UserTutorial.java b/src/main/java/net/silentclient/client/gui/UserTutorial.java index 214ec12..842fea4 100644 --- a/src/main/java/net/silentclient/client/gui/UserTutorial.java +++ b/src/main/java/net/silentclient/client/gui/UserTutorial.java @@ -109,7 +109,7 @@ public class UserTutorial extends SilentScreen { break; case 3: try { - FileUtils.exportResource(String.format("/assets/minecraft/silentclient/configs/%s.txt", this.configs.get(configIndex)), String.format(Client.getInstance().dir.toString() + "/%s (Preset).txt", this.configs.get(configIndex))); + FileUtils.exportResource(String.format("/assets/minecraft/silentclient/configs/%s.txt", this.configs.get(configIndex)), String.format(Client.getInstance().configDir.toString() + "/%s (Preset).txt", this.configs.get(configIndex))); Client.getInstance().getConfigManager().loadConfig(String.format("%s (Preset).txt", this.configs.get(configIndex))); } catch (Exception e) { Client.logger.catching(e); 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 e3b37b1..6eea58c 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 @@ -365,7 +365,7 @@ public class ClickGUI extends SilentScreen { if(MouseUtils.isInside(mouseX, mouseY,x + 100 + (column == 1 ? 0 : 140), y + modOffsetY - scrollAnimation.getValue(), 135, 28) && mouseButton == 0) { Sounds.playButtonSound(); - File file1 = Client.getInstance().dir; + File file1 = Client.getInstance().configDir; String s = file1.getAbsolutePath(); if (Util.getOSType() == Util.EnumOS.OSX) { diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java index 02c5264..c9cda31 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java @@ -290,7 +290,7 @@ public class ModMenu extends SilentScreen { mc.displayGuiScreen(new AddConfigModal(this)); break; case 6: - File file1 = Client.getInstance().dir; + File file1 = Client.getInstance().configDir; String s = file1.getAbsolutePath(); if (Util.getOSType() == Util.EnumOS.OSX) { diff --git a/src/main/java/net/silentclient/client/utils/FileUtils.java b/src/main/java/net/silentclient/client/utils/FileUtils.java index 499b547..891ee4b 100644 --- a/src/main/java/net/silentclient/client/utils/FileUtils.java +++ b/src/main/java/net/silentclient/client/utils/FileUtils.java @@ -62,4 +62,21 @@ public class FileUtils { resStreamOut.close(); } } + + public static void copyFile(File source, File dest) throws IOException { + InputStream is = null; + OutputStream os = null; + try { + is = new FileInputStream(source); + os = new FileOutputStream(dest); + byte[] buffer = new byte[1024]; + int length; + while ((length = is.read(buffer)) > 0) { + os.write(buffer, 0, length); + } + } finally { + is.close(); + os.close(); + } + } } diff --git a/src/main/java/net/silentclient/client/utils/types/GlobalSettings.java b/src/main/java/net/silentclient/client/utils/types/GlobalSettings.java index 5fad56f..6b084c1 100644 --- a/src/main/java/net/silentclient/client/utils/types/GlobalSettings.java +++ b/src/main/java/net/silentclient/client/utils/types/GlobalSettings.java @@ -8,6 +8,7 @@ public class GlobalSettings { public String config; public boolean lite; public boolean displayedTutorial; + public boolean configsMigrated; public GlobalSettings() { this.config = "config.txt";