This commit is contained in:
kirillsaint 2023-07-25 15:40:25 +06:00
parent 526673828b
commit 387e9ac10a
13 changed files with 506 additions and 18 deletions

View File

@ -60,7 +60,7 @@ public class Client {
private BuildData buildData = new BuildData(); private BuildData buildData = new BuildData();
private UserData userData = new UserData(); private UserData userData = new UserData();
public File dir; public File configDir;
private SettingsManager settingsManager; private SettingsManager settingsManager;
public ConfigManager configManager; public ConfigManager configManager;
private ModInstances modInstances; private ModInstances modInstances;
@ -158,9 +158,9 @@ public class Client {
this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting() this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting()
.enableComplexMapKeySerialization().create(); .enableComplexMapKeySerialization().create();
logger.info("INITIALISING > silent-directory"); logger.info("INITIALISING > silent-directory");
dir = new File(Minecraft.getMinecraft().mcDataDir, "SilentClient"); configDir = new File(Minecraft.getMinecraft().mcDataDir, "SilentClient-Configs");
if (!dir.exists()) { if (!configDir.exists()) {
dir.mkdirs(); configDir.mkdirs();
} }
globalSettingsFile = new File(Minecraft.getMinecraft().mcDataDir, "silent_settings.json"); globalSettingsFile = new File(Minecraft.getMinecraft().mcDataDir, "silent_settings.json");
if(!globalSettingsFile.exists()) { if(!globalSettingsFile.exists()) {
@ -208,9 +208,8 @@ public class Client {
content.append(inputLine); content.append(inputLine);
} }
globalSettings.setConfig(new JSONObject(content.toString()).getString("config")); globalSettings = gson.fromJson(content.toString(), GlobalSettings.class);
globalSettings.setLite(new JSONObject(content.toString()).getBoolean("lite")); Client.getInstance().updateWindowTitle();
globalSettings.setDisplayedTutorial(new JSONObject(content.toString()).getBoolean("displayedTutorial"));
in.close(); in.close();
} catch (Exception err) { } catch (Exception err) {
Client.logger.catching(err); Client.logger.catching(err);
@ -218,6 +217,15 @@ public class Client {
globalSettings.save(); globalSettings.save();
Client.getInstance().updateWindowTitle(); 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"); logger.info("STARTING > config-manager");
configManager = new ConfigManager(); configManager = new ConfigManager();
logger.info("STARTING > texture-manager"); logger.info("STARTING > texture-manager");

View File

@ -31,7 +31,7 @@ import net.silentclient.client.utils.FileUtils;
import net.silentclient.client.utils.Players; import net.silentclient.client.utils.Players;
public class AdminRender extends GuiScreen { 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 // Settings
private boolean showSettings = false; private boolean showSettings = false;

View File

@ -12,7 +12,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.gui.hud.ScreenPosition;
import net.silentclient.client.gui.notification.NotificationManager; import net.silentclient.client.gui.notification.NotificationManager;
@ -31,7 +30,7 @@ public final class ConfigManager {
updateConfigs(); updateConfigs();
String config = Client.getInstance().getGlobalSettings().getConfig(); String config = Client.getInstance().getGlobalSettings().getConfig();
configFile = new File(Client.getInstance().dir, config); configFile = new File(Client.getInstance().configDir, config);
if(!configFile.exists()) { if(!configFile.exists()) {
@ -51,7 +50,7 @@ public final class ConfigManager {
public void updateConfigs() { public void updateConfigs() {
Client.logger.info("Updating Config List"); 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()) .filter(file -> !file.isDirectory())
.map(File::getName) .map(File::getName)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
@ -59,7 +58,7 @@ public final class ConfigManager {
public void deleteConfig(String name) { public void deleteConfig(String name) {
try { try {
new File(Client.getInstance().dir, name).delete(); new File(Client.getInstance().configDir, name).delete();
} catch (Exception err) { } catch (Exception err) {
err.printStackTrace(); err.printStackTrace();
} }
@ -69,7 +68,7 @@ public final class ConfigManager {
public void loadConfig(String name) { public void loadConfig(String name) {
Client.logger.info("Loading Config: " + name); Client.logger.info("Loading Config: " + name);
Client.getInstance().getGlobalSettings().setConfig(name); Client.getInstance().getGlobalSettings().setConfig(name);
configFile = new File(Client.getInstance().dir, name); configFile = new File(Client.getInstance().configDir, name);
if(!configFile.exists()) { if(!configFile.exists()) {
try { try {
configFile.createNewFile(); configFile.createNewFile();
@ -91,7 +90,7 @@ public final class ConfigManager {
public String newConfig(String name, boolean clone) { public String newConfig(String name, boolean clone) {
Client.logger.info("Creating Config: " + name); 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()) { if(testConfig.exists()) {
Client.logger.info("Creating Config Error: Config already exists."); Client.logger.info("Creating Config Error: Config already exists.");
return "Config already exists."; return "Config already exists.";

View File

@ -131,6 +131,9 @@ public class Cosmetics {
}); });
} }
} }
Client.logger.info("STARTING > cosmeitcs > outfits");
Outfits.loadOutfits();
} }
update(false); update(false);

View File

@ -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<Outfit> 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<String> 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<Outfit> 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;
}
}
}

View File

@ -45,11 +45,12 @@ public class CosmeticsGui extends SilentScreen {
rotate = 144; rotate = 144;
if(mc.thePlayer == null) { if(mc.thePlayer == null) {
Client.backgroundPanorama.updateWidthHeight(this.width, this.height); Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
} else {
MenuBlurUtils.loadBlur();
} }
this.silentInputs.add(new Input("Search")); this.silentInputs.add(new Input("Search"));
CosmeticsGui.scrollY = 0; CosmeticsGui.scrollY = 0;
CosmeticsGui.selectedCategory = "capes"; CosmeticsGui.selectedCategory = "capes";
MenuBlurUtils.loadBlur();
Client.getInstance().updateUserInformation(); Client.getInstance().updateUserInformation();
int categoryOffsetY = 25; int categoryOffsetY = 25;
int addX = 190; int addX = 190;
@ -84,6 +85,8 @@ public class CosmeticsGui extends SilentScreen {
tabId++; 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) - 26, 75, 20, "Store"));
this.buttonList.add(new Button(88, x + 380 - 140, y + 220 - 22, 135, 20, "Outfits"));
} }
@Override @Override
@ -173,6 +176,10 @@ public class CosmeticsGui extends SilentScreen {
err.printStackTrace(); err.printStackTrace();
} }
} }
if(button.id == 88) {
mc.displayGuiScreen(new OutfitsGui(this));
}
} }
private ArrayList<CosmeticItem> getItems() { private ArrayList<CosmeticItem> getItems() {

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -109,7 +109,7 @@ public class UserTutorial extends SilentScreen {
break; break;
case 3: case 3:
try { 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))); Client.getInstance().getConfigManager().loadConfig(String.format("%s (Preset).txt", this.configs.get(configIndex)));
} catch (Exception e) { } catch (Exception e) {
Client.logger.catching(e); Client.logger.catching(e);

View File

@ -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) { if(MouseUtils.isInside(mouseX, mouseY,x + 100 + (column == 1 ? 0 : 140), y + modOffsetY - scrollAnimation.getValue(), 135, 28) && mouseButton == 0) {
Sounds.playButtonSound(); Sounds.playButtonSound();
File file1 = Client.getInstance().dir; File file1 = Client.getInstance().configDir;
String s = file1.getAbsolutePath(); String s = file1.getAbsolutePath();
if (Util.getOSType() == Util.EnumOS.OSX) { if (Util.getOSType() == Util.EnumOS.OSX) {

View File

@ -290,7 +290,7 @@ public class ModMenu extends SilentScreen {
mc.displayGuiScreen(new AddConfigModal(this)); mc.displayGuiScreen(new AddConfigModal(this));
break; break;
case 6: case 6:
File file1 = Client.getInstance().dir; File file1 = Client.getInstance().configDir;
String s = file1.getAbsolutePath(); String s = file1.getAbsolutePath();
if (Util.getOSType() == Util.EnumOS.OSX) { if (Util.getOSType() == Util.EnumOS.OSX) {

View File

@ -62,4 +62,21 @@ public class FileUtils {
resStreamOut.close(); 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();
}
}
} }

View File

@ -8,6 +8,7 @@ public class GlobalSettings {
public String config; public String config;
public boolean lite; public boolean lite;
public boolean displayedTutorial; public boolean displayedTutorial;
public boolean configsMigrated;
public GlobalSettings() { public GlobalSettings() {
this.config = "config.txt"; this.config = "config.txt";