(feat) start on very basic bridge

This commit is contained in:
refactoring 2024-01-02 15:53:55 -05:00
parent f1c964fe94
commit 5509f7f69c
1038 changed files with 220998 additions and 2744 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
@ -10,7 +11,6 @@
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/Bridge" />
<option value="$PROJECT_DIR$/Client" />
<option value="$PROJECT_DIR$/v1_19_4" />
<option value="$PROJECT_DIR$/v1_8_9" />
</set>
</option>

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="graalvm-ce-17" project-jdk-type="JavaSDK">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,12 +1,16 @@
package dev.refactoring.bridge.client;
import dev.refactoring.bridge.client.gui.GuiScreenBridge;
import java.io.File;
/**
* Bridge for the class MinecraftClient.
* This is just an example and will definitely need to have changes.
*
* @author refactoring
*/
public interface MinecraftClientBridge {
public interface MinecraftBridge {
/**
* Returns the current FPS.
* Javadoc is not required for a bridge, but all bridge methods must start with "bridge$"
@ -14,5 +18,15 @@ public interface MinecraftClientBridge {
*
* @return the current FPS
*/
public int bridge$getCurrentFps();
public int bridge$getDebugFps();
public void bridge$displayScreen(GuiScreenBridge screen);
public File bridge$getDataDir();
public int bridge$width();
public int bridge$height();
public boolean bridge$isFullScreen();
}

View File

@ -0,0 +1,15 @@
package dev.refactoring.bridge.client.gui;
/**
* @author refactoring
*/
public interface CustomScreen {
int mouseReleased();
void drawScreen(int var1, int var2, float var3);
void mouseClicked(int var1, int var2, int var3);
void mouseReleased(int var1, int var2, int var3);
void onGuiClosed();
void updateScreen();
void keyTyped(char var1, int var2);
boolean doesGuiPauseGame();
}

View File

@ -0,0 +1,7 @@
package dev.refactoring.bridge.client.gui;
/**
* @author refactoring
*/
public interface GuiBridge {
}

View File

@ -0,0 +1,20 @@
package dev.refactoring.bridge.client.gui;
/**
* @author refactoring
*/
import java.io.IOException;
import java.net.URI;
import java.util.List;
public interface GuiScreenBridge extends GuiBridge {
void bridge$drawScreen(int mouseX, int mouseY, float pTicks);
void bridge$mouseClicked(int mouseX, int mouseY, int mouseButton);
void bridge$mouseReleased(int mouseX, int mouseY, int mouseButton);
void bridge$onGuiClosed();
void bridge$updateScreen();
void bridge$keyTyped(char keyChar, int keyCode);
void bridge$handleMouseInput();
boolean bridge$allowUserInput();
boolean bridge$doesGuiPauseGame();
}

View File

@ -0,0 +1,8 @@
package dev.refactoring.bridge.client.gui;
/**
* @author refactoring
*/
public interface WrappedGuiScreenBridge extends GuiScreenBridge {
CustomScreen getCustomScreen();
}

View File

@ -1,6 +1,8 @@
package dev.refactoring.bridge.core;
import dev.refactoring.bridge.client.gui.CustomScreen;
import dev.refactoring.bridge.client.gui.WrappedGuiScreenBridge;
import dev.refactoring.bridge.client.input.KeyBindingBridge;
/**
@ -11,4 +13,5 @@ import dev.refactoring.bridge.client.input.KeyBindingBridge;
*/
public interface Bridge {
public KeyBindingBridge initKeyBinding(String name, int keyCode, String cat);
public WrappedGuiScreenBridge initCustomScreen(CustomScreen screen);
}

View File

@ -1,6 +1,6 @@
package dev.refactoring.bridge.core;
import dev.refactoring.bridge.client.MinecraftClientBridge;
import dev.refactoring.bridge.client.MinecraftBridge;
import dev.refactoring.bridge.core.util.MinecraftVersion;
import lombok.Getter;
import lombok.Setter;
@ -16,9 +16,9 @@ public class BridgeManager {
// Bridges
public Bridge bridge;
public MinecraftClientBridge minecraftClientBridge;
public MinecraftBridge minecraftBridge;
// Other
private String windowTitle = "Test Client | Initializing";
private String windowTitle = "Silent Client | Initializing";
private MinecraftVersion version;
}

View File

@ -7,8 +7,7 @@ import lombok.Getter;
*/
@Getter
public enum MinecraftVersion {
v1_8_9("1.8.9"),
v1_19_4("1.19.4");
v1_8_9("1.8.9"); // Finish the 1.8 implementation first, and then we can do the rest.
MinecraftVersion(String name) {
this.name = name;

View File

@ -1,6 +1,6 @@
package dev.refactoring.bridge.core.util;
import dev.refactoring.bridge.client.MinecraftClientBridge;
import dev.refactoring.bridge.client.MinecraftBridge;
import dev.refactoring.bridge.core.BridgeManager;
/**
@ -9,12 +9,12 @@ import dev.refactoring.bridge.core.BridgeManager;
* @author refactoring
*/
public class Ref {
public static MinecraftClientBridge minecraft() {
return BridgeManager.INSTANCE.getMinecraftClientBridge();
public static MinecraftBridge minecraft() {
return BridgeManager.INSTANCE.getMinecraftBridge();
}
/**
* It can also be used to return commonly used values.
* It can also be used to return commonly used bridges.
* Here, I've used FPS. But again, the possibilities are endless.
*/
public static int fps() {

View File

@ -20,9 +20,12 @@ dependencies {
implementation platform("org.lwjgl:lwjgl-bom:3.3.2")
implementation("org.lwjgl:lwjgl-opengl:3.3.2")
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
implementation("com.google.code.gson:gson:2.10.1")
implementation project(":Bridge") // You need to reference this in every module.
// You also need to reference the client project.
implementation fileTree(dir: "../libs", includes: ["*.jar"])
}
test {

View File

@ -1,20 +0,0 @@
package dev.refactoring.testclient;
import dev.refactoring.bridge.core.BridgeManager;
import dev.refactoring.bridge.core.util.Ref;
/**
* @author refactoring
*/
public class TestClient {
public static TestClient INSTANCE = new TestClient();
public static TestClient get() {
return INSTANCE;
}
public void printFps() {
BridgeManager.INSTANCE.setWindowTitle("Test Client 1.0.0 | " + BridgeManager.INSTANCE.getVersion().getName());
System.out.println(Ref.fps()); // This is how you use the methods.
}
}

View File

@ -0,0 +1,700 @@
package net.silentclient.client;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev.refactoring.bridge.core.util.Ref;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.data.IMetadataSerializer;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.config.ConfigManager;
import net.silentclient.client.cosmetics.Cosmetics;
import net.silentclient.client.event.EventManager;
import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.*;
import net.silentclient.client.gui.GuiError;
import net.silentclient.client.gui.UserTutorial;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.lite.GuiNews;
import net.silentclient.client.gui.lite.LiteMainMenu;
import net.silentclient.client.gui.lite.clickgui.ClickGUI;
import net.silentclient.client.gui.modmenu.ModMenu;
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.keybinds.KeyBindManager;
import net.silentclient.client.mods.ModInstances;
import net.silentclient.client.mods.SettingsManager;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.mods.util.PingSource;
import net.silentclient.client.mods.util.Server;
import net.silentclient.client.mods.util.Utils;
import net.silentclient.client.premium.PremiumCosmeticsGui;
import net.silentclient.client.premium.PremiumUtils;
import net.silentclient.client.skillissue.SkillIssue;
import net.silentclient.client.utils.*;
import net.silentclient.client.utils.animations.AnimationHandler;
import net.silentclient.client.utils.animations.SneakHandler;
import net.silentclient.client.utils.culling.EntityCulling;
import net.silentclient.client.utils.types.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.*;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
public class Client {
public static final Logger logger = LogManager.getLogger("SC");
private final String version = "2.0.0";
private static final Client INSTANCE = new Client();
public static final Client getInstance() {
return INSTANCE;
}
private BuildData buildData = new BuildData();
private UserData userData = new UserData();
public File configDir;
private SettingsManager settingsManager;
public ConfigManager configManager;
private ModInstances modInstances;
private Gson gson;
private ScreenshotManager screenshotManager;
private Cosmetics cosmetics = new Cosmetics();
private PlayerResponse.Account account;
private SCTextureManager textureManager;
private SilentFontRenderer silentFontRenderer;
private long lastMemoryDebug = System.currentTimeMillis();
public int ping;
private static final int PING_INTERVAL = 600;
private int nextPing;
private PingSource source = PingSource.AUTO;
private boolean banerror = false;
private ResourceLocation bindingTexture = new ResourceLocation("silentclient/binding.png");
private ArrayList<ServerDataFeature> featuredServers = new ArrayList<ServerDataFeature>();
private FriendsResponse friends;
public int playersCount = 0;
private CPSTracker cpsTracker;
public static BackgroundPanorama backgroundPanorama;
private KeyBindManager keyBindManager;
private IMetadataSerializer iMetadataSerializer;
private MouseCursorHandler mouseCursorHandler;
private GlobalSettings globalSettings;
private File globalSettingsFile;
private AccountManager accountManager;
public ServerData lastServerData;
public TextUtils textUtils;
private SkillIssue skillIssue;
private PlayerResponse.BanInfo banInfo;
public static void memoryDebug(String paramString) {
LogManager.getLogger().info("-- Start Memory Debug -- " + paramString);
long l1 = Runtime.getRuntime().maxMemory();
long l2 = Runtime.getRuntime().totalMemory();
long l3 = Runtime.getRuntime().freeMemory();
LogManager.getLogger().info("Max: " + l1 + " (" + (l1 / 1000000.0D) + "MB)");
LogManager.getLogger().info("Total: " + l2 + " (" + (l2 / 1000000.0D) + "MB)");
LogManager.getLogger().info("Free: " + l3 + " (" + (l3 / 1000000.0D) + "MB)");
LogManager.getLogger().info("-- End Memory Debug -- " + paramString);
}
public void init() throws IOException {
try {
InputStream in = getClass().getResourceAsStream("/build_data.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer content = new StringBuffer();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
content.append(inputLine);
}
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
buildData = gson.fromJson(content.toString(), BuildData.class);
in.close();
} catch (Exception e1) {
Client.logger.catching(e1);
}
try {
InputStream in = new FileInputStream(new File(Ref.minecraft().bridge$getDataDir(), "silent_account.json"));
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer content = new StringBuffer();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
content.append(inputLine);
}
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
userData = gson.fromJson(content.toString(), UserData.class);
in.close();
if(!ClientUtils.isDevelopment()) {
try {
new File(Ref.minecraft().bridge$getDataDir(), "silent_account.json").delete();
} catch (Exception err) {
}
}
} catch (Exception err) {
}
logger.info("---------[ Silent Client Initialising ]---------");
logger.info("MC Version: 1.8.9");
logger.info("SC Version: " + getFullVersion());
logger.info("Width: " + Ref.minecraft().bridge$width());
logger.info("Height: " + Ref.minecraft().bridge$height());
logger.info("Fullscreen: " + Ref.minecraft().bridge$isFullScreen());
List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean gcMxBean : gcMxBeans) {
logger.info("GC Name: " + gcMxBean.getName());
logger.info("GC Object Name: " + gcMxBean.getObjectName());
}
logger.info("-------------------------------------------------");
memoryDebug("CLIENT_PRE_INIT");
// if(SilentClientTweaker.hasOptifine) {
// logger.info("INITIALISING > optifine-patch");
// OptifinePatch.init();
// }
logger.info("INITIALISING > gson-builder");
this.gson = (new GsonBuilder()).registerTypeAdapterFactory(new EnumAdapterFactory()).setPrettyPrinting()
.enableComplexMapKeySerialization().create();
logger.info("INITIALISING > silent-directory");
configDir = new File(Ref.minecraft().bridge$getDataDir(), "SilentClient-Configs");
if (!configDir.exists()) {
configDir.mkdirs();
}
globalSettingsFile = new File(Ref.minecraft().bridge$getDataDir(), "silent_settings.json");
if(!globalSettingsFile.exists()) {
globalSettingsFile.createNewFile();
}
logger.info("INITIALISING > event-manager");
EventManager.register(this);
EventManager.register(SneakHandler.getInstance());
EventManager.register(AnimationHandler.getInstance());
memoryDebug("CLIENT_POST_INIT");
}
public void start() throws Throwable {
memoryDebug("CLIENT_PRE_START");
logger.info("---------[ Silent Client Starting ]--------------");
try {
logger.info("STARTING > registering-player");
Players.register();
logger.info("STARTING > sc-account");
PlayerResponse acc = updateAccount();
if(acc != null) {
Client.getInstance().setAccount(acc.getAccount());
}
logger.info("STARTING > settings-manager");
settingsManager = new SettingsManager();
logger.info("STARTING > mod-instances");
modInstances = new ModInstances();
logger.info("STARTING > global-settings");
globalSettings = new GlobalSettings();
try {
InputStream in = new FileInputStream(getGlobalSettingsFile());
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer content = new StringBuffer();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
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.setConfigsMigrated(new JSONObject(content.toString()).getBoolean("configsMigrated"));
globalSettings.setPacksPanoramaEnabled(new JSONObject(content.toString()).getBoolean("packsPanoramaEnabled"));
Client.getInstance().updateWindowTitle();
in.close();
} catch (Exception err) {
Client.logger.catching(err);
}
globalSettings.save();
Client.getInstance().updateWindowTitle();
if(!globalSettings.configsMigrated && new File(Ref.minecraft().bridge$getDataDir(), "SilentClient").exists() && new File(Ref.minecraft().bridge$getDataDir(), "SilentClient").isDirectory()) {
logger.info("STARTING > migrating-configs");
for(String file : new File(Ref.minecraft().bridge$getDataDir(), "SilentClient").list()) {
if(!new File(Ref.minecraft().bridge$getDataDir(), "SilentClient/" + file).isDirectory()) {
Client.logger.info("STARTING > migrating-configs > " + file);
FileUtils.copyFile(new File(Ref.minecraft().bridge$getDataDir(), "SilentClient/" + file), new File(Ref.minecraft().bridge$getDataDir(), "SilentClient-Configs/" + file));
}
}
globalSettings.configsMigrated = true;
globalSettings.save();
new File(Ref.minecraft().bridge$getDataDir(), "SilentClient").delete();
}
logger.info("STARTING > config-manager");
configManager = new ConfigManager();
if(OSUtil.isWindows()) {
logger.info("STARTING > raw-mouse-input");
Minecraft.getMinecraft().mouseHelper = new RawMouseHelper();
RawInputHandler.init();
}
logger.info("STARTING > texture-manager");
this.textureManager = new SCTextureManager(Minecraft.getMinecraft().getResourceManager());
logger.info("STARTING > font-renderer");
this.silentFontRenderer = new SilentFontRenderer();
logger.info("STARTING > cps-tracker");
this.cpsTracker = new CPSTracker();
EventManager.register(cpsTracker);
logger.info("STARTING > cosmetics");
cosmetics.init();
logger.info("STARTING > account-manager");
accountManager = new AccountManager();
accountManager.init();
logger.info("STARTING > entity-culling");
EventManager.register(new EntityCulling());
try {
EntityCulling.SUPPORT_NEW_GL = GLContext.getCapabilities().OpenGL33;
} catch(Exception err) {
Client.logger.catching(err);
EntityCulling.SUPPORT_NEW_GL = false;
}
EntityCulling.renderManager = Minecraft.getMinecraft().getRenderManager();
logger.info("STARTING > screenshot-manager");
EventManager.register(this.screenshotManager = new ScreenshotManager());
logger.info("STARTING > binding-textures");
Minecraft.getMinecraft().getTextureManager().bindTexture(this.getBindingTexture());
modInstances.getMods().forEach((mod) -> {
if(mod.getIcon() != null) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(mod.getIcon()));
}
});
logger.info("STARTING > servers");
ArrayList<FeaturedServers.FeaturedServerInfo> servers = FeaturedServers.get();
featuredServers.clear();
if(servers != null && servers != null) {
servers.forEach(server -> {
featuredServers.add(new ServerDataFeature(server.getName(), server.getIp()));
});
}
logger.info("STARTING > friends");
this.updateFriendsList();
if(Client.getInstance().getAccount() == null) {
logger.info("STARTING > ERROR: " + "Authorization Error. Try restarting the game.");
Minecraft.getMinecraft().displayGuiScreen(new GuiError("Authorization Error. Try restarting the game"));
return;
}
if(banInfo != null && banInfo.banned && !banerror) {
logger.info("STARTING > ERROR: " + "Account is banned");
Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned. Reason: " + banInfo.reason));
banerror = true;
}
Client.logger.info("STARTING > mod-instances-post-init");
modInstances.postInit();
Client.logger.info("STARTING > fixing-mods");
modInstances.getMods().forEach((mod) -> {
mod.setEnabled(!mod.isEnabled());
mod.setEnabled(!mod.isEnabled());
});
Client.logger.info("STARTING > launching-detector");
Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString());
logger.info("STARTING > promo");
String panelContent = Requests.get("https://assets.silentclient.net/client/promo.json");
if(panelContent != null) {
try {
PromoController.PromoResponse promoResponse = getGson().fromJson(panelContent, PromoController.PromoResponse.class);
PromoController.setResponse(promoResponse);
} catch (Exception err) {
logger.catching(err);
}
}
logger.info("STARTING > mouse-cursor-handler");
this.mouseCursorHandler = new MouseCursorHandler();
if(globalSettings.lite) {
Minecraft.getMinecraft().displayGuiScreen(new GuiNews());
} else {
Minecraft.getMinecraft().displayGuiScreen(new MainMenuConcept());
}
if(!Client.getInstance().getAccount().getClaimedPremiumCosmetics()) {
Client.logger.info("STARTING > premium-cosmetics");
PremiumCosmeticsResponse premiumCosmetics = PremiumUtils.getPremiumCosmetics();
if(premiumCosmetics != null) {
Minecraft.getMinecraft().displayGuiScreen(new PremiumCosmeticsGui(premiumCosmetics));
}
}
Client.logger.info("STARTING > config-manager-post-init");
configManager.postInit();
if(!globalSettings.displayedTutorial) {
Minecraft.getMinecraft().displayGuiScreen(new UserTutorial());
}
} catch(Exception err) {
Client.logger.catching(err);
logger.info("STARTING > ERROR: " + err.getMessage());
throw err;
}
Client.logger.info("STARTING > text-utils");
this.textUtils = new TextUtils(Minecraft.getMinecraft().fontRendererObj);
logger.info("STARTING > skillissue");
this.skillIssue = new SkillIssue();
logger.info("-------------------------------------------------");
memoryDebug("CLIENT_POST_INIT");
}
public void shutdown() {
logger.info("---------[ Silent Client Stopping ]--------------");
logger.info("STOPPING > silent-socket");
skillIssue.sendDetections();
Players.unregister();
logger.info("-------------------------------------------------");
}
// utils
public void updateWindowTitle() {
Display.setTitle(String.format("Silent Client%s %s (1.8.9)", Client.getInstance().getGlobalSettings() != null && Client.getInstance().getGlobalSettings().isLite() ? " Lite" : "", Client.getInstance().getFullVersion()));
}
public void updateUserInformation() {
if(Client.getInstance().getAccount() != null) {
(new Thread("updateUserInformation") {
public void run() {
PlayerResponse cosmetics = updateAccount();
if(cosmetics != null) {
Client.getInstance().setAccount(cosmetics.getAccount());
Client.getInstance().getCosmetics().setMyCapes(cosmetics.getAccount().getCosmetics().getCapes());
Client.getInstance().getCosmetics().setMyWings(cosmetics.getAccount().getCosmetics().getWings());
Client.getInstance().getCosmetics().setMyIcons(cosmetics.getAccount().getCosmetics().getIcons());
Client.getInstance().getCosmetics().setMyBandanas(cosmetics.getAccount().getCosmetics().getBandanas());
Client.getInstance().getCosmetics().setMyHats(cosmetics.getAccount().getCosmetics().getHats());
Client.getInstance().getCosmetics().setMyShields(cosmetics.getAccount().getCosmetics().getShields());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Type").setValString(cosmetics.getAccount().getCapeType().equals("dynamic_curved") ? "Dynamic Curved" : cosmetics.getAccount().getCapeType().equals("curved_rectangle") ? "Curved Rectangle" : "Rectangle");
if(Minecraft.getMinecraft().thePlayer != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setCapeType(cosmetics.getAccount().getCapeType());
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setShoulders(cosmetics.getAccount().getCapeShoulders());
}
}
}
}).start();
}
}
public void updateFriendsList() {
if(Client.getInstance().getAccount() != null) {
(new Thread("updateFriendsList") {
public void run() {
FriendsResponse friends = getFriendsAPI();
if(friends != null) {
Client.getInstance().setFriends(friends);
}
}
}).start();
}
}
private FriendsResponse getFriendsAPI() {
try {
URL url = new URL("https://api.silentclient.net/friends");
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "SilentClient");
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer content = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
Client.logger.info("Loaded friends: " + content.toString());
in.close();
con.disconnect();
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
FriendsResponse response = gson.fromJson(content.toString(), FriendsResponse.class);
return response;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public PlayerResponse updateAccount() {
try {
String content = Requests.post("https://api.silentclient.net/account/update", new JSONObject().put("server", Minecraft.getMinecraft().getCurrentServerData() != null ? Minecraft.getMinecraft().getCurrentServerData().serverIP : null).toString());
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
PlayerResponse playerResponse = gson.fromJson(content, PlayerResponse.class);
this.banInfo = playerResponse.banInfo;
return playerResponse;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// Events
@EventTarget
public void onTick(ClientTickEvent event) {
long l = System.currentTimeMillis();
if (l - 60000L > this.lastMemoryDebug) {
this.lastMemoryDebug = l;
if(getSettingsManager() != null && getSettingsManager().getSettingByClass(FPSBoostMod.class, "Do memory debug").getValBoolean()) {
memoryDebug("Interval: " + l);
}
this.updateUserInformation();
}
if(banInfo != null) {
if(banInfo.banned && !banerror) {
if(Minecraft.getMinecraft().theWorld != null) {
Minecraft.getMinecraft().theWorld.sendQuittingDisconnectingPacket();
Minecraft.getMinecraft().loadWorld(null);
}
Minecraft.getMinecraft().displayGuiScreen(new GuiError("Your account is banned. Reason: " + banInfo.reason));
banerror = true;
}
}
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Mod Menu Keybind").isKeyDown()) {
Minecraft.getMinecraft().displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ClickGUI() : new ModMenu());
}
if(source.resolve() != PingSource.MULTIPLAYER_SCREEN) {
return;
}
if(Minecraft.getMinecraft().getCurrentServerData() != null && !Minecraft.getMinecraft().isIntegratedServerRunning()) {
if(nextPing > 0) {
nextPing--;
}
else if(nextPing > -1) {
nextPing = -1;
Utils.MAIN_EXECUTOR.submit(() -> {
try {
Utils.pingServer(Minecraft.getMinecraft().getCurrentServerData().serverIP, (newPing) -> {
if(newPing != -1) {
if(ping != 0) {
ping = (ping * 3 + newPing) / 4;
}
else {
ping = newPing;
}
}
});
}
catch(UnknownHostException error) {
Client.logger.fatal("[SC]: Could not ping server", error);
}
nextPing = PING_INTERVAL;
});
}
}
}
@EventTarget
public void onMouseClick(EventClickMouse event) {
if(event.getButton() == 0) {
((MinecraftAccessor) Minecraft.getMinecraft()).setLeftClickCounter(0);
}
}
@EventTarget
public void onServerConnect(ConnectToServerEvent event) {
ping = 0;
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
Client.logger.info("Update Connection Server: " + event.getServerData().serverIP);
Server.setHypixel(Server.checkIsHypixel());
Server.setRuHypixel(Server.checkIsRuHypixel());
}
@EventTarget
public void onServerDisconnect(ServerLeaveEvent event) {
ping = 0;
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
Client.logger.info("Update Connection Server: null");
Server.setHypixel(Server.checkIsHypixel());
Server.setRuHypixel(Server.checkIsRuHypixel());
}
@EventTarget
public void onServerDisconnect(SingleplayerJoinEvent event) {
ping = 0;
playersCount = 0;
nextPing = 10;
this.updateUserInformation();
Client.logger.info("Update Connection Server: null");
Server.setHypixel(Server.checkIsHypixel());
Server.setRuHypixel(Server.checkIsRuHypixel());
}
// Instances
public String getApiUrl() {
return "http://localhost:" + getUserData().server_port;
}
public AccountManager getAccountManager() {
return accountManager;
}
public FriendsResponse getFriends() {
return friends;
}
public void setFriends(FriendsResponse friends) {
this.friends = friends;
}
public UserData getUserData() {
return userData;
}
public BuildData getBuildData() {
return buildData;
}
public String getVersion() {
return version;
}
public String getFullVersion() {
return "v" + version + "-" + getBuildData().getCommit() + "-" + getBuildData().getBranch();
}
public Cosmetics getCosmetics() {
return cosmetics;
}
public PlayerResponse.Account getAccount() {
return account;
}
public void setAccount(PlayerResponse.Account account) {
this.account = account;
}
public ResourceLocation getBindingTexture() {
return bindingTexture;
}
public Gson getGson() {
return gson;
}
public SCTextureManager getTextureManager() {
return textureManager;
}
public SilentFontRenderer getSilentFontRenderer() {
return silentFontRenderer;
}
public SettingsManager getSettingsManager() {
return settingsManager;
}
public ModInstances getModInstances() {
return modInstances;
}
public ConfigManager getConfigManager() {
return configManager;
}
public CPSTracker getCPSTracker() {
return cpsTracker;
}
public int getPing() {
return ping;
}
public ArrayList<ServerDataFeature> getFeaturedServers() {
return featuredServers;
}
public int getPlayersCount() {
return playersCount;
}
public ScreenshotManager getScreenshotManager() {
return screenshotManager;
}
public boolean isTest() {
return getBuildData().getBranch().equals("test");
}
public boolean isDebug() {
return getBuildData().getBranch().equals("debug");
}
public int getScaleFactor() {
return (new ScaledResolution(Minecraft.getMinecraft())).getScaleFactor();
}
public void setKeyBindManager(KeyBindManager keyBindManager) {
this.keyBindManager = keyBindManager;
}
public KeyBindManager getKeyBindManager() {
return keyBindManager;
}
public IMetadataSerializer getiMetadataSerializer() {
return iMetadataSerializer;
}
public void setiMetadataSerializer(IMetadataSerializer iMetadataSerializer) {
this.iMetadataSerializer = iMetadataSerializer;
}
public MouseCursorHandler getMouseCursorHandler() {
return mouseCursorHandler;
}
public GlobalSettings getGlobalSettings() {
return globalSettings;
}
public File getGlobalSettingsFile() {
return globalSettingsFile;
}
public GuiScreen getMainMenu() {
if(Client.getInstance().getGlobalSettings() == null) {
return new MainMenuConcept();
}
return Client.getInstance().getGlobalSettings().isLite() ? new LiteMainMenu() : new MainMenuConcept();
}
}

View File

@ -0,0 +1,11 @@
package net.silentclient.client;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.util.ResourceLocation;
public class ServerDataFeature extends ServerData {
public static final ResourceLocation STAR_ICON = new ResourceLocation("silentclient/icons/star.png");
public ServerDataFeature(String serverName, String serverIp) {
super(serverName, serverIp, false);
}
}

View File

@ -0,0 +1,455 @@
package net.silentclient.client.admin;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.AnimatedResourceLocation;
import net.silentclient.client.cosmetics.ShieldData;
import net.silentclient.client.cosmetics.StaticResourceLocation;
import net.silentclient.client.cosmetics.gui.CosmeticsGui;
import net.silentclient.client.gui.elements.StaticButton;
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.CustomFontRenderer;
import net.silentclient.client.mods.CustomFontRenderer.RenderMode;
import net.silentclient.client.utils.FileUtils;
import net.silentclient.client.utils.Players;
import org.lwjgl.Sys;
import org.lwjgl.input.Mouse;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.text.DecimalFormat;
public class AdminRender extends GuiScreen {
public static File adminRenderPath = new File(Client.getInstance().configDir, "admin-render");
// Settings
private boolean showSettings = false;
private static boolean savingPreview = false;
private float scale = 1.0F;
private int rotate = 0;
private int redBackground = 0;
private int greenBackground = 0;
private int blueBackground = 0;
// Information
private int frames = 1;
private int currentFrame = 0;
public AdminRender() {
if(Client.getInstance().getAccount().isStaff()) {
if(!adminRenderPath.exists()) {
adminRenderPath.mkdirs();
}
}
}
@Override
public void initGui() {
super.initGui();
this.showSettings = false;
AdminRender.savingPreview = false;
this.scale = 1.0F;
this.redBackground = 0;
this.greenBackground = 0;
this.blueBackground = 0;
this.rotate = 0;
loadTextureCosmetic("none");
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
super.drawDefaultBackground();
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setShoulders(true);
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setCapeType("Rectangle");
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getCape() != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getCape().setCurrentFrame(this.currentFrame);
}
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getBandana() != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getBandana().setCurrentFrame(this.currentFrame);
}
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getShield() != null && ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getShield().getTexture() != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getShield().getTexture().setCurrentFrame(this.currentFrame);
}
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(RenderMode.CUSTOM);
ScaledResolution sr = new ScaledResolution(mc);
RenderUtils.drawRect(0, 0, sr.getScaledWidth(), sr.getScaledHeight(), new Color(redBackground, greenBackground, blueBackground).getRGB());
if(!AdminRender.savingPreview) {
StaticButton.render(2, 2, 50, 12, this.showSettings ? "Close" : "Settings");
if(this.showSettings) {
int settingY = 20;
int sliderLeft = 50;
// Scale
font.drawString("Scale:", 2, settingY, -1, true);
RenderUtils.drawRect(sliderLeft, settingY, 90, 9, Color.black.getRGB());
RenderUtils.drawRect(sliderLeft, settingY, 90F * (float) (scale / 5.0D), 9, -1);
boolean scaleDrag = MouseUtils.isInside(mouseX, mouseY, sliderLeft, settingY - 1, 90, 9) && Mouse.isButtonDown(0);
if (scaleDrag) {
double diff = 5.0D - 1.0F;
double mouse = MathHelper.clamp_double((mouseX - sliderLeft) / 90D, 0, 1);
double newVal = 1.0F + mouse * diff;
this.scale = (float) newVal;
}
font.drawString(new DecimalFormat("0.00").format(scale), sliderLeft + 95, settingY, -1, true);
settingY += 15;
// Rotate
font.drawString("Rotate:", 2, settingY, -1, true);
RenderUtils.drawRect(sliderLeft, settingY, 90, 9, Color.black.getRGB());
RenderUtils.drawRect(sliderLeft, settingY, 90F * (float) (rotate / 360.0D), 9, -1);
boolean rotateDrag = MouseUtils.isInside(mouseX, mouseY, sliderLeft, settingY - 1, 90, 9) && Mouse.isButtonDown(0);
if (rotateDrag) {
double diff = 360D - 0F;
double mouse = MathHelper.clamp_double((mouseX - sliderLeft) / 90D, 0, 1);
double newVal = 0 + mouse * diff;
this.rotate = (int) newVal;
}
font.drawString(new DecimalFormat("0.00").format(rotate), sliderLeft + 95, settingY, -1, true);
settingY += 15;
// Background Red
font.drawString("BG Red:", 2, settingY, -1, true);
RenderUtils.drawRect(sliderLeft, settingY, 90, 9, Color.black.getRGB());
RenderUtils.drawRect(sliderLeft, settingY, 90F * (float) (redBackground / 255.0D), 9, -1);
boolean bgRedDrag = MouseUtils.isInside(mouseX, mouseY, sliderLeft, settingY - 1, 90, 9) && Mouse.isButtonDown(0);
if (bgRedDrag) {
double diff = 255D - 0F;
double mouse = MathHelper.clamp_double((mouseX - sliderLeft) / 90D, 0, 1);
double newVal = 0 + mouse * diff;
this.redBackground = (int) newVal;
}
font.drawString(new DecimalFormat("0.00").format(redBackground), sliderLeft + 95, settingY, -1, true);
settingY += 15;
// Background Green
font.drawString("BG Green:", 2, settingY, -1, true);
RenderUtils.drawRect(sliderLeft, settingY, 90, 9, Color.black.getRGB());
RenderUtils.drawRect(sliderLeft, settingY, 90F * (float) (greenBackground / 255.0D), 9, -1);
boolean bgGreenDrag = MouseUtils.isInside(mouseX, mouseY, sliderLeft, settingY - 1, 90, 9) && Mouse.isButtonDown(0);
if (bgGreenDrag) {
double diff = 255D - 0F;
double mouse = MathHelper.clamp_double((mouseX - sliderLeft) / 90D, 0, 1);
double newVal = 0 + mouse * diff;
this.greenBackground = (int) newVal;
}
font.drawString(new DecimalFormat("0.00").format(greenBackground), sliderLeft + 95, settingY, -1, true);
settingY += 15;
// Background Blue
font.drawString("BG Blue:", 2, settingY, -1, true);
RenderUtils.drawRect(sliderLeft, settingY, 90, 9, Color.black.getRGB());
RenderUtils.drawRect(sliderLeft, settingY, 90F * (float) (blueBackground / 255.0D), 9, -1);
boolean bgBlueDrag = MouseUtils.isInside(mouseX, mouseY, sliderLeft, settingY - 1, 90, 9) && Mouse.isButtonDown(0);
if (bgBlueDrag) {
double diff = 255D - 0F;
double mouse = MathHelper.clamp_double((mouseX - sliderLeft) / 90D, 0, 1);
double newVal = 0 + mouse * diff;
this.blueBackground = (int) newVal;
}
font.drawString(new DecimalFormat("0.00").format(blueBackground), sliderLeft + 95, settingY, -1, true);
settingY += 15;
// Presets
boolean twoColumn = false;
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Store Preset");
settingY += 15;
// Loads
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Load Cape");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Load Wings");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Load Bandana");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Load Shield");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 65 : 0), settingY, 60, 12, "Load Round Shield");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 65 : 0), settingY, 60, 12, "Load Hexagon Shield");
twoColumn = false;
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getWings() == null) {
settingY += 20;
font.drawString("Frames: " + this.frames, 2, settingY, -1, true);
settingY += 10;
font.drawString("Current Frame: " + (this.currentFrame + 1), 2, settingY, -1, true);
settingY += 15;
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Prev Frame");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
StaticButton.render(2 + (twoColumn ? 63 : 0), settingY, 60, 12, "Next Frame");
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
}
}
StaticButton.render(2, sr.getScaledHeight() - 14, 50, 12, "Open Textures Folder");
StaticButton.render(sr.getScaledWidth() - 52, 2, 50, 12, "Hide UI");
}
GlUtils.startScale(sr.getScaledWidth() / 2, sr.getScaledHeight() / 2 + ((int) (50 * scale)), scale);
CosmeticsGui.drawEntityOnScreen(sr.getScaledWidth() / 2, sr.getScaledHeight() / 2 + ((int) (50 * scale)), 45, 1, 1, mc.thePlayer, rotate);
GlUtils.stopScale();
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
ScaledResolution sr = new ScaledResolution(mc);
if(!AdminRender.savingPreview) {
if(StaticButton.isHovered(mouseX, mouseY, 2, 2, 50, 12)) {
this.showSettings = !this.showSettings;
}
if(StaticButton.isHovered(mouseX, mouseY, sr.getScaledWidth() - 52, 2, 50, 12)) {
AdminRender.savingPreview = true;
}
if(StaticButton.isHovered(mouseX, mouseY, 2, sr.getScaledHeight() - 14, 50, 12)) {
File file1 = adminRenderPath;
String s = file1.getAbsolutePath();
if (Util.getOSType() == Util.EnumOS.OSX)
{
try
{
Client.logger.info(s);
Runtime.getRuntime().exec(new String[] {"/usr/bin/open", s});
return;
}
catch (IOException ioexception1)
{
Client.logger.error((String)"Couldn\'t open file", (Throwable)ioexception1);
}
}
else if (Util.getOSType() == Util.EnumOS.WINDOWS)
{
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[] {s});
try
{
Runtime.getRuntime().exec(s1);
return;
}
catch (IOException ioexception)
{
Client.logger.error((String)"Couldn\'t open file", (Throwable)ioexception);
}
}
boolean flag = false;
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[] {file1.toURI()});
}
catch (Throwable throwable)
{
Client.logger.error("Couldn\'t open link", throwable);
flag = true;
}
if (flag)
{
Client.logger.info("Opening via system class!");
Sys.openURL("file://" + s);
}
}
if(this.showSettings) {
int settingY = 95;
boolean twoColumn = false;
if(StaticButton.isHovered(mouseX, mouseY, 2, settingY, 60, 12)) {
this.scale = 3.20F;
this.rotate = 4;
this.redBackground = 19;
this.blueBackground = 19;
this.greenBackground = 19;
}
settingY += 15;
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("cape");
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("wings");
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("bandana");
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("shield", "shield");
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("shield", "roundshield");
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
loadTextureCosmetic("shield", "hexagon_shield");
}
twoColumn = false;
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getWings() == null) {
settingY += 45;
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
this.currentFrame = (this.currentFrame - 1 >= 0 ? this.currentFrame - 1 : this.frames - 1);
}
if(twoColumn) {
twoColumn = !twoColumn;
settingY += 15;
} else {
twoColumn = !twoColumn;
}
if(StaticButton.isHovered(mouseX, mouseY, 2 + (twoColumn ? 63 : 0), settingY, 60, 12)) {
this.currentFrame = (this.currentFrame + 1 <= (this.frames - 1) ? this.currentFrame + 1 : 0);
}
}
}
} else {
AdminRender.savingPreview = false;
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Players.reload();
}
private void loadTextureCosmetic(String type) {
this.loadTextureCosmetic(type, "");
}
private void loadTextureCosmetic(String type, String model) {
((AbstractClientPlayerExt) mc.thePlayer).silent$setCape(null);
((AbstractClientPlayerExt) mc.thePlayer).silent$setCapeShoulders(null);
((AbstractClientPlayerExt) mc.thePlayer).silent$setBandana(null);
((AbstractClientPlayerExt) mc.thePlayer).silent$setHat(null);
((AbstractClientPlayerExt) mc.thePlayer).silent$setShield(null);
((AbstractClientPlayerExt) mc.thePlayer).silent$setWings(null);
this.frames = 0;
this.currentFrame = 0;
File [] pngFiles = adminRenderPath.listFiles(file -> file.isFile() && file.getName().toLowerCase().endsWith(".png"));
switch(type) {
case "cape":
((AbstractClientPlayerExt) mc.thePlayer).silent$setCape(new TestAnimatedResourceLocation(pngFiles.length - 1, 150));
((AbstractClientPlayerExt) mc.thePlayer).silent$setCapeShoulders(new StaticResourceLocation(FileUtils.fileToResourceLocation(new File(adminRenderPath, "0.png")).getResourcePath()));
this.frames = ((AbstractClientPlayerExt) mc.thePlayer).silent$getCape().getFrames();
this.currentFrame = 0;
break;
case "wings":
((AbstractClientPlayerExt) mc.thePlayer).silent$setWings(new TestAnimatedResourceLocation(pngFiles.length, 150));
this.frames = 1;
this.currentFrame = 0;
break;
case "bandana":
((AbstractClientPlayerExt) mc.thePlayer).silent$setBandana(new TestAnimatedResourceLocation(pngFiles.length, 150));
this.frames = ((AbstractClientPlayerExt) mc.thePlayer).silent$getBandana().getFrames();
this.currentFrame = 0;
break;
case "shield":
((AbstractClientPlayerExt) mc.thePlayer).silent$setShield(new ShieldData(new TestAnimatedResourceLocation(pngFiles.length, 150), model));
this.frames = ((AbstractClientPlayerExt) mc.thePlayer).silent$getShield().getTexture().getFrames();
this.currentFrame = 0;
break;
}
}
private class TestAnimatedResourceLocation extends AnimatedResourceLocation {
public TestAnimatedResourceLocation(int frames, int fpt) {
super("", frames, fpt, true);
textures = new ResourceLocation[frames];
for(int i = 0; i < frames; i++) {
Client.logger.info(new File(adminRenderPath, i + ".png").toString());
textures[i] = FileUtils.fileToResourceLocation(new File(adminRenderPath, i + ".png"));
}
}
@Override
public void update(float deltaTick) {
// Nothing =)
}
}
}

View File

@ -0,0 +1,278 @@
package net.silentclient.client.blc;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GLContext;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
public class BlcGlStateManager {
public static void a() {
// GlStateManager.get
}
public static void b() {
GlStateManager.disableAlpha();
}
public static void a(final int n, final float n2) {
GlStateManager.enableAlpha();
}
public static void c() {
GlStateManager.enableLighting();
}
public static void d() {
GlStateManager.disableLighting();
}
public static void e() {
GlStateManager.disableDepth();
}
public static void f() {
GlStateManager.enableDepth();
}
public static void a(final int n) {
GlStateManager.depthFunc(n);
}
public static void a(final boolean b) {
GlStateManager.depthMask(b);
}
public static void g() {
GlStateManager.enableBlend();
}
public static void h() {
GlStateManager.disableBlend();
}
public static void a(final int n, final int n2) {
GlStateManager.blendFunc(n, n2);
}
public static void a(final int n, final int n2, final int n3, final int n4) {
GlStateManager.tryBlendFuncSeparate(n, n2, n3, n4);
}
public static void i() {
GlStateManager.enableFog();
}
public static void j() {
GlStateManager.disableFog();
}
public static void b(final int n) {
GlStateManager.setFog(n);
}
public static void a(final float n) {
GlStateManager.setFogDensity(n);
}
public static void b(final float n) {
GlStateManager.setFogStart(n);
}
public static void c(final float n) {
GlStateManager.setFogEnd(n);
}
public static void k() {
GlStateManager.enableCull();
}
public static void l() {
GlStateManager.disableCull();
}
public static void c(final int n) {
GlStateManager.cullFace(n);
}
public static void m() {
GlStateManager.enablePolygonOffset();
}
public static void n() {
GlStateManager.disablePolygonOffset();
}
public static void a(final float n, final float n2) {
GlStateManager.doPolygonOffset(n, n2);
}
public static void o() {
GlStateManager.enableColorLogic();
}
public static void p() {
GlStateManager.disableColorLogic();
}
public static void d(final int n) {
GlStateManager.colorLogicOp(n);
}
public static void e(final int n) {
GlStateManager.setActiveTexture(n);
}
public static void q() {
GlStateManager.enableTexture2D();
}
public static void r() {
GlStateManager.disableTexture2D();
}
public static void a(final float n, final float n2, final float n3, final float n4) {
GlStateManager.color(n, n2, n3, n4);
}
public static void a(final float n, final float n2, final float n3) {
GlStateManager.color(n, n2, n3);
}
public static void s() {
GlStateManager.resetColor();
}
public static void f(final int n) {
GlStateManager.callList(n);
}
public static void t() {
GlStateManager.pushMatrix();
}
public static void u() {
GlStateManager.popMatrix();
}
public static void b(final float n, final float n2, final float n3, final float n4) {
GlStateManager.rotate(n, n2, n3, n4);
}
public static void b(final float n, final float n2, final float n3) {
GlStateManager.scale(n, n2, n3);
}
public static void a(final double n, final double n2, final double n3) {
GlStateManager.scale(n, n2, n3);
}
public static void c(final float n, final float n2, final float n3) {
GlStateManager.translate(n, n2, n3);
}
public static void b(final double n, final double n2, final double n3) {
GlStateManager.translate(n, n2, n3);
}
public static void b(final int n, final int n2, final int n3, final int n4) {
OpenGlHelper.glBlendFunc(n, n2, n3, n4);
}
public static boolean v() {
return OpenGlHelper.areShadersSupported();
}
public static void w() {
RenderHelper.enableStandardItemLighting();
}
public static void x() {
RenderHelper.disableStandardItemLighting();
}
public static void y() {
RenderHelper.enableGUIStandardItemLighting();
}
public static void g(final int n) {
GlStateManager.shadeModel(n);
}
public static boolean z() {
return GLContext.getCapabilities().OpenGL15;
}
public static boolean A() {
return GLContext.getCapabilities().OpenGL21;
}
public static void a(final int n, final IntBuffer intBuffer) {
GL11.glGetInteger(n, intBuffer);
}
public static void a(final int n, final FloatBuffer floatBuffer) {
GL11.glGetFloat(n, floatBuffer);
}
public static void h(final int n) {
GlStateManager.clear(n);
}
}

View File

@ -0,0 +1,120 @@
package net.silentclient.client.config;
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.gui.SilentScreen;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.Checkbox;
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.MouseCursorHandler;
import net.silentclient.client.utils.NotificationUtils;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
public class AddConfigModal extends SilentScreen {
private final GuiScreen parentScreen;
private int modalWidth;
private int modalHeight;
private boolean cloneConfig;
public AddConfigModal(GuiScreen parentScreen) {
this.parentScreen = parentScreen;
this.modalWidth = 200;
this.modalHeight = 90;
}
@Override
public void initGui() {
MenuBlurUtils.loadBlur();
defaultCursor = false;
this.cloneConfig = false;
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("Config Name"));
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
switch (button.id) {
case 1:
mc.displayGuiScreen(parentScreen);
break;
case 2:
if(this.silentInputs.get(0).getValue().length() != 0) {
String result = Client.getInstance().configManager.newConfig(this.silentInputs.get(0).getValue() + ".txt", cloneConfig);
if(!result.equals("success")) {
NotificationUtils.showNotification("Error", result);
} else {
mc.displayGuiScreen(parentScreen);
}
} else {
NotificationUtils.showNotification("Error", "Please enter a Config Name");
}
break;
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
MenuBlurUtils.renderBackground(this);
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
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);
Checkbox.render(mouseX, mouseY, x + 3, y + 50, "Clone Current Config", cloneConfig);
if(Checkbox.isHovered(mouseX, mouseY, x + 3, y + 50)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
super.drawScreen(mouseX, mouseY, partialTicks);
GlStateManager.popMatrix();
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
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);
if(Checkbox.isHovered(mouseX, mouseY, x + 3, y + 50)) {
this.cloneConfig = !this.cloneConfig;
}
}
@Override
public void onGuiClosed() {
MenuBlurUtils.unloadBlur();
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == Keyboard.KEY_ESCAPE) {
mc.displayGuiScreen(parentScreen);
return;
};
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
}
}

View File

@ -0,0 +1,289 @@
package net.silentclient.client.config;
import net.minecraft.client.Minecraft;
import net.silentclient.client.Client;
import net.silentclient.client.gui.hud.ScreenPosition;
import net.silentclient.client.gui.notification.NotificationManager;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModDraggable;
import net.silentclient.client.mods.Setting;
import net.silentclient.client.mods.player.AutoTextMod.AutoTextCommand;
import net.silentclient.client.utils.FileUtils;
import net.silentclient.client.utils.MenuBlurUtils;
import java.awt.*;
import java.io.*;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class ConfigManager {
public File configFile;
private Set<String> configs;
private boolean creatingDefaultConfigNeeded;
public ConfigManager() {
updateConfigs();
String config = Client.getInstance().getGlobalSettings().getConfig();
configFile = new File(Client.getInstance().configDir, config);
if(!configFile.exists()) {
creatingDefaultConfigNeeded = true;
}
this.load();
}
public void postInit() {
if(creatingDefaultConfigNeeded) {
configFile.delete();
newConfig("Default.txt", false);
}
}
public Set<String> getConfigFiles() {
return this.configs;
}
public void updateConfigs() {
Client.logger.info("Updating Config List");
this.configs = Stream.of(Client.getInstance().configDir.listFiles())
.filter(file -> !file.isDirectory())
.map(File::getName)
.collect(Collectors.toSet());
}
public void deleteConfig(String name) {
try {
new File(Client.getInstance().configDir, name).delete();
} catch (Exception err) {
err.printStackTrace();
}
updateConfigs();
}
public void loadConfig(String name) {
Client.logger.info("Loading Config: " + name);
Client.getInstance().getGlobalSettings().setConfig(name);
configFile = new File(Client.getInstance().configDir, name);
if(!configFile.exists()) {
try {
configFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
this.load();
this.save();
for(Mod m : Client.getInstance().getModInstances().getMods()) {
if(m.isEnabled()) {
m.toggle();
m.toggle();
}
}
NotificationManager.clear();
Client.getInstance().getGlobalSettings().save();
}
public String newConfig(String name, boolean clone) {
Client.logger.info("Creating Config: " + 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.";
} else {
if(clone) {
try {
testConfig.createNewFile();
} catch (IOException e) {
Client.logger.catching(e);
return "Error: " + e.getMessage();
}
}
}
Client.getInstance().getGlobalSettings().setConfig(name);
Client.getInstance().getGlobalSettings().save();
configFile = testConfig;
if(!clone) {
Client.getInstance().getModInstances().getMods().forEach(mod -> mod.reset(true));
try {
FileUtils.exportResource("/assets/minecraft/silentclient/configs/Default.txt", String.format(Client.getInstance().configDir.toString() + "/%s", name));
} catch (Exception e) {
Client.logger.catching(e);
}
} else {
this.save();
}
this.load();
if(clone) {
for(Mod m : Client.getInstance().getModInstances().getMods()) {
if(m.isEnabled()) {
m.toggle();
m.toggle();
}
}
}
updateConfigs();
return "success";
}
public void load() {
try (BufferedReader reader = new BufferedReader(new FileReader(this.configFile))) {
String s;
Client.getInstance().getModInstances().getAutoText().commands.clear();
while((s = reader.readLine()) != null) {
String[] args = s.split(":");
if (s.toLowerCase().startsWith("mod:")) {
try {
Mod m = Client.getInstance().getModInstances().getModByName(args[1]);
if (m != null) {
m.setEnabled(Boolean.parseBoolean(args[2]));
m.setToggled(Boolean.parseBoolean(args[2]));
}
} catch (Exception err) {
err.printStackTrace();
}
}
if (s.toLowerCase().startsWith("pos:")) {
try {
Mod m = Client.getInstance().getModInstances().getModByName(args[1]);
if (m != null && m instanceof ModDraggable) {
ModDraggable md = (ModDraggable) m;
md.setPos(ScreenPosition.fromRelativePosition(Double.parseDouble(args[2]), Double.parseDouble(args[3])));
md.getPos().setRelative(Double.parseDouble(args[2]), Double.parseDouble(args[3]));
}
} catch (Exception err) {
err.printStackTrace();
}
}
if (s.toLowerCase().startsWith("set:")) {
Mod m = Client.getInstance().getModInstances().getModByName(args[2]);
if (m != null) {
Setting set = Client.getInstance().getSettingsManager().getSettingByName(m, args[1]);
if (set != null) {
if (set.isCheck()) {
try {
set.setValBoolean(Boolean.parseBoolean(args[3]));
if(set.getName() == "Menu Background Blur") {
if(Minecraft.getMinecraft().currentScreen != null) {
if(!set.getValBoolean()) {
MenuBlurUtils.unloadBlur(true);
} else {
MenuBlurUtils.loadBlur(true);
}
}
}
} catch (Exception err) {
}
}
if(set.isKeybind()) {
try {
set.setKeybind(Integer.parseInt(args[3]));
} catch (Exception err) {
}
}
if (set.isCombo()) {
try {
if(set.getOptions().contains(args[3])) {
set.setValString(args[3]);
}
} catch (Exception err) {
}
}
if (set.isSlider()) {
try {
if(Double.parseDouble(args[3]) >= set.getMin() && Double.parseDouble(args[3]) <= set.getMax()) {
set.setValDouble(Double.parseDouble(args[3]));
}
} catch (Exception err) {
}
}
if(set.isInput()) {
try {
set.setValString(args[3]);
} catch (Exception err) {
}
}
if (set.isColor()) {
try {
set.setValColor(new Color(Integer.parseInt(args[3])));
} catch (Exception err) {
}
try {
set.setChroma(Boolean.parseBoolean(args[4]));
} catch (Exception err) {
}
try {
set.setOpacity(Integer.parseInt(args[5]));
} catch (Exception err) {
}
}
}
}
}
if (s.toLowerCase().startsWith("atc:")) {
try {
Client.getInstance().getModInstances().getAutoText().addCommand(args[1], Integer.parseInt(args[2]));
} catch (Exception err) {
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
public void save() {
Client.logger.info("Saving Config: " + this.configFile.getName());
try(PrintWriter writer = new PrintWriter(this.configFile)) {
for(Mod m : Client.getInstance().getModInstances().getMods()) {
writer.println("MOD:" + m.getName() + ":" + m.isToggled());
if(m instanceof ModDraggable) {
ModDraggable md = (ModDraggable) m;
writer.println("POS:" + m.getName() + ":" + md.getPos().getRelitiveX() + ":" + md.getPos().getRelitiveY());
}
}
for(Setting set : Client.getInstance().getSettingsManager().getSettings()) {
if (set.isCheck()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getValBoolean());
}
if (set.isCombo()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getValString());
}
if (set.isSlider()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getValDouble());
}
if (set.isColor()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getClearColor().getRGB() + ":" + set.isChroma() + ":" + set.getOpacity());
}
if(set.isInput()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getValString());
}
if(set.isKeybind()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getKeybind());
}
}
for(AutoTextCommand command : Client.getInstance().getModInstances().getAutoText().getCommands()) {
writer.println("ATC:"+command.getCommand()+":"+command.getKey());
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,127 @@
package net.silentclient.client.cosmetics;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.item.ItemStack;
import net.silentclient.client.Client;
import net.silentclient.client.blc.BlcGlStateManager;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
public class AbstractShieldRenderer extends ModelBase implements LayerRenderer<AbstractClientPlayer> {
private final RenderPlayer playerRenderer;
public AbstractShieldRenderer(RenderPlayer playerRendererIn)
{
this.playerRenderer = playerRendererIn;
}
@Override
public void doRenderLayer(AbstractClientPlayer entity, float p_177141_2_, float p_177141_3_,
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
if(((AbstractClientPlayerExt) entity).silent$getShield() == null || !Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Shields").getValBoolean() || entity.isInvisible() || !Client.getInstance().getCosmetics().shieldModels.containsKey(((AbstractClientPlayerExt) entity).silent$getShield().getModel()) || !Client.getInstance().getCosmetics().shieldModels.get(((AbstractClientPlayerExt) entity).silent$getShield().getModel()).loadModel()) {
return;
}
BlcGlStateManager.t();
BlcGlStateManager.s();
BlcGlStateManager.a(1.0F, 1.0F, 1.0F, 1.0F);
BlcGlStateManager.g();
BlcGlStateManager.a(770, 771);
BlcGlStateManager.q();
BlcGlStateManager.d();
BlcGlStateManager.t();
if (playerRenderer.getMainModel().bipedLeftArm.rotateAngleZ != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedLeftArm.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
}
if (playerRenderer.getMainModel().bipedLeftArm.rotateAngleY != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedLeftArm.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
}
if (playerRenderer.getMainModel().bipedLeftArm.rotateAngleX != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedLeftArm.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
}
ItemStack chestplate = entity.getCurrentArmor(2);
applyArmTransformations(((AbstractClientPlayerExt) entity).silent$getShield().getModel(), entity.isSneaking(), entity.getSkinType().equals("slim"), chestplate != null);
double d = getShieldScale(((AbstractClientPlayerExt) entity).silent$getShield().getModel());
BlcGlStateManager.a(d, d, d);
BlcGlStateManager.k();
((AbstractClientPlayerExt) entity).silent$getShield().getTexture().bindTexture();
Client.getInstance().getCosmetics().shieldModels.get(((AbstractClientPlayerExt) entity).silent$getShield().getModel()).renderModel();
BlcGlStateManager.c();
BlcGlStateManager.u();
BlcGlStateManager.c(1029);
BlcGlStateManager.l();
BlcGlStateManager.r();
BlcGlStateManager.u();
GlStateManager.enableTexture2D();
((AbstractClientPlayerExt) entity).silent$getShield().getTexture().update(partialTicks);
}
public double getShieldScale(String model) {
if(model.equals("roundshield") || model.equals("hexagon_shield") || model.equals("shield_dollar") || model.equals("zzv4shield2") || model.equals("shield_v4")) {
return 0.100;
}
return 0.007;
}
private void applyArmTransformations(String model, boolean paramBoolean1, boolean paramBoolean2, boolean chestplate) {
switch(model) {
case "shield":
GlStateManager.translate(0.33, 0.45, 0.38);
BlcGlStateManager.b(180.0f, 0.0f, 1.0f, 1.0f);
BlcGlStateManager.b(-90.0f, 1.0f, 0.0f, 0.0f);
BlcGlStateManager.b(-90.0f, 0.0f, 1.0f, 0.0f);
BlcGlStateManager.b(paramBoolean1 ? -0.5799999833106995 : -0.4000000059604645, paramBoolean1 ? -0.72 : -0.5, paramBoolean2 ? 0.13700000524520874 : 0.2);
if(chestplate) {
GlStateManager.translate(0, 0, 0.055 + (paramBoolean2 ? 0.055 : 0));
}
break;
case "roundshield":
case "zzv4shield2":
GlStateManager.translate(0.33, 0.35, 0);
BlcGlStateManager.b(-90.0F, 0.0F, 1.0F, 0.0F);
BlcGlStateManager.b(paramBoolean1 ? -0.10000000149011612D : 0.0D, paramBoolean1 ? 0.45D : 0.25D, paramBoolean2 ? -0.1399999964237213D : -0.2D);
BlcGlStateManager.b(180.0F, 0.0F, 0.0F, 1.0F);
if(chestplate) {
GlStateManager.translate(0, 0, -0.06 + (paramBoolean2 ? -0.055 : 0));
}
break;
case "hexagon_shield":
GlStateManager.translate(0.75F, 0.35, 0);
BlcGlStateManager.b(90.0F, 0.0F, 1.0F, 0.0F);
BlcGlStateManager.b(paramBoolean1 ? 0.2 : 0, paramBoolean1 ? 0.45D : 0.25D, (paramBoolean2 ? -0.28D : -0.2D) + (paramBoolean1 ? -0.02 : 0));
BlcGlStateManager.b(180.0F, 0.0F, 0.0F, 1.0F);
if(chestplate) {
GlStateManager.translate(0, 0, 0.06 + (paramBoolean2 ? 0.051 : 0));
}
break;
case "shield_dollar":
GlStateManager.translate(0.70F, 0.35, 0);
BlcGlStateManager.b(90.0F, 0.0F, 1.0F, 0.0F);
BlcGlStateManager.b(paramBoolean1 ? 0.2 : 0, paramBoolean1 ? 0.45D : 0.25D, (paramBoolean2 ? -0.265D : -0.2D) + (paramBoolean1 ? -0.02 : 0));
BlcGlStateManager.b(180.0F, 0.0F, 0.0F, 1.0F);
if(chestplate) {
GlStateManager.translate(0, 0, 0.06 + (paramBoolean2 ? 0.055 : 0));
}
break;
case "shield_v4":
GlStateManager.translate(0.33, 0.35, 0);
BlcGlStateManager.b(-90.0F, 0.0F, 1.0F, 0.0F);
BlcGlStateManager.b(paramBoolean1 ? -0.10000000149011612D : 0.0D, paramBoolean1 ? 0.45D : 0.25D, paramBoolean2 ? -0.1399999964237213D : -0.2D);
BlcGlStateManager.b(180.0F, 90.0F, 0.0F, 1.0F);
if(chestplate) {
GlStateManager.translate(0, 0, -0.06 + (paramBoolean2 ? -0.055 : 0));
}
break;
}
}
@Override
public boolean shouldCombineTextures() {
return false;
}
}

View File

@ -0,0 +1,100 @@
package net.silentclient.client.cosmetics;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.mixin.ducks.TextureManagerExt;
import net.silentclient.client.utils.TimerUtils;
import java.util.ArrayList;
public class AnimatedResourceLocation {
protected final String folder;
protected final int frames;
protected final int fpt;
private int currentFrame = 0;
private TimerUtils timer = new TimerUtils();
protected ResourceLocation[] textures;
public ArrayList<ResourceLocation> bindedFrames = new ArrayList<ResourceLocation>();
private boolean binding;
public AnimatedResourceLocation(String folder, int frames, int fpt) {
this(folder, frames, fpt, false, false);
}
public AnimatedResourceLocation(String folder, int frames, int fpt, boolean clear) {
this(folder, frames, fpt, clear, false);
}
public AnimatedResourceLocation(String folder, int frames, int fpt, boolean clear, boolean bind) {
this.folder = folder;
this.frames = frames;
this.fpt = fpt;
if(!clear) {
textures = new ResourceLocation[frames];
for(int i = 0; i < frames; i++) {
if(bind) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(folder + "/" + i + ".png"));
}
textures[i] = new ResourceLocation(folder + "/" + i + ".png");
}
}
}
public int getCurrentFrame() {
return currentFrame;
}
public ArrayList<ResourceLocation> getBindedFrames() {
return bindedFrames;
}
public ResourceLocation getTexture() {
return textures[currentFrame];
}
public int getFrames() {
return frames;
}
public ResourceLocation[] getTextures() {
return textures;
}
public void bindTexture() {
if(currentFrame == 0) {
binding = false;
Minecraft.getMinecraft().getTextureManager().bindTexture(this.getTexture());
return;
}
binding = ((TextureManagerExt) Minecraft.getMinecraft().getTextureManager()).waitBindTexture(new StaticResourceLocation(this.getTexture().getResourcePath()), new StaticResourceLocation(this.getTextures()[0].getResourcePath()), 1000);
}
public void setCurrentFrame(int currentFrame) {
this.currentFrame = currentFrame;
}
public void update(float deltaTick) {
if(textures.length == 1) {
currentFrame = 0;
return;
}
if(this.binding) {
return;
}
if(timer.delay(this.fpt)) {
currentFrame++;
if(currentFrame > textures.length - 1) {
currentFrame = 0;
}
timer.reset();
}
}
}

View File

@ -0,0 +1,170 @@
package net.silentclient.client.cosmetics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.item.ItemStack;
import net.silentclient.client.Client;
import net.silentclient.client.blc.BlcGlStateManager;
import net.silentclient.client.mixin.injection.accessors.MinecraftAccessor;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.utils.ColorUtils;
public class BandanaRenderer extends ModelBase implements LayerRenderer<AbstractClientPlayer> {
private final RenderPlayer playerRenderer;
private static HashMap<UUID, Integer> uuidToHatLayer = new HashMap<UUID, Integer>();
private static HashSet<UUID> checkedUuids = new HashSet<UUID>();
public BandanaRenderer(RenderPlayer playerRendererIn)
{
this.playerRenderer = playerRendererIn;
}
@Override
public void doRenderLayer(AbstractClientPlayer entityIn, float p_177141_2_, float p_177141_3_,
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
if(Client.getInstance().getCosmetics().getBandana() == null || !Client.getInstance().getCosmetics().getBandana().loadModel() || !Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Bandanas").getValBoolean() || ((AbstractClientPlayerExt) entityIn).silent$getBandana() == null || entityIn.isInvisible()) {
return;
}
GlStateManager.pushMatrix();
BlcGlStateManager.t();
BlcGlStateManager.s();
BlcGlStateManager.g();
BlcGlStateManager.a(770, 771);
BlcGlStateManager.q();
BlcGlStateManager.d();
BlcGlStateManager.t();
if(entityIn.isSneaking()) {
GlStateManager.translate(0.0f, 0.25f, 0.0f);
}
if (playerRenderer.getMainModel().bipedHead.rotateAngleZ != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
}
if (playerRenderer.getMainModel().bipedHead.rotateAngleY != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
}
if (playerRenderer.getMainModel().bipedHead.rotateAngleX != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
}
double applyTransformations = this.applyTransformations();
if(((AbstractClientPlayerExt) entityIn).silent$getAccount() != null && ((AbstractClientPlayerExt) entityIn).silent$getBandana().getTexture().getResourcePath().equals("silentclient/cosmetics/bandanas/17/0.png")) {
if(((AbstractClientPlayerExt) entityIn).silent$getAccount().getBandanaColor() == 50) {
ColorUtils.setColor(ColorUtils.getChromaColor(0, 0, 1).getRGB());
} else {
ColorUtils.setColor(((AbstractClientPlayerExt) entityIn).silent$getAccount().getBandanaColor());
}
}
applyTransformations += this.manipulate(entityIn);
GlStateManager.scale(applyTransformations, applyTransformations, applyTransformations);
((AbstractClientPlayerExt) entityIn).silent$getBandana().bindTexture();
BlcGlStateManager.k();
Client.getInstance().getCosmetics().getBandana().renderModel();
BlcGlStateManager.c();
BlcGlStateManager.u();
BlcGlStateManager.c(1029);
BlcGlStateManager.l();
BlcGlStateManager.r();
BlcGlStateManager.u();
GlStateManager.enableTexture2D();
GlStateManager.popMatrix();
((AbstractClientPlayerExt) entityIn).silent$getBandana().update(partialTicks);
}
private void runSkinProcessing(final UUID uuid, final String s) {
if (BandanaRenderer.checkedUuids.contains(uuid)) {
return;
}
BandanaRenderer.checkedUuids.add(uuid);
new Thread(new Runnable() {
@Override
public void run() {
final String substring = s;
final String string = ((MinecraftAccessor) Minecraft.getMinecraft()).getFileAssets().getAbsolutePath() + "/skins/" + substring.substring(0, 2) + "/" + s;
try {
BandanaRenderer.uuidToHatLayer.put(uuid, BandanaRenderer.findMaxHatLayer(ImageIO.read(new File(string))));
BandanaRenderer.checkedUuids.remove(uuid);
}
catch (final Exception ex) {
try {
Thread.sleep(1000L);
}
catch (final InterruptedException ex2) {}
BandanaRenderer.checkedUuids.remove(uuid);
}
}
}).start();
}
public static int findMaxHatLayer(final BufferedImage bufferedImage) {
for (int i = 8, n = 8; i < 16; ++i, --n) {
for (int j = 32; j < 64; ++j) {
if (bufferedImage.getRGB(j, i) >> 24 != 0) {
return n;
}
}
}
return 0;
}
private double applyTransformations() {
GlStateManager.rotate(180.0f, 0.0f, 0.0f, 1.0f);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
final Vector4f rotations = new Vector4f(180.0f, 0.0f, 1.0f, 0.0f);
final Vector3f translations = new Vector3f(0.0f, 0.375f, 0.0f);
GlStateManager.rotate(rotations.x, rotations.y, rotations.z, rotations.w);
GlStateManager.translate(translations.x, translations.y, translations.z);
return 0.068F;
}
private double manipulate(AbstractClientPlayer entity) {
double n = 0.0;
GlStateManager.translate(0.0, -1 * 0.06, 0.0);
ItemStack helmet = entity.getCurrentArmor(3);
if(helmet != null) {
n = 0.012;
} else {
final Integer n2 = BandanaRenderer.uuidToHatLayer.get(entity.getUniqueID());
if (n2 == null) {
this.runSkinProcessing(entity.getUniqueID(), entity.getLocationSkin().getResourcePath().replace("skins/", ""));
return n;
}
if (n2 == 0) {
return n;
}
if (n2 > 4) {
n = 0.001;
}
}
return n;
}
@Override
public boolean shouldCombineTextures() {
// TODO Auto-generated method stub
return false;
}
}

View File

@ -0,0 +1,142 @@
package net.silentclient.client.cosmetics;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.silentclient.client.Client;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.utils.AngleUtilities;
public class CapeRenderer extends ModelBase implements LayerRenderer<AbstractClientPlayer> {
private final RenderPlayer playerRenderer;
private ModelRenderer bipedCloakShoulders;
public CapeRenderer(RenderPlayer playerRendererIn)
{
this.playerRenderer = playerRendererIn;
this.bipedCloakShoulders = new ModelRenderer(this, 0, 17);
this.bipedCloakShoulders.setTextureSize(22, 23);
this.bipedCloakShoulders.addBox(-5.0F, -1.0F, -2.0F, 2, 1, 5, 0.0F);
this.bipedCloakShoulders.addBox(3.0F, -1.0F, -2.0F, 2, 1, 5, 0.0F);
}
@Override
public void doRenderLayer(AbstractClientPlayer entitylivingbaseIn, float p_177141_2_, float p_177141_3_,
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
if(((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCape() == null) {
return;
}
if (entitylivingbaseIn.isInvisible()) {
return;
}
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getDynamicCape().ticks(System.nanoTime());
String capeType = ((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCapeType();
GlStateManager.pushMatrix();
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCape().bindTexture();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
GlStateManager.disableLighting();
GlStateManager.color(1, 1, 1);
double prevX = entitylivingbaseIn.prevChasingPosX + (entitylivingbaseIn.chasingPosX - entitylivingbaseIn.prevChasingPosX) * (double)partialTicks - (entitylivingbaseIn.prevPosX + (entitylivingbaseIn.posX - entitylivingbaseIn.prevPosX) * (double)partialTicks);
double prevY = entitylivingbaseIn.prevChasingPosY + (entitylivingbaseIn.chasingPosY - entitylivingbaseIn.prevChasingPosY) * (double)partialTicks - (entitylivingbaseIn.prevPosY + (entitylivingbaseIn.posY - entitylivingbaseIn.prevPosY) * (double)partialTicks);
double prevZ = entitylivingbaseIn.prevChasingPosZ + (entitylivingbaseIn.chasingPosZ - entitylivingbaseIn.prevChasingPosZ) * (double)partialTicks - (entitylivingbaseIn.prevPosZ + (entitylivingbaseIn.posZ - entitylivingbaseIn.prevPosZ) * (double)partialTicks);
float prevRenderYaw = entitylivingbaseIn.prevRenderYawOffset + (entitylivingbaseIn.renderYawOffset - entitylivingbaseIn.prevRenderYawOffset) * partialTicks;
float prevCameraYaw = entitylivingbaseIn.prevCameraYaw + (entitylivingbaseIn.cameraYaw - entitylivingbaseIn.prevCameraYaw) * partialTicks;
double distanceWalkedModified = entitylivingbaseIn.prevDistanceWalkedModified + (entitylivingbaseIn.distanceWalkedModified - entitylivingbaseIn.prevDistanceWalkedModified) * partialTicks;
final double a = AngleUtilities .a((double)(prevRenderYaw * 3.1415927f / 180.0f));
final double n2 = -AngleUtilities .b(prevRenderYaw * 3.1415927f / 180.0f);
float a2 = AngleUtilities .a((float)prevY * 10.0f, -6.0f, 32.0f);
float n3 = (float)(prevX * a + prevZ * n2) * 100.0f;
final float n4 = (float)(prevX * n2 - prevZ * a) * 100.0f;
if (n3 < 0.0f) {
n3 = 0.0f;
}
if (n3 > 165.0f) {
n3 = 165.0f;
}
if(entitylivingbaseIn.isSneaking()) {
n3 += 5.0F;
GlStateManager.translate(0.0F, 0.1F, 0.0F);
a2 += 25.0F;
GlStateManager.translate(0.0F, 0.05F, -0.0178F);
}
float n5 = a2 + (float) (AngleUtilities.a(6.0f * prevCameraYaw)) * (float) (16.0f * distanceWalkedModified);
GlStateManager.scale(0.0625f, 0.0625f, 0.0625f);
GlStateManager.translate(0.0f, 0.0f, 2.0f);
GlStateManager.rotate(6.0f + Math.min(n3 / 2.0f + n5, 90.0f), 1.0f, 0.0f, 0.0f);
GlStateManager.rotate(n4 / 2.0f, 0.0f, 0.0f, 1.0f);
GlStateManager.rotate(-n4 / 2.0f, 0.0f, 1.0f, 0.0f);
GlStateManager.rotate(-90.0f, 0.0f, 1.0f, 0.0f);
GlStateManager.rotate(180.0f, 1.0f, 0.0f, 0.0f);
if(Client.getInstance().getSettingsManager().getSettingByClass(FPSBoostMod.class, "Low Graphics Mode").getValBoolean()) {
capeType = "rectangle";
}
switch(capeType) {
case "dynamic_curved":
final float max = Math.max(Math.min(0.0f, n5), -3.0f);
final float min = Math.min(n3 + n5, 90.0f);
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getDynamicCape().renderDynamicCape();
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getDynamicCape().update(min, max, true);
break;
case "curved_rectangle":
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCurvedCape().renderStaticCape();
break;
default:
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getStaticCape().renderStaticCape();
break;
}
GlStateManager.translate(0.0f, 0.0f, 0.125f);
GlStateManager.rotate(6.0f + n3 / 2.0f + n5, 1.0f, 0.0f, 0.0f);
GlStateManager.rotate(n4 / 2.0f, 0.0f, 0.0f, 1.0f);
GlStateManager.rotate(-n4 / 2.0f, 0.0f, 1.0f, 0.0f);
GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f);
GlStateManager.popMatrix();
if(((AbstractClientPlayerExt) entitylivingbaseIn).silent$getShoulders()) {
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCapeShoulders().bindTexture();
GlStateManager.pushMatrix();
if(entitylivingbaseIn.isSneaking()) {
GlStateManager.translate(0.0F, 0.2F, 0.0F);
GlStateManager.rotate(10.0F, 1.0F, 0.0F, 0.0F);
}
GlStateManager.rotate(-n4 / 2.0F, 0.0F, 1.0F, 0.0F);
this.bipedCloakShoulders.render(0.0625F);
GlStateManager.popMatrix();
}
GlStateManager.enableLighting();
if(((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCape() != null) {
((AbstractClientPlayerExt) entitylivingbaseIn).silent$getCape().update(partialTicks);
}
}
@Override
public boolean shouldCombineTextures() {
return false;
}
}

View File

@ -0,0 +1,316 @@
package net.silentclient.client.cosmetics;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.cosmetics.model.ModelBuffer;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.utils.Players;
import net.silentclient.client.utils.Requests;
import net.silentclient.client.utils.types.PlayerResponse;
import net.silentclient.client.utils.types.PlayerResponse.Account.Cosmetics.CosmeticItem;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class Cosmetics {
public Map<Number, AnimatedResourceLocation> capes = new HashMap<>();
public Map<Number, StaticResourceLocation> capesShoulders = new HashMap<>();
public Map<Number, AnimatedResourceLocation> wings = new HashMap<>();
public Map<Number, AnimatedResourceLocation> bandanas = new HashMap<>();
public Map<Number, HatData> hats = new HashMap<>();
public Map<Number, ShieldData> shields = new HashMap<>();
public Map<Number, StaticResourceLocation> icons = new HashMap<>();
public ArrayList<CosmeticItem> myIcons = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myWings = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myCapes = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myBandanas = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myHats = new ArrayList<CosmeticItem>();
public ArrayList<CosmeticItem> myShields = new ArrayList<CosmeticItem>();
public StaticResourceLocation defaultIcon;
private ModelBuffer bandana;
public Map<String, ModelBuffer> hatModels = new HashMap<>();
public Map<String, ModelBuffer> shieldModels = new HashMap<>();
public void init() {
init(true);
}
public void init(boolean cosmeticInit) {
if(cosmeticInit) {
Client.logger.info("STARTING > cosmeitcs > bandana_model");
try {
bandana = new ModelBuffer(new ResourceLocation("silentclient/models/bandana.obj"));
} catch (Exception e) {
e.printStackTrace();
}
Client.logger.info("STARTING > cosmeitcs > default_icon");
defaultIcon = new StaticResourceLocation("silentclient/icons/player_icon.png");
PlayerResponse.Account.Cosmetics allCosmetics = getAllCosmetics();
Client.logger.info("STARTING > cosmeitcs > capes");
capes.clear();
capesShoulders.clear();
if(allCosmetics != null && allCosmetics.getCapes() != null) {
allCosmetics.getCapes().forEach((cape) -> {
capes.put(cape.getId(), new AnimatedResourceLocation("silentclient/cosmetics/capes/"+cape.getId(), cape.getFrames(), cape.getFrameDelay(), false, cape.getId() == Client.getInstance().getAccount().getSelectedCape()));
capesShoulders.put(cape.getId(), new StaticResourceLocation("silentclient/cosmetics/capes/"+cape.getId()+"/shoulders.png"));
});
}
Client.logger.info("STARTING > cosmeitcs > wings");
wings.clear();
if(allCosmetics != null && allCosmetics.getWings() != null) {
allCosmetics.getWings().forEach((wing) -> {
wings.put(wing.getId(), new AnimatedResourceLocation("silentclient/cosmetics/wings/"+ wing.getId(), wing.getFrames(), wing.getFrameDelay(), false, wing.getId() == Client.getInstance().getAccount().getSelectedWings()));
});
}
Client.logger.info("STARTING > cosmeitcs > bandanas");
bandanas.clear();
if(allCosmetics != null && allCosmetics.getBandanas() != null) {
allCosmetics.getBandanas().forEach((bandana) -> {
bandanas.put(bandana.getId(), new AnimatedResourceLocation("silentclient/cosmetics/bandanas/"+bandana.getId(), bandana.getFrames(), bandana.getFrameDelay(), false, bandana.getId() == Client.getInstance().getAccount().getSelectedBandana()));
});
}
Client.logger.info("STARTING > cosmeitcs > hats");
hats.clear();
if(allCosmetics != null && allCosmetics.getHats() != null) {
allCosmetics.getHats().forEach((hat) -> {
hats.put(hat.getId(), new HatData(new AnimatedResourceLocation("silentclient/cosmetics/hats/"+hat.getId(), hat.getFrames(), hat.getFrameDelay(), false, hat.getId() == Client.getInstance().getAccount().getSelectedHat()), hat.getModel()));
if(!hatModels.containsKey(hat.getModel())) {
try {
Client.logger.info("STARTING > cosmeitcs > hats > model > " + hat.getModel());
ModelBuffer model = new ModelBuffer(new ResourceLocation("silentclient/models/"+ hat.getModel() + ".obj"));
if(model != null) {
hatModels.put(hat.getModel(), model);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Client.logger.info("STARTING > cosmeitcs > shields");
shields.clear();
if(allCosmetics != null && allCosmetics.getShields() != null) {
allCosmetics.getShields().forEach((shield) -> {
shields.put(shield.getId(), new ShieldData(new AnimatedResourceLocation("silentclient/cosmetics/shields/"+shield.getId(), shield.getFrames(), shield.getFrameDelay(), false, shield.getId() == Client.getInstance().getAccount().getSelectedShield()), shield.getModel()));
if(!hatModels.containsKey(shield.getModel())) {
try {
Client.logger.info("STARTING > cosmeitcs > shields > model > " + shield.getModel());
ModelBuffer model = new ModelBuffer(new ResourceLocation("silentclient/models/"+ shield.getModel() + ".obj"));
if(model != null) {
shieldModels.put(shield.getModel(), model);
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
Client.logger.info("STARTING > cosmeitcs > icons");
icons.clear();
if(allCosmetics != null && allCosmetics.getIcons() != null) {
allCosmetics.getIcons().forEach((icon) -> {
icons.put(icon.getId(), new StaticResourceLocation("silentclient/cosmetics/icons/"+ icon.getId() + "/0.png"));
});
}
Client.logger.info("STARTING > cosmeitcs > outfits");
Outfits.loadOutfits();
}
update(false);
}
public ModelBuffer getBandana() {
return bandana;
}
public void update(boolean async) {
Client.logger.info("Loading Player Information");
if(!async) {
PlayerResponse cosmetics = getCosmetics();
if(cosmetics != null) {
Client.getInstance().setAccount(cosmetics.getAccount());
Client.getInstance().getCosmetics().setMyCapes(cosmetics.getAccount().getCosmetics().getCapes());
Client.getInstance().getCosmetics().setMyWings(cosmetics.getAccount().getCosmetics().getWings());
Client.getInstance().getCosmetics().setMyIcons(cosmetics.getAccount().getCosmetics().getIcons());
Client.getInstance().getCosmetics().setMyBandanas(cosmetics.getAccount().getCosmetics().getBandanas());
Client.getInstance().getCosmetics().setMyHats(cosmetics.getAccount().getCosmetics().getHats());
Client.getInstance().getCosmetics().setMyShields(cosmetics.getAccount().getCosmetics().getShields());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Type").setValString(cosmetics.getAccount().getCapeType().equals("dynamic_curved") ? "Dynamic Curved" : cosmetics.getAccount().getCapeType().equals("curved_rectangle") ? "Curved Rectangle" : "Rectangle");
if(Minecraft.getMinecraft().thePlayer != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setCapeType(cosmetics.getAccount().getCapeType());
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setShoulders(cosmetics.getAccount().getCapeShoulders());
}
}
} else {
(new Thread("update") {
public void run() {
PlayerResponse cosmetics = getCosmetics();
if(cosmetics != null) {
Client.getInstance().setAccount(cosmetics.getAccount());
Client.getInstance().getCosmetics().setMyCapes(cosmetics.getAccount().getCosmetics().getCapes());
Client.getInstance().getCosmetics().setMyWings(cosmetics.getAccount().getCosmetics().getWings());
Client.getInstance().getCosmetics().setMyIcons(cosmetics.getAccount().getCosmetics().getIcons());
Client.getInstance().getCosmetics().setMyBandanas(cosmetics.getAccount().getCosmetics().getBandanas());
Client.getInstance().getCosmetics().setMyHats(cosmetics.getAccount().getCosmetics().getHats());
Client.getInstance().getCosmetics().setMyShields(cosmetics.getAccount().getCosmetics().getShields());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Shoulders").setValBoolean(cosmetics.getAccount().getCapeShoulders());
Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Cape Type").setValString(cosmetics.getAccount().getCapeType().equals("dynamic_curved") ? "Dynamic Curved" : cosmetics.getAccount().getCapeType().equals("curved_rectangle") ? "Curved Rectangle" : "Rectangle");
if(Minecraft.getMinecraft().thePlayer != null) {
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setCapeType(cosmetics.getAccount().getCapeType());
((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$setShoulders(cosmetics.getAccount().getCapeShoulders());
}
}
}
}).start();
}
}
public void setMyCapes(ArrayList<CosmeticItem> myCapes) {
this.myCapes = myCapes;
}
public void setMyIcons(ArrayList<CosmeticItem> myIcons) {
this.myIcons = myIcons;
}
public void setMyWings(ArrayList<CosmeticItem> myWings) {
this.myWings = myWings;
}
public void setMyBandanas(ArrayList<CosmeticItem> myBandanas) {
this.myBandanas = myBandanas;
}
public void setMyHats(ArrayList<CosmeticItem> myHats) {
this.myHats = myHats;
}
public ArrayList<CosmeticItem> getMyHats() {
return myHats;
}
public void setMyShields(ArrayList<CosmeticItem> myShields) {
this.myShields = myShields;
}
public ArrayList<CosmeticItem> getMyShields() {
return myShields;
}
public static PlayerResponse.Account.Cosmetics getAllCosmetics() {
try {
InputStream in = Client.getInstance().getClass().getResourceAsStream("/assets/minecraft/silentclient/cosmetics.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuffer content = new StringBuffer();
String inputLine;
while ((inputLine = reader.readLine()) != null) {
content.append(inputLine);
}
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
in.close();
return gson.fromJson(content.toString(), PlayerResponse.Account.Cosmetics.class);
} catch (Exception e1) {
Client.logger.catching(e1);
return null;
}
}
public static PlayerResponse getCosmetics() {
try {
String content = Requests.get("https://api.silentclient.net/account");
GsonBuilder builder = new GsonBuilder();
Gson gson = builder.create();
PlayerResponse response = gson.fromJson(content.toString(), PlayerResponse.class);
return response;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public AnimatedResourceLocation getWingsById(int id) {
return wings.get(id);
}
public AnimatedResourceLocation getCapeById(int id) {
return capes.get(id);
}
public AnimatedResourceLocation getBandanaById(int id) {
return bandanas.get(id);
}
public HatData getHatById(int id) {;
return hats.get(id);
}
public ShieldData getShieldById(int id) {;
return shields.get(id);
}
public StaticResourceLocation getCapeShoulders(int id) {
return capesShoulders.get(id);
}
public StaticResourceLocation getIconById(int id) {
StaticResourceLocation icon = icons.get(id);
return icon != null ? icon : getDefaultIcon();
}
public StaticResourceLocation getDefaultIcon() {
return defaultIcon;
}
public ArrayList<CosmeticItem> getMyCapes() {
return myCapes;
}
public ArrayList<CosmeticItem> getMyWings() {
return myWings;
}
public ArrayList<CosmeticItem> getMyIcons() {
return myIcons;
}
public ArrayList<CosmeticItem> getMyBandanas() {
return myBandanas;
}
public static void reload(final AbstractClientPlayer player) {
Minecraft.getMinecraft().refreshResources();
Client.getInstance().getCosmetics().update(true);
Players.reload();
Players.getPlayerStatus(false, ((AbstractClientPlayerExt) player).silent$getNameClear(), EntityPlayer.getUUID(player.getGameProfile()), player);
}
}

View File

@ -0,0 +1,19 @@
package net.silentclient.client.cosmetics;
public class HatData {
private final String model;
private final AnimatedResourceLocation texture;
public HatData(AnimatedResourceLocation texture, String model) {
this.model = model;
this.texture = texture;
}
public String getModel() {
return model;
}
public AnimatedResourceLocation getTexture() {
return texture;
}
}

View File

@ -0,0 +1,270 @@
package net.silentclient.client.cosmetics;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.item.ItemStack;
import net.silentclient.client.Client;
import net.silentclient.client.blc.BlcGlStateManager;
import net.silentclient.client.mixin.injection.accessors.MinecraftAccessor;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import org.lwjgl.opengl.GL11;
import javax.imageio.ImageIO;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
public class HatRenderer extends ModelBase implements LayerRenderer<AbstractClientPlayer> {
private final RenderPlayer playerRenderer;
private static HashMap<UUID, Integer> uuidToHatLayer = new HashMap<UUID, Integer>();
private static HashSet<UUID> checkedUuids = new HashSet<UUID>();
public final String type;
public HatRenderer(RenderPlayer playerRendererIn, String type)
{
this.playerRenderer = playerRendererIn;
this.type = type;
}
@Override
public void doRenderLayer(AbstractClientPlayer entityIn, float p_177141_2_, float p_177141_3_,
float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) {
if(!Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Hats").getValBoolean() || entityIn.isInvisible()) {
return;
}
HatData data = null;
switch(type) {
case "hat":
data = ((AbstractClientPlayerExt) entityIn).silent$getHat();
break;
case "mask":
data = ((AbstractClientPlayerExt) entityIn).silent$getMask();
break;
case "neck":
data = ((AbstractClientPlayerExt) entityIn).silent$getNeck();
break;
}
if(data == null || !Client.getInstance().getCosmetics().hatModels.containsKey(data.getModel()) || !Client.getInstance().getCosmetics().hatModels.get(data.getModel()).loadModel()) {
return;
}
GlStateManager.pushMatrix();
BlcGlStateManager.t();
BlcGlStateManager.s();
BlcGlStateManager.g();
BlcGlStateManager.a(770, 771);
BlcGlStateManager.q();
BlcGlStateManager.d();
BlcGlStateManager.t();
if(entityIn.isSneaking()) {
GlStateManager.translate(0.0f, data.getModel().equals("gold_chain") ? 0.2f : 0.25f, 0.0f);
}
switch(data.getModel()) {
case "gold_chain":
if (playerRenderer.getMainModel().bipedBody.rotateAngleZ != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedBody.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
}
if (playerRenderer.getMainModel().bipedBody.rotateAngleY != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedBody.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
}
if (playerRenderer.getMainModel().bipedBody.rotateAngleX != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedBody.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
}
break;
default:
if (playerRenderer.getMainModel().bipedHead.rotateAngleZ != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleZ * (180F / (float) Math.PI), 0.0F, 0.0F, 1.0F);
}
if (playerRenderer.getMainModel().bipedHead.rotateAngleY != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleY * (180F / (float) Math.PI), 0.0F, 1.0F, 0.0F);
}
if (playerRenderer.getMainModel().bipedHead.rotateAngleX != 0.0F) {
GlStateManager.rotate(playerRenderer.getMainModel().bipedHead.rotateAngleX * (180F / (float) Math.PI), 1.0F, 0.0F, 0.0F);
}
break;
}
double applyTransformations = this.applyTransformations(data.getModel());
applyTransformations += this.manipulate(entityIn, data.getModel());
GlStateManager.scale(applyTransformations, applyTransformations, applyTransformations);
data.getTexture().bindTexture();
BlcGlStateManager.k();
Client.getInstance().getCosmetics().hatModels.get(data.getModel()).renderModel();
BlcGlStateManager.c();
BlcGlStateManager.u();
BlcGlStateManager.c(1029);
BlcGlStateManager.l();
BlcGlStateManager.r();
BlcGlStateManager.u();
GlStateManager.popMatrix();
GlStateManager.enableTexture2D();
data.getTexture().update(partialTicks);
}
private void runSkinProcessing(final UUID uuid, final String s) {
if (HatRenderer.checkedUuids.contains(uuid)) {
return;
}
HatRenderer.checkedUuids.add(uuid);
new Thread(new Runnable() {
@Override
public void run() {
final String substring = s;
final String string = ((MinecraftAccessor) Minecraft.getMinecraft()).getFileAssets().getAbsolutePath() + "/skins/" + substring.substring(0, 2) + "/" + s;
try {
HatRenderer.uuidToHatLayer.put(uuid, HatRenderer.findMaxHatLayer(ImageIO.read(new File(string))));
HatRenderer.checkedUuids.remove(uuid);
}
catch (final Exception ex) {
try {
Thread.sleep(1000L);
}
catch (final InterruptedException ex2) {}
HatRenderer.checkedUuids.remove(uuid);
}
}
}).start();
}
public static int findMaxHatLayer(final BufferedImage bufferedImage) {
for (int i = 8, n = 8; i < 16; ++i, --n) {
for (int j = 32; j < 64; ++j) {
if (bufferedImage.getRGB(j, i) >> 24 != 0) {
return n;
}
}
}
return 0;
}
private double applyTransformations(String model) {
GlStateManager.rotate(180.0f, 0.0f, 0.0f, 1.0f);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
Vector4f rotations = new Vector4f(180.0f, 0.0f, 1.0f, 0.0f);
Vector3f translations = null;
double scale = 0.068F;
switch(model) {
case "halo":
case "halo2":
case "sharp_halo":
translations = new Vector3f(0.65f, 0.65f, 0.65f);
scale = 0.08f;
break;
case "cowboy":
translations = new Vector3f(0.0f, 0.5f, 0.0f);
scale = 0.0101f;
break;
case "snapback":
rotations = new Vector4f(180.0f, 90.0f, 1.0f, 0.0f);
translations = new Vector3f(0.0f, 1.5f, 0.0f);
scale = 1;
break;
case "crown":
rotations = null;
translations = new Vector3f(0.08f, 0.4f, 0.0f);
break;
case "flowersnew":
translations = new Vector3f(0.0f, 0.275f, 0.0f);
break;
}
if(rotations != null) {
GlStateManager.rotate(rotations.x, rotations.y, rotations.z, rotations.w);
}
if(translations != null) {
GlStateManager.translate(translations.x, translations.y, translations.z);
}
return scale;
}
private double manipulate(AbstractClientPlayer entity, String model) {
double n = 0.0;
ItemStack helmet = entity.getCurrentArmor(3);
ItemStack chestplate = entity.getCurrentArmor(2);
if(chestplate != null && model.equals("gold_chain")) {
return 0.018;
}
if(helmet != null) {
switch(model) {
case "sombrero":
GL11.glTranslatef(0.0f, 0.065f, 0.0f);
break;
case "cowboy":
GL11.glTranslatef(0.0f, 0.18f, 0.0f);
break;
case "crown_v2":
GL11.glTranslatef(0.0f, 0.15f, 0.0f);
break;
case "panda":
n = 0.018;
GL11.glTranslatef(0.0f, -0.1f, 0.0f);
break;
case "flowersnew":
n = 0.012;
break;
case "zekich_hat":
GL11.glTranslatef(0.0f, 0.01f, 0.0f);
break;
case "gaming_headset":
n = 0.018;
break;
case "snapback":
n = 0.25;
GL11.glTranslatef(0.0f, 0.3f, 0.0f);
break;
}
} else {
final Integer n2 = HatRenderer.uuidToHatLayer.get(entity.getUniqueID());
if (n2 == null) {
this.runSkinProcessing(entity.getUniqueID(), entity.getLocationSkin().getResourcePath().replace("skins/", ""));
return n;
}
if (n2 == 0) {
return n;
}
switch(model) {
case "sombrero":
GL11.glTranslatef(0.0f, 0.04f, 0.0f);
break;
case "bunny_laying_hat":
GL11.glTranslatef(0.0f, -0.06f, 0.0f);
break;
case "zekich_hat":
GL11.glTranslatef(0.0f, -0.05f, 0.0f);
break;
}
}
return n;
}
@Override
public boolean shouldCombineTextures() {
return false;
}
}

View File

@ -0,0 +1,116 @@
package net.silentclient.client.cosmetics;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.silentclient.client.Client;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.utils.Players;
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();
Players.reload();
if(Minecraft.getMinecraft().thePlayer != null) {
Players.getPlayerStatus(false, ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getNameClear(), EntityPlayer.getUUID(Minecraft.getMinecraft().thePlayer.getGameProfile()), Minecraft.getMinecraft().thePlayer);
}
}
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

@ -0,0 +1,19 @@
package net.silentclient.client.cosmetics;
public class ShieldData {
private final String model;
private final AnimatedResourceLocation texture;
public ShieldData(AnimatedResourceLocation texture, String model) {
this.model = model;
this.texture = texture;
}
public String getModel() {
return model;
}
public AnimatedResourceLocation getTexture() {
return texture;
}
}

View File

@ -0,0 +1,119 @@
package net.silentclient.client.cosmetics;
import org.lwjgl.opengl.GL11;
import net.silentclient.client.cosmetics.dynamiccurved.Box;
public class StaticCape {
private final float curvePoints;
private final float horizCurve;
private final float vertCurve;
private Integer staticCloakCallList = null;
public StaticCape(float paramFloat1, float paramFloat2, float paramFloat3) {
this.curvePoints = paramFloat1;
this.horizCurve = paramFloat2;
this.vertCurve = paramFloat3;
}
public void init() {
this.staticCloakCallList = Integer.valueOf(GL11.glGenLists(1));
float f1 = 22.0F;
float f2 = 23.0F;
float f3 = 1.0F / f2;
float f4 = 17.0F / f2;
float f5 = 1.0F / f1;
float f6 = 11.0F / f1;
float f7 = 12.0F / f1;
float f8 = 22.0F / f1;
float f9 = 21.0F / f1;
Box b1 = new Box(0.0F, 0.0F, 5.0F);
Box b2 = new Box(0.0F + this.horizCurve, -16.0F + this.vertCurve, 5.0F);
Box b3 = new Box(0.0F + this.horizCurve, -16.0F + this.vertCurve, -5.0F);
Box b4 = new Box(0.0F, 0.0F, -5.0F);
Box b5 = new Box(1.0F, 0.0F, 5.0F);
Box b6 = new Box(1.0F + this.horizCurve, -16.0F + this.vertCurve, 5.0F);
Box b7 = new Box(1.0F + this.horizCurve, -16.0F + this.vertCurve, -5.0F);
Box b8 = new Box(1.0F, 0.0F, -5.0F);
Box b9 = new Box(0.0F, -10.0F, -5.0F);
Box b10 = new Box(0.0F, -10.0F, -5.0F);
GL11.glNewList(this.staticCloakCallList.intValue(), 4864);
GL11.glBegin(5);
byte b;
for (b = 0; b <= this.curvePoints; b++) {
float f10 = b / this.curvePoints;
float f11 = (1.0F - f10) * (1.0F - f10) * b7.a + 2.0F * (1.0F - f10) * f10 * b9.a + f10 * f10 * b8.a;
float f12 = (1.0F - f10) * (1.0F - f10) * b7.b + 2.0F * (1.0F - f10) * f10 * b9.b + f10 * f10 * b8.b;
GL11.glTexCoord2f(f5, f4 - (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b5.c);
GL11.glTexCoord2f(f6, f4 - (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b8.c);
}
GL11.glTexCoord2f(f5, f3);
GL11.glVertex3f(b5.a, b5.b, b5.c);
GL11.glTexCoord2f(f6, f3);
GL11.glVertex3f(b8.a, b8.b, b8.c);
GL11.glTexCoord2f(f5, 0.0F);
GL11.glVertex3f(b1.a, b1.b, b1.c);
GL11.glTexCoord2f(f6, 0.0F);
GL11.glVertex3f(b4.a, b4.b, b4.c);
for (b = 0; b <= this.curvePoints; b++) {
float f10 = b / this.curvePoints;
float f11 = (1.0F - f10) * (1.0F - f10) * b4.a + 2.0F * (1.0F - f10) * f10 * b10.a + f10 * f10 * b3.a;
float f12 = (1.0F - f10) * (1.0F - f10) * b4.b + 2.0F * (1.0F - f10) * f10 * b10.b + f10 * f10 * b3.b;
GL11.glTexCoord2f(f7, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b8.c);
f11 = (1.0F - f10) * (1.0F - f10) * b8.a + 2.0F * (1.0F - f10) * f10 * b9.a + f10 * f10 * b7.a;
f12 = (1.0F - f10) * (1.0F - f10) * b8.b + 2.0F * (1.0F - f10) * f10 * b9.b + f10 * f10 * b7.b;
GL11.glTexCoord2f(f6, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b8.c);
}
GL11.glTexCoord2f(f9, 0.0F);
GL11.glVertex3f(b7.a, b7.b, b7.c);
GL11.glTexCoord2f(f6, 0.0F);
GL11.glVertex3f(b6.a, b6.b, b6.c);
GL11.glTexCoord2f(f9, f3);
GL11.glVertex3f(b3.a, b3.b, b3.c);
GL11.glTexCoord2f(f6, f3);
GL11.glVertex3f(b2.a, b2.b, b2.c);
for (b = 0; b <= this.curvePoints; b++) {
float f10 = b / this.curvePoints;
float f11 = (1.0F - f10) * (1.0F - f10) * b3.a + 2.0F * (1.0F - f10) * f10 * b10.a + f10 * f10 * b4.a;
float f12 = (1.0F - f10) * (1.0F - f10) * b3.b + 2.0F * (1.0F - f10) * f10 * b10.b + f10 * f10 * b4.b;
GL11.glTexCoord2f(f7, f4 - (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b8.c);
GL11.glTexCoord2f(f8, f4 - (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b5.c);
}
for (b = 0; b <= this.curvePoints; b++) {
float f10 = b / this.curvePoints;
if (b == 0) {
float f13 = (1.0F - f10) * (1.0F - f10) * b4.a + 2.0F * (1.0F - f10) * f10 * b10.a + f10 * f10 * b3.a;
float f14 = (1.0F - f10) * (1.0F - f10) * b4.b + 2.0F * (1.0F - f10) * f10 * b10.b + f10 * f10 * b3.b;
GL11.glTexCoord2f(0.0F, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f13, f14, b5.c);
GL11.glTexCoord2f(0.0F, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f13, f14, b5.c);
}
float f11 = (1.0F - f10) * (1.0F - f10) * b8.a + 2.0F * (1.0F - f10) * f10 * b9.a + f10 * f10 * b7.a;
float f12 = (1.0F - f10) * (1.0F - f10) * b8.b + 2.0F * (1.0F - f10) * f10 * b9.b + f10 * f10 * b7.b;
GL11.glTexCoord2f(f5, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b5.c);
f11 = (1.0F - f10) * (1.0F - f10) * b4.a + 2.0F * (1.0F - f10) * f10 * b10.a + f10 * f10 * b3.a;
f12 = (1.0F - f10) * (1.0F - f10) * b4.b + 2.0F * (1.0F - f10) * f10 * b10.b + f10 * f10 * b3.b;
GL11.glTexCoord2f(0.0F, f3 + (f4 - f3) * f10);
GL11.glVertex3f(f11, f12, b5.c);
}
GL11.glEnd();
GL11.glEndList();
}
public void renderStaticCape() {
if (this.staticCloakCallList == null)
init();
GL11.glCallList(this.staticCloakCallList.intValue());
}
}

View File

@ -0,0 +1,24 @@
package net.silentclient.client.cosmetics;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
public class StaticResourceLocation {
private ResourceLocation location;
public StaticResourceLocation(ResourceLocation location) {
this.location = location;
}
public StaticResourceLocation(String path) {
this.location = new ResourceLocation(path);
}
public ResourceLocation getLocation() {
return location;
}
public void bindTexture() {
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
}
}

View File

@ -0,0 +1,46 @@
package net.silentclient.client.cosmetics.dynamiccurved;
public class Box {
public float a;
public float b;
public float c;
public Box(float f, float f1, float f2)
{
this.a = f;
this.b = f1;
this.c = f2;
}
public Box a(float f, float f1, float f2)
{
this.a = f;
this.b = f1;
this.c = f2;
return this;
}
public Box a(Box bx)
{
float f = (float)Math.sqrt((double)this.a());
return bx == null ? new Box(this.a / f, this.b / f, this.c / f) : bx.a(this.a / f, this.b / f, this.c / f);
}
public float a()
{
return this.a * this.a + this.b * this.b + this.c * this.c;
}
public static Box a(Box b1, Box b2, Box b3)
{
if (b3 == null)
{
return new Box(b1.a + b2.a, b1.b + b2.b, b1.c + b2.c);
}
else
{
b3.a(b1.a + b2.a, b1.b + b2.b, b1.c + b2.c);
return b3;
}
}
}

View File

@ -0,0 +1,250 @@
package net.silentclient.client.cosmetics.dynamiccurved;
import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.ARBVertexBufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
public class DynamicCape {
private long COUNTER = 0L;
private long lastNanoTime = 0L;
private int vertexVbo;
private int textureVbo;
private FloatBuffer vertexBuffer = BufferUtils.createFloatBuffer(294);
private FloatBuffer textureBuffer;
private int vertexCount = 0;
private float lastHorz = 0.0F;
private float lastVert = 0.0F;
private float lastAmplitude = 0.0F;
private boolean deleted = false;
public DynamicCape() {
this.vertexBuffer.flip();
this.vertexVbo = GL15.glGenBuffers();
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.vertexVbo);
GL15.glBufferData(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, (FloatBuffer) this.vertexBuffer, ARBVertexBufferObject.GL_DYNAMIC_DRAW_ARB);
this.textureBuffer = BufferUtils.createFloatBuffer(196);
this.textureBuffer.flip();
this.textureVbo = GL15.glGenBuffers();
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.textureVbo);
GL15.glBufferData(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, (FloatBuffer) this.textureBuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
}
public void ticks(long i) {
if (i - lastNanoTime > 16666666L) {
lastNanoTime = i;
++COUNTER;
}
}
public void update(float f, float f1, boolean flag) {
f = f / 55.0F;
float f2 = (float) COUNTER / 10.0F;
float f3 = f;
float f4 = 1.5F;
if (!this.deleted) {
if (flag || f != this.lastHorz || f1 != this.lastVert || this.lastAmplitude != f || f != 0.0F) {
this.lastAmplitude = f;
this.vertexBuffer.clear();
this.vertexCount = 0;
if (flag) {
this.textureBuffer.clear();
}
float f5 = 22.0F;
float f6 = 23.0F;
float f7 = 1.0F / f6;
float f8 = 17.0F / f6;
float f9 = 1.0F / f5;
float f10 = 11.0F / f5;
float f11 = 12.0F / f5;
float f12 = 22.0F / f5;
Box b = new Box(0.0F, 0.0F, 5.0F);
Box box1 = new Box(0.0F, -16.0F, 5.0F);
Box box2 = new Box(0.0F, -16.0F, -5.0F);
Box box3 = new Box(0.0F, 0.0F, -5.0F);
Box box4 = new Box(1.0F, 0.0F, 5.0F);
Box box5 = new Box(1.0F, -16.0F, 5.0F);
Box box6 = new Box(1.0F, -16.0F, -5.0F);
Box box7 = new Box(1.0F, 0.0F, -5.0F);
Box box8 = new Box(0.0F, -10.0F, -5.0F);
Box box9 = new Box(0.0F, -10.0F, -5.0F);
float f14 = 10.0F;
boolean flag1 = true;
float f15 = (float) Math.sin(Math.PI * (double) f4 + (double) f2) * f;
float f16 = -f15;
for (int i = 0; (float) i <= f14; ++i) {
float f17 = (float) i / f14;
float f18 = (1.0F - f17) * (1.0F - f17) * box6.a + 2.0F * (1.0F - f17) * f17 * box8.a + f17 * f17 * box7.a;
float f19 = (1.0F - f17) * (1.0F - f17) * box6.b + 2.0F * (1.0F - f17) * f17 * box8.b + f17 * f17 * box7.b;
if (flag1) {
f18 = (float) Math.sin((double) f17 * Math.PI * (double) f4 + (double) f2) * f3 + 1.0F + f16;
}
if (flag) {
this.textureBuffer.put(new float[]{f9, f8 - (f8 - f7) * f17});
this.textureBuffer.put(new float[]{f10, f8 - (f8 - f7) * f17});
}
this.vertexBuffer.put(new float[]{f18, f19, box4.c});
this.vertexBuffer.put(new float[]{f18, f19, box7.c});
this.vertexCount += 2;
}
if (flag) {
this.textureBuffer.put(new float[]{0.045454547F, 0.04347826F});
this.textureBuffer.put(new float[]{0.5F, 0.04347826F});
this.textureBuffer.put(new float[]{0.045454547F, 0.0F});
this.textureBuffer.put(new float[]{0.5F, 0.0F});
}
this.vertexBuffer.put(new float[]{box4.a, box4.b, box4.c});
this.vertexBuffer.put(new float[]{box7.a, box7.b, box7.c});
this.vertexBuffer.put(new float[]{b.a, b.b, b.c});
this.vertexBuffer.put(new float[]{box3.a, box3.b, box3.c});
this.vertexCount += 4;
for (int j = 0; (float) j <= f14; ++j) {
float f22 = (float) j / f14;
float f26 = (1.0F - f22) * (1.0F - f22) * box3.b + 2.0F * (1.0F - f22) * f22 * box9.b + f22 * f22 * box2.b;
float f23 = (float) Math.sin((double) (1.0F - f22) * Math.PI * (double) f4 + (double) f2) * f3 + f16;
if (flag) {
this.textureBuffer.put(new float[]{f11, f7 + (f8 - f7) * f22});
this.textureBuffer.put(new float[]{f10, f7 + (f8 - f7) * f22});
}
this.vertexBuffer.put(new float[]{f23, f26, box7.c});
f23 = (1.0F - f22) * (1.0F - f22) * box7.a + 2.0F * (1.0F - f22) * f22 * box8.a + f22 * f22 * box6.a;
f26 = (1.0F - f22) * (1.0F - f22) * box7.b + 2.0F * (1.0F - f22) * f22 * box8.b + f22 * f22 * box6.b;
if (flag1) {
f23 = (float) Math.sin((double) (1.0F - f22) * Math.PI * (double) f4 + (double) f2) * f3 + 1.0F + f16;
}
this.vertexBuffer.put(new float[]{f23, f26, box7.c});
this.vertexCount += 2;
}
if (flag) {
this.textureBuffer.put(new float[]{0.95454544F, 0.0F});
this.textureBuffer.put(new float[]{0.5F, 0.0F});
this.textureBuffer.put(new float[]{0.95454544F, 0.04347826F});
this.textureBuffer.put(new float[]{0.5F, 0.04347826F});
}
float f21 = 0.0F;
if (flag1) {
f21 = (float) Math.sin(0.0D * (double) f4 + (double) f2) * f3 + f16;
}
this.vertexBuffer.put(new float[]{box6.a + f21, box6.b, box6.c});
this.vertexBuffer.put(new float[]{box5.a + f21, box5.b, box5.c});
this.vertexBuffer.put(new float[]{box2.a + f21, box2.b, box2.c});
this.vertexBuffer.put(new float[]{box1.a + f21, box1.b, box1.c});
this.vertexCount += 4;
for (int k = 0; (float) k <= f14; ++k) {
float f24 = (float) k / f14;
float f27 = (1.0F - f24) * (1.0F - f24) * box2.a + 2.0F * (1.0F - f24) * f24 * box9.a + f24 * f24 * box3.a;
float f20 = (1.0F - f24) * (1.0F - f24) * box2.b + 2.0F * (1.0F - f24) * f24 * box9.b + f24 * f24 * box3.b;
if (flag1) {
f27 = (float) Math.sin((double) f24 * Math.PI * (double) f4 + (double) f2) * f3 + f16;
}
if (flag) {
this.textureBuffer.put(new float[]{f11, f8 - (f8 - f7) * f24});
this.textureBuffer.put(new float[]{f12, f8 - (f8 - f7) * f24});
}
this.vertexBuffer.put(new float[]{f27, f20, box7.c});
this.vertexBuffer.put(new float[]{f27, f20, box4.c});
this.vertexCount += 2;
}
for (int l = 0; (float) l <= f14; ++l) {
float f25 = (float) l / f14;
if (l == 0) {
float f28 = (1.0F - f25) * (1.0F - f25) * box3.a + 2.0F * (1.0F - f25) * f25 * box9.a + f25 * f25 * box2.a;
float f30 = (1.0F - f25) * (1.0F - f25) * box3.b + 2.0F * (1.0F - f25) * f25 * box9.b + f25 * f25 * box2.b;
if (flag) {
this.textureBuffer.put(new float[]{0.0F, f7 + (f8 - f7) * f25});
this.textureBuffer.put(new float[]{0.0F, f7 + (f8 - f7) * f25});
}
this.vertexBuffer.put(new float[]{f28, f30, box4.c});
this.vertexBuffer.put(new float[]{f28, f30, box4.c});
this.vertexCount += 2;
}
float f29 = (float) Math.sin((double) (1.0F - f25) * Math.PI * (double) f4 + (double) f2) * f3 + 1.0F + f16;
float f31 = (1.0F - f25) * (1.0F - f25) * box7.b + 2.0F * (1.0F - f25) * f25 * box8.b + f25 * f25 * box6.b;
if (flag) {
this.textureBuffer.put(new float[]{f9, f7 + (f8 - f7) * f25});
this.textureBuffer.put(new float[]{0.0F, f7 + (f8 - f7) * f25});
}
this.vertexBuffer.put(new float[]{f29, f31, box4.c});
f29 = (1.0F - f25) * (1.0F - f25) * box3.a + 2.0F * (1.0F - f25) * f25 * box9.a + f25 * f25 * box2.a;
f31 = (1.0F - f25) * (1.0F - f25) * box3.b + 2.0F * (1.0F - f25) * f25 * box9.b + f25 * f25 * box2.b;
if (flag1) {
f29 = (float) Math.sin((double) (1.0F - f25) * Math.PI * (double) f4 + (double) f2) * f3 + f16;
}
this.vertexBuffer.put(new float[]{f29, f31, box4.c});
this.vertexCount += 2;
}
this.vertexBuffer.flip();
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.vertexVbo);
GL15.glBufferData(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, (FloatBuffer) this.vertexBuffer, ARBVertexBufferObject.GL_DYNAMIC_DRAW_ARB);
if (flag) {
this.textureBuffer.flip();
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.textureVbo);
GL15.glBufferData(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, (FloatBuffer) this.textureBuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
}
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
this.lastHorz = f;
this.lastVert = f1;
}
}
}
public void renderDynamicCape() {
if (!this.deleted) {
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.vertexVbo);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0L);
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, this.textureVbo);
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0L);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, this.vertexCount);
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
GL15.glBindBuffer(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);
}
}
public void deleteData() {
this.deleted = true;
GL15.glDeleteBuffers(this.vertexVbo);
GL15.glDeleteBuffers(this.textureVbo);
}
}

View File

@ -0,0 +1,511 @@
package net.silentclient.client.cosmetics.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.gui.SilentScreen;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.Input;
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.theme.button.DefaultButtonTheme;
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.ScrollHelper;
import net.silentclient.client.utils.Sounds;
import net.silentclient.client.utils.types.PlayerResponse.Account.Cosmetics.CosmeticItem;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
public class CosmeticsGui extends SilentScreen {
public static String selectedCategory = "capes";
private int rotate = 0;
private ScrollHelper scrollHelper = new ScrollHelper();
@Override
public void initGui() {
rotate = 144;
defaultCursor = false;
if(mc.thePlayer == null) {
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
} else {
MenuBlurUtils.loadBlur();
}
this.silentInputs.add(new Input("Search"));
CosmeticsGui.selectedCategory = "capes";
Client.getInstance().updateUserInformation();
int categoryOffsetY = 25;
int addX = 190;
int addY = 110;
int x = (width / 2) - addX;
int y = (height / 2) - addY;
int height = addY * 2;
int tabId = 1;
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, 18, "Wings", false, selectedCategory == "wings" ? new SelectedButtonTheme() : new DefaultButtonTheme()));
categoryOffsetY +=23;
tabId++;
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, 18, "Hats", false, selectedCategory == "hats" ? new SelectedButtonTheme() : new DefaultButtonTheme()));
categoryOffsetY +=23;
tabId++;
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, 18, "Icons", false, selectedCategory == "icons" ? new SelectedButtonTheme() : new DefaultButtonTheme()));
tabId++;
this.buttonList.add(new Button(tabId, x + 5, (y + height) - 24, 75, 18, "Store"));
this.buttonList.add(new Button(88, x + 380 - 140, (y + height) - 24, 135, 18, "Outfits"));
}
@Override
public void onGuiClosed() {
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Menu Background Blur").getValBoolean()) {
Minecraft.getMinecraft().entityRenderer.loadEntityShader(null);
}
super.onGuiClosed();
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if(button instanceof Button) {
switch (button.id) {
case 1:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "capes";
rotate = 144;
scrollHelper.resetScroll();
break;
case 2:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "wings";
rotate = 144;
scrollHelper.resetScroll();
break;
case 3:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "bandanas";
rotate = 340;
scrollHelper.resetScroll();
break;
case 4:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "hats";
rotate = 340;
scrollHelper.resetScroll();
break;
case 5:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "shields";
rotate = 340;
scrollHelper.resetScroll();
break;
case 6:
this.buttonList.forEach(oldButton -> {
if(oldButton instanceof Button) {
((Button) oldButton).setTheme(new DefaultButtonTheme());
}
});
((Button) button).setTheme(new SelectedButtonTheme());
selectedCategory = "icons";
scrollHelper.resetScroll();
break;
}
this.silentInputs.get(0).setValue("");
}
if(button.id == 7) {
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(button.id == 88) {
mc.displayGuiScreen(new OutfitsGui(this));
}
}
private ArrayList<CosmeticItem> getItems() {
ArrayList<CosmeticItem> items;
ArrayList<CosmeticItem> searchItems = new ArrayList<>();
if(selectedCategory == "capes") {
items = Client.getInstance().getCosmetics().getMyCapes();
} else if(selectedCategory == "wings") {
items = Client.getInstance().getCosmetics().getMyWings();
} else if(selectedCategory == "bandanas") {
items = Client.getInstance().getCosmetics().getMyBandanas();
} else if(selectedCategory == "hats") {
items = Client.getInstance().getCosmetics().getMyHats();
} else if(selectedCategory == "shields") {
items = Client.getInstance().getCosmetics().getMyShields();
} else {
items = Client.getInstance().getCosmetics().getMyIcons();
}
if(this.silentInputs.get(0).getValue().trim().equals("")) {
return items;
} else {
for(CosmeticItem item : items) {
if(item.getName().trim().toLowerCase().contains(this.silentInputs.get(0).getValue().toLowerCase().trim())) {
searchItems.add(item);
}
}
return searchItems;
}
}
private ArrayList<Number> getFavoriteItems() {
ArrayList<Number> items;
if(selectedCategory == "capes") {
items = Client.getInstance().getAccount().getFavoriteCosmetics().capes;
} else if(selectedCategory == "wings") {
items = Client.getInstance().getAccount().getFavoriteCosmetics().wings;
} else if(selectedCategory == "bandanas") {
items = Client.getInstance().getAccount().getFavoriteCosmetics().bandanas;
} else if(selectedCategory == "hats") {
items = Client.getInstance().getAccount().getFavoriteCosmetics().hats;
} else if(selectedCategory == "shields") {
items = Client.getInstance().getAccount().getFavoriteCosmetics().shields;
} else {
items = Client.getInstance().getAccount().getFavoriteCosmetics().icons;
}
return items;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
if(mc.thePlayer == null) {
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
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);
}
int addX = 190;
int addY = 110;
int x = (width / 2) - addX;
int y = (height / 2) - addY;
int width = addX * 2;
int height = addY * 2;
int modOffsetY = 25;
int modIndex = 1;
//Draw background
RenderUtil.drawRoundedRect(x, y, width, height, 10, Theme.backgroundColor().getRGB());
ArrayList<CosmeticItem> items = null;
ArrayList<Number> selected_item = new ArrayList<>();
boolean can_show = true;
String error_text = "";
items = getItems();
selected_item.clear();
if(selectedCategory == "capes") {
selected_item.add(Client.getInstance().getAccount().getSelectedCape());
can_show = Client.getInstance().getAccount().customCape() ? false : Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Capes").getValBoolean();
error_text = Client.getInstance().getAccount().customCape() ? "Please disable Custom Cape in Silent+ settings" : Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Capes").getValBoolean() ? "" : "Please enable Capes in the cosmetics settings";
} else if(selectedCategory == "wings") {
selected_item.add(Client.getInstance().getAccount().getSelectedWings());
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings").getValBoolean();
error_text = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings").getValBoolean() ? "" : "Please enable Wings in the cosmetics settings";
} else if(selectedCategory == "bandanas") {
selected_item.add(Client.getInstance().getAccount().getSelectedBandana());
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Bandanas").getValBoolean();
error_text = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Bandanas").getValBoolean() ? "" : "Please enable Bandanas in the cosmetics settings";
} else if(selectedCategory == "hats") {
selected_item.add(Client.getInstance().getAccount().getSelectedHat());
selected_item.add(Client.getInstance().getAccount().getSelectedMask());
selected_item.add(Client.getInstance().getAccount().getSelectedNeck());
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Hats").getValBoolean();
error_text = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Hats").getValBoolean() ? "" : "Please enable Hats in the cosmetics settings";
} else if(selectedCategory == "shields") {
selected_item.add(Client.getInstance().getAccount().getSelectedShield());
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Shields").getValBoolean();
error_text = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Shields").getValBoolean() ? "" : "Please enable Shields in the cosmetics settings";
} else {
selected_item.add(Client.getInstance().getAccount().getSelectedIcon());
can_show = Client.getInstance().getAccount().plusIcon() ? false : true;
error_text = Client.getInstance().getAccount().plusIcon() ? "Please disable Plus Nametag Icon in Silent+ settings" : "";
}
if(can_show) {
scrollHelper.setStep(5);
scrollHelper.setElementsHeight((items != null ? items.size() : 0) * 35);
scrollHelper.setMaxScroll(height - 25);
scrollHelper.setSpeed(100);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
ScaledResolution r = new ScaledResolution(mc);
int s = r.getScaleFactor();
int translatedY = r.getScaledHeight() - (y + 25) - (height - 25);
GL11.glScissor(x * s, translatedY * s, width * s, (height - 25) * s);
if(items != null) {
for(CosmeticItem m : items) {
RenderUtil.drawRoundedOutline(x + 100, y + modOffsetY + scrollHelper.getScroll(), 135, 28, 10, 2, selected_item.contains(m.getId()) ? new Color(32, 252, 3).getRGB() : new Color(252, 3, 3).getRGB());
if(MouseUtils.isInside(mouseX, mouseY, x + 100, y + modOffsetY + scrollHelper.getScroll(), 135, 28)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
GL11.glDisable((int) 2929);
GL11.glEnable((int) 3042);
GL11.glDepthMask((boolean) false);
OpenGlHelper.glBlendFunc((int) 770, (int) 771, (int) 1, (int) 0);
GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f);
GL11.glDepthMask((boolean) true);
GL11.glDisable((int) 3042);
GL11.glEnable((int) 2929);
Client.getInstance().getSilentFontRenderer().drawString(m.getName(), x + 110, y + modOffsetY + 10 + scrollHelper.getScroll() - 3, 14, SilentFontRenderer.FontType.TITLE, 100);
boolean favorite = false;
for(Number i : getFavoriteItems()) {
if(i.intValue() == m.getId()) {
favorite = true;
}
}
RenderUtil.drawImage(favorite ? new ResourceLocation("silentclient/icons/star.png") : new ResourceLocation("silentclient/icons/star_outline.png"), x + 100 + 120, y + modOffsetY + scrollHelper.getScroll() + 8, 12, 12, false);
modOffsetY+= 35;
modIndex += 1;
}
}
GL11.glDisable(GL11.GL_SCISSOR_TEST);
GL11.glPopMatrix();
RenderUtil.drawImage(new ResourceLocation("silentclient/transparent.png"), x, y, 30, 30, false);
if(mc.thePlayer != null && selectedCategory != "icons") {
drawEntityOnScreen(x + 310, y + 175, 60, 1, 1, mc.thePlayer, rotate);
boolean drag = MouseUtils.isInside(mouseX, mouseY, x + 265, y + 50, 90, 150) && Mouse.isButtonDown(0);
if (drag) {
double diff = 360 - 0;
double mouse = MathHelper.clamp_double((mouseX - (x + 265)) / 90D, 0, 1);
double newVal = 0 + mouse * diff;
rotate = (int) newVal;
}
}
}
RenderUtil.drawImage(new ResourceLocation("silentclient/logos/logo.png"), x + 5, y + 5, 77, 15);
Client.getInstance().getSilentFontRenderer().drawString("Cosmetics", x + 100, (int) (y + 5), 14, SilentFontRenderer.FontType.TITLE);
super.drawScreen(mouseX, mouseY, partialTicks);
if(mc.thePlayer == null && can_show && selectedCategory != "icons") {
Client.getInstance().getSilentFontRenderer().drawString("Preview not available", x + 100 + 160, y + 100 - 3, 14, SilentFontRenderer.FontType.TITLE);
}
if(!can_show) {
Client.getInstance().getSilentFontRenderer().drawString(error_text, x + ((width - 90) / 2) - 15, y + (height / 3) + 20 - 3, 14, SilentFontRenderer.FontType.TITLE);
}
if(selectedCategory == "icons" && can_show) {
RenderUtil.drawImage(Client.getInstance().getAccount().getSelectedIcon() != 0 && !Client.getInstance().getAccount().plusIcon() ? Client.getInstance().getCosmetics().getIconById(Client.getInstance().getAccount().getSelectedIcon()).getLocation() : new ResourceLocation(Client.getInstance().getAccount().plusIcon() ? "silentclient/icons/plus_icon.png" : "silentclient/icons/player_icon.png"), x + 285, y + ((height / 2) - 25), 50, 50, false);
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
if(can_show) {
this.silentInputs.get(0).render(mouseX, mouseY, x + width - 140, y + 2, 135);
}
}
public void updateScreen()
{
Client.backgroundPanorama.tickPanorama();
}
public static void drawEntityOnScreen(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent, int rotate)
{
GlStateManager.enableColorMaterial();
GlStateManager.pushMatrix();
GlStateManager.translate((float)posX, (float)posY, 50.0F);
GlStateManager.scale((float)(-scale), (float)scale, (float)scale);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(rotate, 0.0F, 1.0F, 0.0F);
float f = ent.renderYawOffset;
float f1 = ent.rotationYaw;
float f2 = ent.rotationPitch;
float f3 = ent.prevRotationYawHead;
float f4 = ent.rotationYawHead;
GlStateManager.rotate(135.0F, 0, 1.0F, 0.0F);
GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
ent.renderYawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
ent.rotationYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
ent.rotationPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
ent.rotationYawHead = ent.rotationYaw;
ent.prevRotationYawHead = ent.rotationYaw;
GlStateManager.translate(0.0F, 0.0F, 0.0F);
RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
rendermanager.setPlayerViewY(180.0F);
rendermanager.setRenderShadow(false);
rendermanager.renderEntityWithPosYaw(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
rendermanager.setRenderShadow(true);
ent.renderYawOffset = f;
ent.rotationYaw = f1;
ent.rotationPitch = f2;
ent.prevRotationYawHead = f3;
ent.rotationYawHead = f4;
GlStateManager.popMatrix();
GlStateManager.disableLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GlStateManager.disableTexture2D();
GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
int addX = 190;
int addY = 110;
int x = (width / 2) - addX;
int y = (height / 2) - addY;
int width = addX * 2;
int modOffsetY = 25;
ArrayList<CosmeticItem> items = getItems();
boolean can_show = true;
if(selectedCategory == "capes") {
can_show = Client.getInstance().getAccount().customCape() ? false : Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Capes").getValBoolean();
} else if(selectedCategory == "wings") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings").getValBoolean();
} else if(selectedCategory == "bandanas") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Bandanas").getValBoolean();
} else if(selectedCategory == "hats") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Hats").getValBoolean();
}else if(selectedCategory == "shields") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Shields").getValBoolean();
} else {
can_show = Client.getInstance().getAccount().plusIcon() ? false : true;
}
if(items != null && can_show) {
this.silentInputs.get(0).onClick(mouseX, mouseY, x + width - 140, y + 2, 135);
for(CosmeticItem m : items) {
if(MouseUtils.isInside(mouseX, mouseY, x + 100 + 120, y + modOffsetY + scrollHelper.getScroll() + 8, 12, 12)) {
Client.getInstance().getAccount().updateFavorite(m.getId(), selectedCategory);
} else if(MouseUtils.isInside(mouseX, mouseY,x + 100, y + modOffsetY + scrollHelper.getScroll(), 135, 28) && mouseButton == 0) {
Sounds.playButtonSound();
if(selectedCategory == "capes") {
Client.getInstance().getAccount().setSelectedCape(m.getId());
} else if(selectedCategory == "wings") {
Client.getInstance().getAccount().setSelectedWings(m.getId());
} else if(selectedCategory == "bandanas") {
Client.getInstance().getAccount().setSelectedBandana(m.getId());
} else if(selectedCategory == "hats") {
Client.getInstance().getAccount().setSelectedHat(m.getId(), m.getModel().equals("gold_chain") ? "neck" : (m.getModel().equals("facemask") || m.getModel().equals("wichtiger_glasses")) ? "mask" : "hat");
} else if(selectedCategory == "shields") {
Client.getInstance().getAccount().setSelectedShield(m.getId());
} else {
Client.getInstance().getAccount().setSelectedIcon(m.getId());
}
}
modOffsetY+= 35;
}
}
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
super.keyTyped(typedChar, keyCode);
boolean can_show = true;
if(selectedCategory == "capes") {
can_show = Client.getInstance().getAccount().customCape() ? false : Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Capes").getValBoolean();
} else if(selectedCategory == "wings") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings").getValBoolean();
} else if(selectedCategory == "bandanas") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Bandanas").getValBoolean();
} else if(selectedCategory == "hats") {
can_show = Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Hats").getValBoolean();
} else {
can_show = Client.getInstance().getAccount().plusIcon() ? false : true;
}
if(can_show) {
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
if(this.silentInputs.get(0).isFocused()) {
this.scrollHelper.resetScroll();
}
}
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
}

View File

@ -0,0 +1,130 @@
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.awt.*;
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 = 70;
}
@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"));
}
@Override
protected void actionPerformed(GuiButton button) {
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();
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);
}
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 Outfit", 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) {
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) {
if (keyCode == Keyboard.KEY_ESCAPE) {
mc.displayGuiScreen(parentScreen);
return;
};
this.silentInputs.get(0).onKeyTyped(typedChar, keyCode);
}
}

View File

@ -0,0 +1,255 @@
package net.silentclient.client.cosmetics.gui;
import net.minecraft.client.Minecraft;
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.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.MouseCursorHandler;
import net.silentclient.client.utils.ScrollHelper;
import net.silentclient.client.utils.types.PlayerResponse;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
public class OutfitsGui extends SilentScreen {
private final GuiScreen parentScreen;
private int outfitIndex = 0;
private ScrollHelper scrollHelper = new ScrollHelper();
public OutfitsGui(GuiScreen parentScreen) {
this.parentScreen = parentScreen;
}
@Override
public void initGui() {
super.initGui();
defaultCursor = false;
if(mc.thePlayer == null) {
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
} else {
MenuBlurUtils.loadBlur();
}
int width = 255;
int height = 200;
int x = this.width / 2 - (width / 2);
int y = this.height / 2 - (height / 2);
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) {
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
if(mc.thePlayer == null) {
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
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);
}
int width = 255;
int height = 200;
int x = this.width / 2 - (width / 2);
int y = this.height / 2 - (height / 2);
scrollHelper.setStep(5);
scrollHelper.setElementsHeight((float) Math.ceil((Outfits.getOutfits().size() + 3) / 3) * 85);
scrollHelper.setMaxScroll(height - 20);
scrollHelper.setSpeed(100);
scrollHelper.setFlag(true);
float scrollY = scrollHelper.getScroll();
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);
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_SCISSOR_TEST);
ScaledResolution r = new ScaledResolution(Minecraft.getMinecraft());
int s = r.getScaleFactor();
int listHeight = height - 20;
int translatedY = r.getScaledHeight() - y - 20 - listHeight;
GL11.glScissor(0 * s, translatedY * s, this.width * s, listHeight * s);
int outfitX = x + 3;
float outfitY = y + 20 + scrollY;
int outfitIndex = 0;
boolean isCreateHovered = MouseUtils.isInside(mouseX, mouseY, outfitX, outfitY, 80, 80);
if(isCreateHovered) {
cursorType = MouseCursorHandler.CursorType.POINTER;
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, (int) (outfitY + 40 - 6), 12, SilentFontRenderer.FontType.TITLE);
outfitX += 83;
outfitIndex += 1;
this.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) {
cursorType = MouseCursorHandler.CursorType.POINTER;
RenderUtil.drawRoundedRect(outfitX, outfitY, 80, 80, 3, new Color(255, 255, 255, 30).getRGB());
}
if(MouseUtils.isInside(mouseX, mouseY, outfitX + 80 - 3 - 10, outfitY + 3, 10, 10)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
RenderUtil.drawRoundedOutline(outfitX, outfitY, 80, 80, 3, 1, Theme.borderColor().getRGB());
Client.getInstance().getSilentFontRenderer().drawString(outfit.name, outfitX + 3, (int) (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 = (int) (outfitY + 18);
if(outfit.selected_cape != 0 && Client.getInstance().getCosmetics().getMyCapes().stream().filter((c) -> c.id == outfit.selected_cape).findFirst().isPresent() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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() && (cosmeticY - outfitY) <= 62) {
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);
}
this.outfitIndex += 1;
outfitIndex += 1;
if(outfitIndex == 3) {
outfitIndex = 0;
outfitX = x + 3;
outfitY += 85;
} else {
outfitX += 83;
}
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
GL11.glDisable(GL11.GL_SCISSOR_TEST);
GL11.glPopMatrix();
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if(button.id == 0) {
mc.displayGuiScreen(parentScreen);
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
int width = 255;
int height = 200;
int x = this.width / 2 - (width / 2);
int y = this.height / 2 - (height / 2);
int outfitX = x + 3;
float outfitY = (int) (y + 20 + scrollHelper.getScroll());
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;
outfitX = x + 3;
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) {
if (keyCode == Keyboard.KEY_ESCAPE) {
mc.displayGuiScreen(parentScreen);
}
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
MenuBlurUtils.unloadBlur();
}
}

View File

@ -0,0 +1,70 @@
package net.silentclient.client.cosmetics.model;
public class Face
{
private final int[] vertexIndices;
private final int[] normalIndices;
private final int[] textureCoordinateIndices;
private Material material;
public Material getMaterial() {
return this.material;
}
public boolean hasNormals() {
return this.normalIndices[0] != -1;
}
public boolean hasTextureCoordinates() {
return this.textureCoordinateIndices[0] != -1;
}
public int[] getVertexIndices() {
return this.vertexIndices;
}
public int[] getTextureCoordinateIndices() {
return this.textureCoordinateIndices;
}
public int[] getNormalIndices() {
return this.normalIndices;
}
public Face(final int[] array) {
this.vertexIndices = new int[] { -1, -1, -1, -1 };
this.normalIndices = new int[] { -1, -1, -1, -1 };
this.textureCoordinateIndices = new int[] { -1, -1, -1, -1 };
this.vertexIndices[0] = array[0];
this.vertexIndices[1] = array[1];
this.vertexIndices[2] = array[2];
}
public Face(final int[] array, final int[] array2) {
this.vertexIndices = new int[] { -1, -1, -1, -1 };
this.normalIndices = new int[] { -1, -1, -1, -1 };
this.textureCoordinateIndices = new int[] { -1, -1, -1, -1 };
this.vertexIndices[0] = array[0];
this.vertexIndices[1] = array[1];
this.vertexIndices[2] = array[2];
this.normalIndices[0] = array2[0];
this.normalIndices[1] = array2[1];
this.normalIndices[2] = array2[2];
}
public Face(final int[] array, final int[] array2, final int[] array3, final Material material) {
this.vertexIndices = new int[] { -1, -1, -1, -1 };
this.normalIndices = new int[] { -1, -1, -1, -1 };
this.textureCoordinateIndices = new int[] { -1, -1, -1, -1 };
this.vertexIndices[0] = array[0];
this.vertexIndices[1] = array[1];
this.vertexIndices[2] = array[2];
this.textureCoordinateIndices[0] = array3[0];
this.textureCoordinateIndices[1] = array3[1];
this.textureCoordinateIndices[2] = array3[2];
this.normalIndices[0] = array2[0];
this.normalIndices[1] = array2[1];
this.normalIndices[2] = array2[2];
this.material = material;
}
}

View File

@ -0,0 +1,5 @@
package net.silentclient.client.cosmetics.model;
public class Material {
}

View File

@ -0,0 +1,52 @@
package net.silentclient.client.cosmetics.model;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;
public class Model
{
private String name;
private List<ModelBuffer.Vertex3f> vertices;
private List<ModelBuffer.Vertex2f> textureCoordinates;
private List<ModelBuffer.Vertex3f> normals;
private List<Face> faces;
private Map<String, Material> materials;
public Model() {
this.vertices = new ArrayList<ModelBuffer.Vertex3f>();
this.textureCoordinates = new ArrayList<ModelBuffer.Vertex2f>();
this.normals = new ArrayList<ModelBuffer.Vertex3f>();
this.faces = new ArrayList<Face>();
this.materials = new HashMap<String, Material>();
}
public void setName(final String name) {
this.name = name;
}
public String getName() {
return name;
}
public List<ModelBuffer.Vertex3f> getVertices() {
return this.vertices;
}
public List<ModelBuffer.Vertex2f> getTextureCoordinates() {
return this.textureCoordinates;
}
public List<ModelBuffer.Vertex3f> getNormals() {
return this.normals;
}
public List<Face> getFaces() {
return this.faces;
}
public Map<String, Material> getMaterials() {
return this.materials;
}
}

View File

@ -0,0 +1,221 @@
package net.silentclient.client.cosmetics.model;
import java.nio.FloatBuffer;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import net.minecraft.util.ResourceLocation;
public class ModelBuffer
{
private static final ExecutorService EXECUTOR_SERVICE;
private final ResourceLocation location;
private final boolean flipUVs;
private Model model;
private Integer bufferId;
private Future<FutureResult> loaded;
private int totalVertices;
public ModelBuffer(final ResourceLocation aj) {
this(aj, false);
}
public ModelBuffer(final ResourceLocation location, final boolean flipUVs) {
this.location = location;
this.flipUVs = flipUVs;
}
public boolean loadModel() {
if (this.isLoaded()) {
return true;
}
if (this.loaded != null && this.loaded.isDone()) {
FloatBuffer access$000;
try {
final FutureResult futureResult = this.loaded.get();
access$000 = futureResult.getBuffer();
this.model = futureResult.getModel();
this.totalVertices = futureResult.getTotalVertices();
}
catch (final Exception cause) {
throw new RuntimeException(cause);
}
this.bufferId = GL15.glGenBuffers();
GL15.glBindBuffer(34962, (int)this.bufferId);
GL15.glBufferData(34962, access$000, 35044);
GL15.glBindBuffer(34962, 0);
return true;
}
if (this.model == null && this.loaded == null) {
this.loaded = ModelBuffer.EXECUTOR_SERVICE.submit((Callable<FutureResult>)new Callable<FutureResult>() {
@Override
public FutureResult call() {
final Model loadModel = ModelLoader.loadModel(ModelBuffer.this.location, ModelBuffer.this.flipUVs);
final int n = loadModel.getFaces().size() * 3;
final FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(n * 8);
for (final Face face : loadModel.getFaces()) {
final Vertex3f[] array = { loadModel.getNormals().get(face.getNormalIndices()[0] - 1), loadModel.getNormals().get(face.getNormalIndices()[1] - 1), loadModel.getNormals().get(face.getNormalIndices()[2] - 1) };
final Vertex2f[] array2 = { loadModel.getTextureCoordinates().get(face.getTextureCoordinateIndices()[0] - 1), loadModel.getTextureCoordinates().get(face.getTextureCoordinateIndices()[1] - 1), loadModel.getTextureCoordinates().get(face.getTextureCoordinateIndices()[2] - 1) };
final Vertex3f[] array3 = { loadModel.getVertices().get(face.getVertexIndices()[0] - 1), loadModel.getVertices().get(face.getVertexIndices()[1] - 1), loadModel.getVertices().get(face.getVertexIndices()[2] - 1) };
for (int i = 0; i < 3; ++i) {
floatBuffer.put(new float[] { array3[i].getX(), array3[i].getY(), array3[i].getZ() });
floatBuffer.put(new float[] { array2[i].getX(), array2[i].getY() });
floatBuffer.put(new float[] { array[i].getX(), array[i].getY(), array[i].getZ() });
}
}
floatBuffer.flip();
return new FutureResult(loadModel, floatBuffer, n);
}
});
}
return false;
}
public void renderModel() {
if (!this.isLoaded()) {
this.loadModel();
}
else {
GL15.glBindBuffer(34962, (int)this.bufferId);
GL11.glVertexPointer(3, 5126, 32, 0L);
GL11.glEnableClientState(32884);
GL11.glTexCoordPointer(2, 5126, 32, 12L);
GL11.glEnableClientState(32888);
GL11.glNormalPointer(5126, 32, 20L);
GL11.glEnableClientState(32885);
GL11.glDrawArrays(4, 0, this.totalVertices);
GL11.glDisableClientState(32884);
GL11.glDisableClientState(32888);
GL11.glDisableClientState(32885);
GL15.glBindBuffer(34962, 0);
}
}
public void deleteData() {
if (this.loaded != null) {
if (this.loaded.isDone()) {
GL15.glDeleteBuffers((int)this.bufferId);
}
else {
this.loaded.cancel(true);
}
}
this.bufferId = null;
this.model = null;
this.loaded = null;
}
private boolean isLoaded() {
return this.bufferId != null;
}
static {
EXECUTOR_SERVICE = Executors.newSingleThreadExecutor();
}
public static class Vertex2f
{
public float x;
public float y;
public Vertex2f(final float n, final float n2) {
this.set(n, n2);
}
public void set(final float x, final float y) {
this.x = x;
this.y = y;
}
public float getX() {
return this.x;
}
public float getY() {
return this.y;
}
public void setX(final float x) {
this.x = x;
}
public void setY(final float y) {
this.y = y;
}
}
public static class Vertex3f
{
public float x;
public float y;
public float z;
public Vertex3f() {
}
public Vertex3f(final float n, final float n2, final float n3) {
this.set(n, n2, n3);
}
public void set(final float x, final float y, final float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float getX() {
return this.x;
}
public void setX(final float x) {
this.x = x;
}
public float getY() {
return this.y;
}
public void setY(final float y) {
this.y = y;
}
public float getZ() {
return this.z;
}
public void setZ(final float z) {
this.z = z;
}
}
private static class FutureResult
{
private Model model;
private FloatBuffer buffer;
private int totalVertices;
private FutureResult(final Model model, final FloatBuffer buffer, final int totalVertices) {
this.model = model;
this.buffer = buffer;
this.totalVertices = totalVertices;
}
private Model getModel() {
return this.model;
}
private FloatBuffer getBuffer() {
return this.buffer;
}
private int getTotalVertices() {
return this.totalVertices;
}
}
}

View File

@ -0,0 +1,97 @@
package net.silentclient.client.cosmetics.model;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
public class ModelLoader
{
private static ModelBuffer.Vertex2f parseTextureCoord(final String s, final boolean b) {
final String[] split = s.split(" ");
final float floatValue = Float.valueOf(split[1]);
final float floatValue2 = Float.valueOf(split[2]);
return new ModelBuffer.Vertex2f(floatValue, b ? (1.0f - floatValue2) : floatValue2);
}
private static ModelBuffer.Vertex3f parseVertex(final String s) {
final String[] split = s.split(" ");
return new ModelBuffer.Vertex3f(Float.valueOf(split[1]), Float.valueOf(split[2]), Float.valueOf(split[3]));
}
private static ModelBuffer.Vertex3f parseNormal(final String s) {
final String[] split = s.split(" ");
return new ModelBuffer.Vertex3f(Float.valueOf(split[1]), Float.valueOf(split[2]), Float.valueOf(split[3]));
}
private static Face parseFace(final boolean b, final boolean b2, final String s) {
final String[] split = s.split(" ");
final int[] array = { Integer.parseInt(split[1].split("/")[0]), Integer.parseInt(split[2].split("/")[0]), Integer.parseInt(split[3].split("/")[0]) };
if (b2) {
return new Face(array, new int[] { Integer.parseInt(split[1].split("/")[2]), Integer.parseInt(split[2].split("/")[2]), Integer.parseInt(split[3].split("/")[2]), 0 }, new int[] { Integer.parseInt(split[1].split("/")[1]), Integer.parseInt(split[2].split("/")[1]), Integer.parseInt(split[3].split("/")[1]), 0 }, null);
}
if (b) {
return new Face(array, new int[] { Integer.parseInt(split[1].split("/")[2]), Integer.parseInt(split[2].split("/")[2]), Integer.parseInt(split[3].split("/")[2]), 0 });
}
return new Face(array);
}
public static Model loadModel(final ResourceLocation aj) {
return loadModel(aj, false);
}
public static Model loadModel(final ResourceLocation aj, final boolean b) {
InputStream a = null;
try {
a = Minecraft.getMinecraft().getResourceManager().getResource(aj).getInputStream();
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(a));
final Model model = new Model();
String line;
while ((line = bufferedReader.readLine()) != null) {
final String s = line.split(" ")[0];
if (!s.equals("#")) {
if (line.startsWith("#")) {
continue;
}
if (s.equals("o")) {
model.setName(line.split(" ")[1]);
}
else if (s.equals("v")) {
model.getVertices().add(parseVertex(line));
}
else if (s.equals("vn")) {
model.getNormals().add(parseNormal(line));
}
else if (s.equals("f")) {
model.getFaces().add(parseFace(model.getNormals().size() > 0, model.getTextureCoordinates().size() > 0, line));
}
else {
if (!s.equals("vt")) {
continue;
}
model.getTextureCoordinates().add(parseTextureCoord(line, b));
}
}
}
bufferedReader.close();
return model;
}
catch (final Exception ex) {
ex.printStackTrace();
Client.logger.error("MODEL LOADER ERROR: " + ex.getMessage());
}
finally {
if (a != null) {
try {
a.close();
}
catch (final IOException ex2) {}
}
}
return null;
}
}

View File

@ -0,0 +1,114 @@
package net.silentclient.client.cosmetics.wings;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderPlayer;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.entity.Entity;
import net.silentclient.client.Client;
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.settings.CosmeticsMod;
import org.lwjgl.opengl.GL11;
public class WingsModel implements LayerRenderer<AbstractClientPlayer> {
private static ModelRenderer wing;
private static ModelRenderer wingTip;
boolean flying;
private final ModelDragonWings modelDragonWings;
public WingsModel(RenderPlayer player) {
this.flying = false;
this.modelDragonWings = new ModelDragonWings(player);
final int bw = this.modelDragonWings.textureWidth;
final int bh = this.modelDragonWings.textureHeight;
this.modelDragonWings.textureWidth = 256;
this.modelDragonWings.textureHeight = 256;
(wing = new ModelRenderer(this.modelDragonWings, "wing")).setRotationPoint(-12.0f, 5.0f, 2.0f);
wing.addBox("bone", -56.0f, -4.0f, -4.0f, 56, 8, 8);
wing.addBox("skin", -56.0f, 0.0f, 2.0f, 56, 0, 56);
wing.isHidden = true;
(wingTip = new ModelRenderer(this.modelDragonWings, "wingTip")).setRotationPoint(-56.0f, 0.0f, 0.0f);
wingTip.isHidden = true;
wingTip.addBox("bone", -56.0f, -2.0f, -2.0f, 56, 4, 4);
wingTip.addBox("skin", -56.0f, 0.0f, 2.0f, 56, 0, 56);
wing.addChild(wingTip);
this.modelDragonWings.textureWidth = bw;
this.modelDragonWings.textureWidth = bh;
}
private class ModelDragonWings extends ModelBase {
public ModelDragonWings(RenderPlayer player) {
this.setTextureOffset("wingTip.bone", 112, 136);
this.setTextureOffset("wing.skin", -56, 88);
this.setTextureOffset("wing.bone", 112, 88);
this.setTextureOffset("wingTip.skin", -56, 144);
}
@Override
public void render(final Entity entityIn, final float limbSwing, final float limbSwingAmount, final float ageInTicks, final float netHeadYaw, final float headPitch, final float scale) {
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
GlStateManager.pushMatrix();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableLighting();
GlStateManager.scale(Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings Scale").getValDouble(), Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings Scale").getValDouble(), Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings Scale").getValDouble());
float f1 = 0.0f;
if (Minecraft.getMinecraft().thePlayer.capabilities.isFlying) {
f1 = ageInTicks / 200.0f;
}
else {
f1 = ageInTicks / 80.0f;
}
((AbstractClientPlayerExt) entityIn).silent$getWings().bindTexture();
if (!entityIn.onGround || flying) {
flying = true;
}
GlStateManager.scale(0.15, 0.15, 0.15);
GlStateManager.translate(0.0, -0.3, 1.1);
if(entityIn.isSneaking()) {
GlStateManager.translate(-0.04F, 1.1F + 0.2F, -0.04F);
}
GlStateManager.rotate(50.0f, -50.0f, 0.0f, 0.0f);
for (int i = 0; i < 2; ++i) {
final float f2 = f1 * 9.141593f * 2.0f;
wing.rotateAngleX = 0.125f - (float)Math.cos(f2) * 0.2f;
wing.rotateAngleY = 0.25f;
wing.rotateAngleZ = (float)(Math.sin(f2) + 1.225) * 0.3f;
wingTip.rotateAngleZ = -(float)(Math.sin(f2 + 2.0f) + 0.5) * 0.75f;
wing.isHidden = false;
wingTip.isHidden = false;
if (!entityIn.isInvisible()) {
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
wing.render(scale);
GlStateManager.popMatrix();
}
wing.isHidden = false;
wingTip.isHidden = false;
if (i == 0) {
GlStateManager.scale(-1.0f, 1.0f, 1.0f);
}
}
GlStateManager.popMatrix();
}
}
@Override
public boolean shouldCombineTextures() {
return false;
}
@Override
public void doRenderLayer(final AbstractClientPlayer player, final float limbSwing, final float limbSwingAmount, final float partialTicks, final float ageInTicks, final float HeadYaw, final float headPitch, final float scale) {
if (((AbstractClientPlayerExt) player).silent$getWings() != null && Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Wings").getValBoolean()) {
if (!player.isInvisible()) {
GlStateManager.pushMatrix();
this.modelDragonWings.render(player, limbSwing, limbSwingAmount, ageInTicks, HeadYaw, headPitch, scale);
this.modelDragonWings.setRotationAngles(scale, limbSwing, limbSwingAmount, ageInTicks, HeadYaw, headPitch, player);
GL11.glPopMatrix();
}
}
}
}

View File

@ -0,0 +1,32 @@
package net.silentclient.client.emotes;
import net.minecraft.client.model.ModelBiped;
import net.silentclient.client.emotes.animation.EmoteSimpleAnimation;
public class DabEmote {
private EmoteSimpleAnimation bipedRightArm = new EmoteSimpleAnimation();
private EmoteSimpleAnimation bipedLeftArm = new EmoteSimpleAnimation();
private EmoteSimpleAnimation bipedHead = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelRightArm = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelRightArmWear = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelLeftArm = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelLeftArmWear = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelHead = new EmoteSimpleAnimation();
private EmoteSimpleAnimation modelHeadWear = new EmoteSimpleAnimation();
public void initEmoteBiped(ModelBiped modelBiped) {
bipedHead.getX().setValue(modelBiped.bipedHead.rotateAngleX);
bipedHead.getY().setValue(modelBiped.bipedHead.rotateAngleY);
bipedHead.getZ().setValue(modelBiped.bipedHead.rotateAngleZ);
bipedRightArm.getX().setValue(modelBiped.bipedRightArm.rotateAngleX);
bipedRightArm.getY().setValue(modelBiped.bipedRightArm.rotateAngleY);
bipedRightArm.getZ().setValue(modelBiped.bipedRightArm.rotateAngleZ);
bipedLeftArm.getX().setValue(modelBiped.bipedLeftArm.rotateAngleX);
bipedLeftArm.getY().setValue(modelBiped.bipedLeftArm.rotateAngleY);
bipedLeftArm.getZ().setValue(modelBiped.bipedLeftArm.rotateAngleZ);
}
public void renderEmoteBiped(ModelBiped modelBiped) {
}
}

View File

@ -0,0 +1,21 @@
package net.silentclient.client.emotes.animation;
import net.silentclient.client.gui.animation.SimpleAnimation;
public class EmoteSimpleAnimation {
private SimpleAnimation xAnimation = new SimpleAnimation(0);
private SimpleAnimation yAnimation = new SimpleAnimation(0);
private SimpleAnimation zAnimation = new SimpleAnimation(0);
public SimpleAnimation getX() {
return xAnimation;
}
public SimpleAnimation getY() {
return yAnimation;
}
public SimpleAnimation getZ() {
return zAnimation;
}
}

View File

@ -0,0 +1,21 @@
package net.silentclient.client.event;
import java.util.ArrayList;
public class Event {
public Event call() {
final ArrayList<EventData> dataList = EventManager.get(this.getClass());
if(dataList != null) {
for(EventData data : dataList) {
try {
data.target.invoke(data.source, this);
} catch(Exception e) {
e.printStackTrace();
}
}
}
return this;
}
}

View File

@ -0,0 +1,13 @@
package net.silentclient.client.event;
public class EventCancelable extends Event {
private boolean cancelled = false;
public boolean isCancelable() {
return cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event;
import java.lang.reflect.Method;
public class EventData {
public final Object source;
public final Method target;
public final byte priority;
public EventData(Object source, Method target, byte priority) {
this.source = source;
this.target = target;
this.priority = priority;
}
}

View File

@ -0,0 +1,133 @@
package net.silentclient.client.event;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class EventManager {
private static final Map<Class<? extends Event>, ArrayList<EventData>> REGISTRY_MAP = new HashMap<Class<? extends Event>, ArrayList<EventData>>();
private static void sortListValue(final Class<? extends Event> clazz) {
final ArrayList<EventData> flexableArray = new ArrayList<EventData>();
for(final byte b : EventPriority.VALUE_ARRAY) {
for(EventData methodData : EventManager.REGISTRY_MAP.get(clazz)) {
if(methodData.priority == b) {
flexableArray.add(methodData);
}
}
}
EventManager.REGISTRY_MAP.put(clazz, flexableArray);
}
private static boolean isMethodBad(final Method method) {
return method.getParameterTypes().length != 1 || !method.isAnnotationPresent(EventTarget.class);
}
private static boolean isMethodBad(final Method method, final Class<? extends Event> clazz) {
return isMethodBad(method) || method.getParameterTypes()[0].equals(clazz);
}
public static ArrayList<EventData> get(final Class<? extends Event> clazz){
return REGISTRY_MAP.get(clazz);
}
public static void cleanMap(final boolean removeOnlyEmptyValues) {
final Iterator<Map.Entry<Class<? extends Event>, ArrayList<EventData>>> iterator = EventManager.REGISTRY_MAP.entrySet().iterator();
while(iterator.hasNext()) {
if(!removeOnlyEmptyValues || iterator.next().getValue().isEmpty()) {
iterator.remove();
}
}
}
public static void unregister(final Object o, final Class<? extends Event> clazz) {
if(REGISTRY_MAP.containsKey(clazz)) {
for(final EventData methodData : REGISTRY_MAP.get(clazz)) {
if(methodData.source.equals(o)) {
REGISTRY_MAP.get(clazz).remove(methodData);
}
}
}
cleanMap(true);
}
public static void unregister(final Object o) {
for(ArrayList<EventData> flexableArray : REGISTRY_MAP.values()) {
for(int i = flexableArray.size() -1; i >= 0; i--) {
if(flexableArray.get(i).source.equals(o)) {
flexableArray.remove(i);
}
}
}
cleanMap(true);
}
@SuppressWarnings("unchecked")
public static void register(final Method method, final Object o) {
final Class<?> clazz = method.getParameterTypes()[0];
final EventData methodData = new EventData(o, method, method.getAnnotation(EventTarget.class).value());
if(!methodData.target.isAccessible()) {
methodData.target.setAccessible(true);
}
if(REGISTRY_MAP.containsKey(clazz)) {
if(!REGISTRY_MAP.get(clazz).contains(methodData)) {
REGISTRY_MAP.get(clazz).add(methodData);
sortListValue((Class<? extends Event>) clazz);
}
}
else {
REGISTRY_MAP.put((Class<? extends Event>) clazz, new ArrayList<EventData>() {
private static final long serialVersionUID = 1L;
{
this.add(methodData);
}
});
}
}
public static void register(final Object o, final Class<? extends Event> clazz) {
for(final Method method : o.getClass().getMethods()) {
if(!isMethodBad(method, clazz)) {
register(method, o);
}
}
}
public static void register(Object o) {
for(final Method method : o.getClass().getMethods()) {
if(!isMethodBad(method)) {
register(method, o);
}
}
}
}

View File

@ -0,0 +1,9 @@
package net.silentclient.client.event;
public class EventPriority {
public static final byte FIRST = 0, SECOND = 1, THIRD = 2, FOURTH = 3, FIRTH = 4;
public static final byte[] VALUE_ARRAY = new byte[] { FIRST, SECOND, THIRD, FOURTH, FIRTH };
}

View File

@ -0,0 +1,12 @@
package net.silentclient.client.event;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EventTarget {
byte value() default EventPriority.THIRD;
}

View File

@ -0,0 +1,7 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class ClientTickEvent extends Event {
}

View File

@ -0,0 +1,17 @@
package net.silentclient.client.event.impl;
import net.minecraft.client.multiplayer.ServerData;
import net.silentclient.client.event.Event;
public class ConnectToServerEvent extends Event {
private final ServerData serverData;
public ConnectToServerEvent(ServerData serverData) {
this.serverData = serverData;
}
public ServerData getServerData() {
return serverData;
}
}

View File

@ -0,0 +1,22 @@
package net.silentclient.client.event.impl;
import net.minecraft.entity.Entity;
import net.silentclient.client.event.Event;
public class EntityAttackEvent extends Event {
private final Entity victim;
private final Entity player;
public EntityAttackEvent(Entity victim, Entity player) {
this.victim = victim;
this.player = player;
}
public Entity getVictim() {
return victim;
}
public Entity getPlayer() {
return player;
}
}

View File

@ -0,0 +1,16 @@
package net.silentclient.client.event.impl;
import net.minecraft.entity.Entity;
import net.silentclient.client.event.Event;
public class EntityDamageEvent extends Event {
private Entity entity;
public EntityDamageEvent(Entity entity) {
this.entity = entity;
}
public Entity getEntity() {
return entity;
}
}

View File

@ -0,0 +1,30 @@
package net.silentclient.client.event.impl;
import net.minecraft.entity.Entity;
import net.silentclient.client.event.EventCancelable;
public class EntityJoinLevelEvent extends EventCancelable {
private final boolean loadedFromDisk;
private final Entity entity;
public EntityJoinLevelEvent(Entity entity)
{
this(entity, false);
}
public EntityJoinLevelEvent(Entity entity, boolean loadedFromDisk)
{
this.entity = entity;
this.loadedFromDisk = loadedFromDisk;
}
public Entity getEntity()
{
return entity;
}
public boolean loadedFromDisk()
{
return loadedFromDisk;
}
}

View File

@ -0,0 +1,39 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventCameraRotation extends Event {
private float yaw;
private float pitch;
private float roll;
public EventCameraRotation(float yaw, float pitch, float roll) {
this.yaw = yaw;
this.pitch = pitch;
this.roll = roll;
}
public float getYaw() {
return yaw;
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
public float getRoll() {
return roll;
}
public void setRoll(float roll) {
this.roll = roll;
}
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventClickMouse extends Event {
private final int button;
public EventClickMouse(int button) {
this.button = button;
}
public int getButton() {
return button;
}
}

View File

@ -0,0 +1,19 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventDebugFps extends Event {
private int fps;
public EventDebugFps(int fps) {
this.fps = fps;
}
public int getFps() {
return fps;
}
public void setFps(int fps) {
this.fps = fps;
}
}

View File

@ -0,0 +1,26 @@
package net.silentclient.client.event.impl;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.silentclient.client.event.Event;
public class EventFovUpdate extends Event {
private AbstractClientPlayer entity;
private float fov;
public EventFovUpdate(AbstractClientPlayer entity, float fov) {
this.entity = entity;
this.fov = fov;
}
public float getFov() {
return fov;
}
public void setFov(float fov) {
this.fov = fov;
}
public AbstractClientPlayer getEntity() {
return entity;
}
}

View File

@ -0,0 +1,49 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventHitOverlay extends Event {
private float red;
private float green;
private float blue;
private float alpha;
public EventHitOverlay(float red, float green, float blue, float alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
public float getRed() {
return red;
}
public void setRed(float red) {
this.red = red;
}
public float getGreen() {
return green;
}
public void setGreen(float green) {
this.green = green;
}
public float getBlue() {
return blue;
}
public void setBlue(float blue) {
this.blue = blue;
}
public float getAlpha() {
return alpha;
}
public void setAlpha(float alpha) {
this.alpha = alpha;
}
}

View File

@ -0,0 +1,55 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventPlaySound extends EventCancelable {
private String soundName;
private float volume;
private float pitch;
private float originalVolume;
private float originalPitch;
public EventPlaySound(String soundName, float volume, float pitch, float originalVolume, float originalPitch) {
this.soundName = soundName;
this.volume = volume;
this.pitch = pitch;
this.originalVolume = originalVolume;
this.originalPitch = originalPitch;
}
public float getVolume() {
return volume;
}
public void setVolume(float volume) {
this.volume = volume;
}
public float getPitch() {
return pitch;
}
public void setPitch(float pitch) {
this.pitch = pitch;
}
public float getOriginalVolume() {
return originalVolume;
}
public void setOriginalVolume(float originalVolume) {
this.originalVolume = originalVolume;
}
public float getOriginalPitch() {
return originalPitch;
}
public void setOriginalPitch(float originalPitch) {
this.originalPitch = originalPitch;
}
public String getSoundName() {
return soundName;
}
}

View File

@ -0,0 +1,21 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventPlayerHeadRotation extends EventCancelable {
private float yaw;
private float pitch;
public EventPlayerHeadRotation(float yaw, float pitch) {
this.yaw = yaw;
this.pitch = pitch;
}
public float getYaw() {
return yaw;
}
public float getPitch() {
return pitch;
}
}

View File

@ -0,0 +1,20 @@
package net.silentclient.client.event.impl;
import net.minecraft.network.Packet;
import net.silentclient.client.event.EventCancelable;
public class EventReceivePacket extends EventCancelable {
private Packet<?> packet;
public EventReceivePacket(Packet<?> packet) {
this.packet = packet;
}
public Packet<?> getPacket() {
return packet;
}
public void setPacket(Packet<?> packet) {
this.packet = packet;
}
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventRender3D extends EventCancelable {
private float partialTicks;
public EventRender3D(float partialTicks) {
this.partialTicks = partialTicks;
}
public float getPartialTicks() {
return partialTicks;
}
}

View File

@ -0,0 +1,7 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventRenderCrosshair extends EventCancelable {
}

View File

@ -0,0 +1,7 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventRenderDamageTint extends Event {
}

View File

@ -0,0 +1,44 @@
package net.silentclient.client.event.impl;
import net.minecraft.entity.Entity;
import net.silentclient.client.event.EventCancelable;
public class EventRenderHitbox extends EventCancelable {
private Entity entity;
private double x, y, z;
private float entityYaw;
private float partialTicks;
public EventRenderHitbox(Entity entity, double x, double y, double z, float entityYaw, float partialTicks) {
this.entity = entity;
this.x = x;
this.y = y;
this.z = z;
this.entityYaw = entityYaw;
this.partialTicks = partialTicks;
}
public Entity getEntity() {
return entity;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public float getEntityYaw() {
return entityYaw;
}
public float getPartialTicks() {
return partialTicks;
}
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventScrollMouse extends EventCancelable {
private int amount;
public EventScrollMouse(int amount) {
this.amount = amount;
}
public int getAmount() {
return amount;
}
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class EventSendMessage extends EventCancelable {
private final String message;
public EventSendMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View File

@ -0,0 +1,20 @@
package net.silentclient.client.event.impl;
import net.minecraft.network.Packet;
import net.silentclient.client.event.EventCancelable;
public class EventSendPacket extends EventCancelable {
private Packet<?> packet;
public EventSendPacket(Packet<?> packet) {
this.packet = packet;
}
public Packet<?> getPacket() {
return packet;
}
public void setPacket(Packet<?> packet) {
this.packet = packet;
}
}

View File

@ -0,0 +1,30 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventText extends Event {
private String text;
private String outputText;
public EventText(String text) {
this.text = text;
this.outputText = text;
}
public String getText() {
return this.text;
}
public String getOutputText() {
return this.outputText;
}
public String replace(String src, String target) {
this.outputText = text.replace(src, target);
return this.outputText;
}
public void setOutputText(String outputText) {
this.outputText = outputText;
}
}

View File

@ -0,0 +1,40 @@
package net.silentclient.client.event.impl;
import net.minecraft.item.ItemStack;
import net.silentclient.client.event.Event;
public class EventTransformFirstPersonItem extends Event {
private ItemStack itemToRender;
private float equipProgress;
private float swingProgress;
public EventTransformFirstPersonItem(ItemStack itemToRender, float equipProgress, float swingProgress) {
this.itemToRender = itemToRender;
this.equipProgress = equipProgress;
this.swingProgress = swingProgress;
}
public ItemStack getItemToRender() {
return itemToRender;
}
public void setItemToRender(ItemStack itemToRender) {
this.itemToRender = itemToRender;
}
public float getEquipProgress() {
return equipProgress;
}
public void setEquipProgress(float equipProgress) {
this.equipProgress = equipProgress;
}
public float getSwingProgress() {
return swingProgress;
}
public void setSwingProgress(float swingProgress) {
this.swingProgress = swingProgress;
}
}

View File

@ -0,0 +1,19 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class EventZoomFov extends Event {
private float fov;
public EventZoomFov(float fov) {
this.fov = fov;
}
public float getFov() {
return fov;
}
public void setFov(float fov) {
this.fov = fov;
}
}

View File

@ -0,0 +1,16 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class KeyEvent extends EventCancelable {
private final int key;
public KeyEvent(int key) {
this.key = key;
}
public int getKey() {
return key;
}
}

View File

@ -0,0 +1,16 @@
package net.silentclient.client.event.impl;
import net.minecraft.client.multiplayer.WorldClient;
import net.silentclient.client.event.Event;
public class LoadWorldEvent extends Event {
private final WorldClient world;
public LoadWorldEvent(WorldClient world) {
this.world = world;
}
public WorldClient getWorld() {
return world;
}
}

View File

@ -0,0 +1,16 @@
package net.silentclient.client.event.impl;
import net.minecraft.util.IChatComponent;
import net.silentclient.client.event.EventCancelable;
public class NewMessageEvent extends EventCancelable {
private final IChatComponent message;
public NewMessageEvent(IChatComponent message) {
this.message = message;
}
public IChatComponent getMessage() {
return message;
}
}

View File

@ -0,0 +1,7 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class RenderEvent extends Event {
}

View File

@ -0,0 +1,30 @@
package net.silentclient.client.event.impl;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.silentclient.client.event.EventCancelable;
public class RenderLivingEvent extends EventCancelable {
private Entity entity;
public double x;
public double y;
public double z;
private RendererLivingEntity<EntityLivingBase> renderer;
public RenderLivingEvent(Entity entity, double x, double y, double z, RendererLivingEntity<EntityLivingBase> renderer) {
this.entity = entity;
this.x = x;
this.y = y;
this.z = z;
this.renderer = renderer;
}
public Entity getEntity() {
return entity;
}
public RendererLivingEntity<EntityLivingBase> getRenderer() {
return renderer;
}
}

View File

@ -0,0 +1,7 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class RenderTickEvent extends EventCancelable {
}

View File

@ -0,0 +1,15 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.EventCancelable;
public class RunCommandEvent extends EventCancelable {
private final String command;
public RunCommandEvent(String command) {
this.command = command;
}
public String getCommand() {
return command;
}
}

View File

@ -0,0 +1,6 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class ServerLeaveEvent extends Event {
}

View File

@ -0,0 +1,6 @@
package net.silentclient.client.event.impl;
import net.silentclient.client.event.Event;
public class SingleplayerJoinEvent extends Event {
}

View File

@ -0,0 +1,66 @@
package net.silentclient.client.gui;
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;
public GuiError(String error) {
this.error = error;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GlStateManager.disableAlpha();
Client.backgroundPanorama.renderSkybox(mouseX, mouseY, partialTicks);
GlStateManager.enableAlpha();
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);
Client.getInstance().getSilentFontRenderer().drawString("Error", (this.width / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth("Error", 14, SilentFontRenderer.FontType.HEADER) / 2), this.height / 3 - 3, 14, SilentFontRenderer.FontType.HEADER);
Client.getInstance().getSilentFontRenderer().drawString(error, (this.width / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth(error, 14, SilentFontRenderer.FontType.TITLE) / 2), this.height / 2 - 3, 14, SilentFontRenderer.FontType.TITLE);
super.drawScreen(mouseX, mouseY, partialTicks);
}
@Override
public void initGui() {
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
this.buttonList.add(new Button(1, (this.width / 2) - (98 / 2), this.height - 30, 98, 20, "Quit Game"));
super.initGui();
}
@Override
protected void actionPerformed(GuiButton button) {
if(button.id == 1) {
this.mc.shutdown();
}
}
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;
}
}

View File

@ -0,0 +1,39 @@
package net.silentclient.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui;
import java.io.IOException;
public class GuiMultiplayerInGame extends SilentMultiplayerGui {
public GuiMultiplayerInGame(GuiScreen parentScreen) {
super(parentScreen);
}
@Override
protected void actionPerformed(GuiButton button) {
if(button.id == 1) {
disconnect();
}
super.actionPerformed(button);
}
@Override
public void connectToSelected() {
disconnect();
super.connectToSelected();
}
private void disconnect() {
if(this.mc.theWorld != null) {
this.mc.theWorld.sendQuittingDisconnectingPacket();
this.mc.loadWorld(null);
this.mc.displayGuiScreen(null);
this.setParentScreen(null);
}
}
}

View File

@ -0,0 +1,27 @@
package net.silentclient.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiScreenServerList;
import net.minecraft.client.multiplayer.ServerData;
import java.io.IOException;
public class GuiScreenServerListInGame extends GuiScreenServerList {
public GuiScreenServerListInGame(GuiScreen p_i1031_1_, ServerData p_i1031_2_) {
super(p_i1031_1_, p_i1031_2_);
}
@Override
protected void actionPerformed(GuiButton button) {
if(button.id == 0) {
if(this.mc.theWorld != null) {
this.mc.theWorld.sendQuittingDisconnectingPacket();
this.mc.loadWorld(null);
this.mc.displayGuiScreen(null);
}
}
super.actionPerformed(button);
}
}

View File

@ -0,0 +1,77 @@
package net.silentclient.client.gui;
import java.io.IOException;
import net.silentclient.client.utils.MenuBlurUtils;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.elements.IconButton;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.theme.Theme;
public class ModalBase extends GuiScreen {
private final GuiScreen parentScreen;
private final int modalWidth;
private final int modalHeight;
private final String modalTitle;
public ModalBase(GuiScreen parentScreen, String modalTitle) {
this(parentScreen, modalTitle, 200, 90);
}
public ModalBase(GuiScreen parentScreen, String modalTitle, int modalWidth, int modalHeight) {
this.parentScreen = parentScreen;
this.modalWidth = modalWidth;
this.modalHeight = modalHeight;
this.modalTitle = modalTitle;
}
@Override
public void initGui() {
MenuBlurUtils.loadBlur();
int x = width / 2 - (this.modalWidth / 2);
int y = height / 2 - (this.modalHeight / 2);
this.buttonList.add(new IconButton(0, x + this.modalWidth - 14 - 3, y + 3, 14, 14, 8, 8, new ResourceLocation("silentclient/icons/exit.png")));
}
@Override
protected void actionPerformed(GuiButton button) {
if(button.id == 0) {
mc.displayGuiScreen(parentScreen);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
MenuBlurUtils.renderBackground(this);
RenderUtils.drawRect(this.getContentX(), this.getContentY(), this.modalWidth, this.modalHeight, Theme.backgroundColor().getRGB());
Client.getInstance().getSilentFontRenderer().drawString(this.modalTitle, this.getContentX() + 3, this.getContentY() + 3, 14, SilentFontRenderer.FontType.TITLE);
super.drawScreen(mouseX, mouseY, partialTicks);
}
public int getContentX() {
return width / 2 - (this.modalWidth / 2);
}
public int getContentY() {
return height / 2 - (this.modalHeight / 2);
}
@Override
public void onGuiClosed() {
MenuBlurUtils.unloadBlur();
}
@Override
protected void keyTyped(char typedChar, int keyCode) {
if (keyCode == Keyboard.KEY_ESCAPE) {
mc.displayGuiScreen(parentScreen);
};
}
}

View File

@ -0,0 +1,82 @@
package net.silentclient.client.gui;
import dev.refactoring.bridge.client.gui.CustomScreen;
import net.silentclient.client.Client;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.Input;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.utils.MouseCursorHandler;
import java.util.ArrayList;
import java.util.List;
public class SilentScreen implements CustomScreen {
protected boolean defaultCursor = true;
protected ArrayList<Input> silentInputs = new ArrayList<>();
@Override
public int mouseReleased() {
return 0;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
if(defaultCursor) {
Client.getInstance().getMouseCursorHandler().enableCursor(getCursor(silentInputs, buttonList));
}
}
@Override
public void mouseClicked(int var1, int var2, int var3) {
}
@Override
public void mouseReleased(int var1, int var2, int var3) {
}
public static MouseCursorHandler.CursorType getCursor(ArrayList<Input> silentInputs, List<GuiButton> buttonList) {
MouseCursorHandler.CursorType cursorType = MouseCursorHandler.CursorType.NORMAL;
for(Input input : silentInputs) {
if(input.isHovered()) {
cursorType = MouseCursorHandler.CursorType.EDIT_TEXT;
}
}
for(GuiButton button : buttonList) {
if(button instanceof Button && button.isMouseOver() && !(((Button) button).escMenu && Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Vanilla ESC Menu Layout").getValBoolean())) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
}
return cursorType;
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Client.getInstance().getMouseCursorHandler().disableCursor();
}
@Override
public void updateScreen() {
}
@Override
public void keyTyped(char var1, int var2) {
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
public int getFpsLimit() {
return 120;
}
}

View File

@ -0,0 +1,63 @@
package net.silentclient.client.gui;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ResourceLocation;
public class SplashScreen {
private static ResourceLocation SPLASH;
public static void update() {
if(Minecraft.getMinecraft() == null || Minecraft.getMinecraft().getLanguageManager() == null) {
return;
}
drawSplash(Minecraft.getMinecraft().getTextureManager());
}
public static void setProgress(int givenProgress, String givenText) {
update();
}
public static void drawSplash(TextureManager tm) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
int scaleFactor = scaledResolution.getScaleFactor();
Framebuffer framebuffer = new Framebuffer(scaledResolution.getScaledWidth() * scaleFactor, scaledResolution.getScaledHeight() * scaleFactor, true);
framebuffer.bindFramebuffer(false);
GlStateManager.matrixMode(GL11.GL_PROJECTION);
GlStateManager.loadIdentity();
GlStateManager.ortho(0.0D, (double) scaledResolution.getScaledWidth(), (double) scaledResolution.getScaledHeight(), 0.0D, 1000.0D, 3000.0D);
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, 0.0F, -2000.0F);
GlStateManager.disableLighting();
GlStateManager.disableFog();
GlStateManager.disableDepth();
GlStateManager.enableTexture2D();
if(SPLASH == null) {
SPLASH = new ResourceLocation("silentclient/splash.png");
}
tm.bindTexture(SPLASH);
GlStateManager.resetColor();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
Gui.drawScaledCustomSizeModalRect(0, 0, 0, 0, 1920, 1080, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), 1920, 1080);
framebuffer.unbindFramebuffer();
framebuffer.framebufferRender(scaledResolution.getScaledWidth() * scaleFactor, scaledResolution.getScaledHeight() * scaleFactor);
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
Minecraft.getMinecraft().updateDisplay();
}
}

View File

@ -0,0 +1,190 @@
package net.silentclient.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
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.lite.GuiNews;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.silentmainmenu.MainMenuConcept;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.FileUtils;
import net.silentclient.client.utils.MouseCursorHandler;
import java.awt.*;
import java.io.IOException;
import java.util.ArrayList;
public class UserTutorial extends SilentScreen {
private int step = 1;
private ArrayList<String> configs = new ArrayList<>();
private int configIndex = 0;
@Override
public void initGui() {
super.initGui();
defaultCursor = false;
this.configs.clear();
this.buttonList.clear();
Client.backgroundPanorama.updateWidthHeight(this.width, this.height);
int blockY = this.height / 2 - 90;
int blockX = this.width / 2 - 175;
if(blockY < 40) {
blockY = 40;
}
this.buttonList.add(new Button(1, blockX + (350 / 2) - 50, blockY + 180 - 35, 100, 20, "Get Started"));
this.configs.add("BedWars");
this.configs.add("Minigames");
this.configs.add("PvP");
this.configs.add("Survival");
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
MouseCursorHandler.CursorType cursorType = getCursor(silentInputs, buttonList);
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());
RenderUtil.drawImage(new ResourceLocation("silentclient/logos/logo.png"), this.width / 2 - 48.8F, 15, 97.7F, 19);
int blockY = this.height / 2 - 90;
int blockX = this.width / 2 - 175;
if(blockY < 40) {
blockY = 40;
}
RenderUtils.drawRect(blockX, blockY, 350, 180, new Color(20, 20, 20).getRGB());
super.drawScreen(mouseX, mouseY, partialTicks);
if(MouseUtils.isInside(mouseX, mouseY, blockX + (350 / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE) / 2), blockY + 180 - 12, Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE), 10)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
Client.getInstance().getSilentFontRenderer().drawCenteredString("Skip Tutorial", blockX + (350 / 2), blockY + 180 - 12, 10, SilentFontRenderer.FontType.TITLE);
switch (step) {
case 1:
this.buttonList.get(0).displayString = "Get Started";
Client.getInstance().getSilentFontRenderer().drawCenteredString("Welcome to Silent Client 2.0", blockX + (350 / 2), blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
RenderUtil.drawImage(new ResourceLocation("silentclient/tutorial/features/feature1.png"), blockX + 132 - (86) - 10, blockY + 22, 86, 120);
RenderUtil.drawImage(new ResourceLocation("silentclient/tutorial/features/feature2.png"), blockX + 132, blockY + 22, 86, 120);
RenderUtil.drawImage(new ResourceLocation("silentclient/tutorial/features/feature3.png"), blockX + 132 + 86 + 10, blockY + 22, 86, 120);
break;
case 2:
this.buttonList.get(0).displayString = "Next";
Client.getInstance().getSilentFontRenderer().drawCenteredString("Choose a version of Silent Client", blockX + (350 / 2), blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
if(MouseUtils.isInside(mouseX, mouseY, blockX + 9, blockY + 29, 161, 102) || MouseUtils.isInside(mouseX, mouseY, blockX + 180, blockY + 29, 161, 102)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
if(!Client.getInstance().getGlobalSettings().isLite()) {
RenderUtils.drawRect(blockX + 9, blockY + 29, 161, 102, -1);
}
RenderUtil.drawImage(new ResourceLocation("silentclient/tutorial/version/regular.png"), blockX + 10, blockY + 30, 159, 100);
if(Client.getInstance().getGlobalSettings().isLite()) {
RenderUtils.drawRect(blockX + 180, blockY + 29, 161, 102, -1);
}
RenderUtil.drawImage(new ResourceLocation("silentclient/tutorial/version/lite.png"), blockX + 181, blockY + 30, 159, 100);
break;
case 3:
this.buttonList.get(0).displayString = "Next";
Client.getInstance().getSilentFontRenderer().drawCenteredString("Choose a config preset", blockX + (350 / 2), blockY + 3, 16, SilentFontRenderer.FontType.TITLE);
if(MouseUtils.isInside(mouseX, mouseY, blockX + 60, blockY + 35 + 50 - 10, 20, 20) || MouseUtils.isInside(mouseX, mouseY, blockX + 95 + 159 + 15, blockY + 35 + 50 - 10, 20, 20)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/back.png"), blockX + 60, blockY + 35 + 50 - 10, 20, 20);
RenderUtil.drawImage(new ResourceLocation("silentclient/icons/next.png"), blockX + 95 + 159 + 15, blockY + 35 + 50 - 10, 20, 20);
Client.getInstance().getSilentFontRenderer().drawCenteredString(this.configs.get(configIndex), blockX + (350 / 2), blockY + 20, 12, SilentFontRenderer.FontType.TITLE);
RenderUtil.drawImage(new ResourceLocation(String.format("silentclient/configs/screenshots/%s.png", this.configs.get(configIndex))), blockX + 95, blockY + 35, 159, 100);
break;
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
}
@Override
protected void actionPerformed(GuiButton button) {
super.actionPerformed(button);
if(button.id == 1) {
switch (step) {
case 1:
step = 2;
break;
case 2:
step = 3;
break;
case 3:
try {
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);
}
Client.getInstance().getGlobalSettings().setDisplayedTutorial(true);
Client.getInstance().getGlobalSettings().save();
mc.displayGuiScreen(Client.getInstance().getGlobalSettings().lite ? new GuiNews() : new MainMenuConcept());
}
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
super.mouseClicked(mouseX, mouseY, mouseButton);
int blockY = this.height / 2 - 90;
int blockX = this.width / 2 - 175;
if(blockY < 40) {
blockY = 40;
}
if(MouseUtils.isInside(mouseX, mouseY, blockX + (350 / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE) / 2), blockY + 180 - 12, Client.getInstance().getSilentFontRenderer().getStringWidth("Skip Tutorial", 10, SilentFontRenderer.FontType.TITLE), 10)) {
Client.getInstance().getGlobalSettings().setDisplayedTutorial(true);
Client.getInstance().getGlobalSettings().save();
mc.displayGuiScreen(Client.getInstance().getGlobalSettings().lite ? new GuiNews() : new MainMenuConcept());
return;
}
switch (step) {
case 2:
if(MouseUtils.isInside(mouseX, mouseY, blockX + 10, blockY + 30, 159, 100)) {
Client.getInstance().getGlobalSettings().setLite(false);
break;
}
if(MouseUtils.isInside(mouseX, mouseY, blockX + 181, blockY + 30, 159, 100)) {
Client.getInstance().getGlobalSettings().setLite(true);
break;
}
break;
case 3:
if(MouseUtils.isInside(mouseX, mouseY, blockX + 60, blockY + 35 + 50 - 10, 20, 20)) {
if(configIndex == 0) {
this.configIndex = this.configs.size() - 1;
} else {
this.configIndex -= 1;
}
break;
}
if(MouseUtils.isInside(mouseX, mouseY, blockX + 95 + 159 + 15, blockY + 35 + 50 - 10, 20, 20)) {
if(configIndex == this.configs.size() - 1) {
this.configIndex = 0;
} else {
this.configIndex += 1;
}
break;
}
break;
}
}
@Override
public void updateScreen() {
super.updateScreen();
Client.backgroundPanorama.tickPanorama();
}
}

View File

@ -0,0 +1,64 @@
package net.silentclient.client.gui.animation;
public final class SimpleAnimation {
private float value;
private long lastMS;
public SimpleAnimation(float value){
this.value = value;
this.lastMS = System.currentTimeMillis();
}
public void setAnimation(float value, double speed){
long currentMS = System.currentTimeMillis();
long delta = currentMS - this.lastMS;
this.lastMS = currentMS;
double deltaValue = 0D;
if(speed > 28) {
speed = 28;
}
if (speed != 0D) {
deltaValue = Math.abs(value - this.value) * 0.35F / (10D / speed);
}
this.value = calculateCompensation(value, this.value, deltaValue, delta);
}
public float getValue() {
return value;
}
public void setValue(float value) {
this.value = value;
}
private float calculateCompensation(final float target, float current, final double speed, long delta) {
float diff = current - target;
double add = (delta * (speed / 50));
if (diff > speed){
if(current - add > target) {
current -= add;
}else {
current = target;
}
}
else if (diff < -speed) {
if(current + add < target) {
current += add;
}else {
current = target;
}
}
else{
current = target;
}
return current;
}
}

View File

@ -0,0 +1,122 @@
package net.silentclient.client.gui.animation.normal;
public abstract class Animation {
public AnimationTimer timer = new AnimationTimer();
protected int duration;
protected double endPoint;
protected Direction direction;
public Animation(int ms, double endPoint) {
this.duration = ms;
this.endPoint = endPoint;
this.direction = Direction.FORWARDS;
}
public Animation(int ms, double endPoint, Direction direction) {
this.duration = ms;
this.endPoint = endPoint;
this.direction = direction;
}
public boolean isDone(Direction direction) {
return isDone() && this.direction.equals(direction);
}
public double getLinearOutput() {
return 1 - ((timer.getTime() / (double) duration) * endPoint);
}
public void reset() {
timer.reset();
}
public boolean isDone() {
return timer.hasTimeElapsed(duration);
}
public void setDuration(int duration) {
this.duration = duration;
}
public void changeDirection() {
setDirection(direction.opposite());
}
public void setDirection(Direction direction) {
if (this.direction != direction) {
this.direction = direction;
timer.setTime(System.currentTimeMillis() - (duration - Math.min(duration, timer.getTime())));
}
}
protected boolean correctOutput() {
return false;
}
public double getValue() {
if (direction == Direction.FORWARDS) {
if (isDone())
return endPoint;
return (getEquation(timer.getTime()) * endPoint);
} else {
if (isDone()) return 0;
if (correctOutput()) {
double revTime = Math.min(duration, Math.max(0, duration - timer.getTime()));
return getEquation(revTime) * endPoint;
} else return (1 - getEquation(timer.getTime())) * endPoint;
}
}
protected abstract double getEquation(double x);
public double getEndPoint() {
return endPoint;
}
public void setEndPoint(double endPoint) {
this.endPoint = endPoint;
}
public int getDuration() {
return duration;
}
public Direction getDirection() {
return direction;
}
}
class AnimationTimer {
public long lastMS = System.currentTimeMillis();
public void reset() {
lastMS = System.currentTimeMillis();
}
public boolean hasTimeElapsed(long time, boolean reset) {
if (System.currentTimeMillis() - lastMS > time) {
if (reset) reset();
return true;
}
return false;
}
public boolean hasTimeElapsed(long time) {
return System.currentTimeMillis() - lastMS > time;
}
public long getTime() {
return System.currentTimeMillis() - lastMS;
}
public void setTime(long time) {
lastMS = time;
}
}

View File

@ -0,0 +1,12 @@
package net.silentclient.client.gui.animation.normal;
public enum Direction {
FORWARDS,
BACKWARDS;
public Direction opposite() {
if (this == Direction.FORWARDS) {
return Direction.BACKWARDS;
} else return Direction.FORWARDS;
}
}

View File

@ -0,0 +1,20 @@
package net.silentclient.client.gui.animation.normal.impl;
import net.silentclient.client.gui.animation.normal.Animation;
import net.silentclient.client.gui.animation.normal.Direction;
public class DecelerateAnimation extends Animation {
public DecelerateAnimation(int ms, double endPoint) {
super(ms, endPoint);
}
public DecelerateAnimation(int ms, double endPoint, Direction direction) {
super(ms, endPoint, direction);
}
protected double getEquation(double x) {
double x1 = x / duration;
return 1 - ((x1 - 1) * (x1 - 1));
}
}

View File

@ -0,0 +1,30 @@
package net.silentclient.client.gui.animation.normal.impl;
import net.silentclient.client.gui.animation.normal.Animation;
import net.silentclient.client.gui.animation.normal.Direction;
public class EaseBackIn extends Animation {
private final float easeAmount;
public EaseBackIn(int ms, double endPoint, float easeAmount) {
super(ms, endPoint);
this.easeAmount = easeAmount;
}
public EaseBackIn(int ms, double endPoint, float easeAmount, Direction direction) {
super(ms, endPoint, direction);
this.easeAmount = easeAmount;
}
@Override
protected boolean correctOutput() {
return true;
}
@Override
protected double getEquation(double x) {
double x1 = x / duration;
float shrink = easeAmount + 1;
return Math.max(0, 1 + shrink * Math.pow(x1 - 1, 3) + easeAmount * Math.pow(x1 - 1, 2));
}
}

View File

@ -0,0 +1,114 @@
package net.silentclient.client.gui.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.silentclient.client.Client;
import net.silentclient.client.gui.font.SilentFontRenderer;
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.mods.settings.GeneralMod;
import net.silentclient.client.utils.ColorUtils;
import net.silentclient.client.utils.TimerUtils;
import java.awt.*;
public class Button extends GuiButton
{
protected int animatedOpacity = 0;
public boolean escMenu = false;
private int fontSize;
protected TimerUtils animateTimer = new TimerUtils();
private IButtonTheme theme;
public Button(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, int fontSize, boolean escMenu, IButtonTheme theme) {
super(buttonId, x, y, widthIn, heightIn, buttonText);
this.escMenu = escMenu;
this.theme = theme;
this.fontSize = fontSize;
}
public Button(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, boolean escMenu, IButtonTheme theme) {
this(buttonId, x, y, widthIn, heightIn, buttonText, 14, escMenu, theme);
}
public Button(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText, boolean escMenu) {
this(buttonId, x, y, widthIn, heightIn, buttonText, escMenu, new DefaultButtonTheme());
}
public Button(int buttonId, int x, int y, int widthIn, int heightIn, String buttonText) {
this(buttonId, x, y, widthIn, heightIn, buttonText, false);
}
public Button(int buttonId, int x, int y, String buttonText)
{
this(buttonId, x, y, 200, 20, buttonText);
}
public Button(int buttonId, int x, int y, String buttonText, boolean escMenu)
{
this(buttonId, x, y, 200, 20, buttonText, escMenu);
}
public void drawButton(Minecraft mc, int mouseX, int mouseY)
{
if(escMenu && Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Vanilla ESC Menu Layout").getValBoolean()) {
new GuiButton(this.id, this.xPosition, this.yPosition, this.width, this.height, this.displayString).drawButton(mc, mouseX, mouseY);
return;
}
if (this.visible)
{
GlStateManager.disableBlend();
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 ? 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.animatedOpacity < 75 && animateTimer.delay(30)) {
this.animatedOpacity += 15;
animateTimer.reset();
}
} else {
if (this.animatedOpacity != 0 && animateTimer.delay(30)) {
this.animatedOpacity -= 15;
animateTimer.reset();
}
}
this.drawButtonContent();
} else {
this.animatedOpacity = 0;
}
}
protected void drawButtonContent() {
ColorUtils.setColor(theme.getTextColor().getRGB());
Client.getInstance().getSilentFontRenderer().drawCenteredString(this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - fontSize) / 2, fontSize, SilentFontRenderer.FontType.TITLE, width - (fontSize / 2));
}
@Override
public void playPressSound(SoundHandler soundHandlerIn) {
if(!Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Silent Button Sounds").getValBoolean() && !(escMenu && Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Vanilla ESC Menu Layout").getValBoolean())) {
return;
}
super.playPressSound(soundHandlerIn);
}
public void setTheme(IButtonTheme theme) {
this.theme = theme;
}
public IButtonTheme getTheme() {
return theme;
}
}

View File

@ -0,0 +1,30 @@
package net.silentclient.client.gui.elements;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.theme.checkbox.DefaultCheckboxTheme;
import net.silentclient.client.gui.theme.checkbox.ICheckboxTheme;
import net.silentclient.client.gui.util.RenderUtil;
import java.awt.*;
public class Checkbox {
public static void render(int mouseX, int mouseY, float x, float y, String name, boolean selected) {
render(mouseX, mouseY, x, y, name, selected, new DefaultCheckboxTheme());
}
public static void render(int mouseX, int mouseY, float x, float y, String name, boolean selected, ICheckboxTheme theme) {
boolean hovered = Checkbox.isHovered(mouseX, mouseY, x, y);
Color checkColor = selected ? theme.getSelectedColor() : theme.getColor();
RenderUtil.drawRoundedOutline(x, y, 9, 9, 9, 2, new Color(checkColor.getRed(), checkColor.getGreen(), checkColor.getBlue(), hovered ? 127 : 255).getRGB());
if(selected) {
RenderUtil.drawRoundedRect(x + (9 / 2 - 5 / 2), y + (9 / 2 - 5 / 2), 5, 5, 5, checkColor.getRGB());
}
Client.getInstance().getSilentFontRenderer().drawString(name, x + 12, y + ((9 / 2) - (12 / 2)), 12, SilentFontRenderer.FontType.TITLE);
}
public static boolean isHovered(int mouseX, int mouseY, float x, float y) {
return MouseUtils.isInside(mouseX, mouseY, x, y, 9, 9);
}
}

View File

@ -0,0 +1,20 @@
package net.silentclient.client.gui.elements;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.util.RenderUtil;
import java.awt.*;
public class ColorPicker {
public static void render(int x, int y, int width, String name, int color) {
Client.getInstance().getSilentFontRenderer().drawString(name, x + 100, y - 2, 12, SilentFontRenderer.FontType.TITLE);
RenderUtil.drawRoundedRect(x + width - 20, y + 1, 15, 8, 5, color);
RenderUtil.drawRoundedOutline(x + width - 20, y + 1, 15, 8, 5, 2, new Color(255, 255, 255).getRGB());
}
public static boolean isHovered(int mouseX, int mouseY, int x, int y, int width) {
return MouseUtils.isInside(mouseX, mouseY, x + width - 20, y + 1, 15, 8);
}
}

View File

@ -0,0 +1,33 @@
package net.silentclient.client.gui.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.gui.util.RenderUtil;
public class IconButton extends Button
{
private ResourceLocation icon;
private int iconWidth;
private int iconHeight;
public IconButton(int buttonId, int x, int y, int widthIn, int heightIn, int iconWidth, int iconHeight, ResourceLocation icon) {
super(buttonId, x, y, widthIn, heightIn, "");
this.icon = icon;
this.iconWidth = iconWidth;
this.iconHeight = iconHeight;
}
public IconButton(int buttonId, int x, int y, ResourceLocation icon)
{
this(buttonId, x, y, 20, 20, 12, 12, icon);
}
@Override
protected void drawButtonContent() {
RenderUtil.drawImage(icon, this.xPosition + ((this.width / 2) - (this.iconWidth / 2)), this.yPosition + ((this.height / 2) - (this.iconHeight / 2)), this.iconWidth, this.iconHeight, false);
}
}

View File

@ -0,0 +1,188 @@
package net.silentclient.client.gui.elements;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.util.ChatAllowedCharacters;
import net.minecraft.util.EnumChatFormatting;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.theme.input.DefaultInputTheme;
import net.silentclient.client.gui.theme.input.IInputTheme;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.utils.ColorUtils;
import net.silentclient.client.utils.NotificationUtils;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Keyboard;
import java.util.regex.Pattern;
public class Input {
private boolean isFocused;
private String value;
private Pattern pattern;
private String name;
private int maxLength;
private boolean keyValue;
private int key;
private boolean hovered = false;
public Input(String name, String value, int key, Pattern pattern, int maxLength, boolean keyValue) {
this.name = name;
this.pattern = pattern;
this.maxLength = maxLength;
this.keyValue = keyValue;
this.value = value;
this.key = key;
}
public Input(String name, Pattern pattern, int maxLength) {
this(name, "", -1, pattern, maxLength, false);
}
public Input(String name, String value) {
this(name, value, -1, Pattern
.compile("^[~`!@#$%^&*()_+=[\\\\]\\\\\\\\\\\\{\\\\}|;':\\\",.\\\\/<>?a-zA-Z0-9-\\s]+$"), 20, false);
}
public Input(String name, int key) {
this(name , "", key, Pattern
.compile("^[~`!@#$%^&*()_+=[\\\\]\\\\\\\\\\\\{\\\\}|;':\\\",.\\\\/<>?a-zA-Z0-9-\\s]+$"), 1, true);
}
public Input(String name, Pattern pattern) {
this(name, pattern, 20);
}
public Input(String name) {
this(name, Pattern
.compile("^[\\w,\\s-]{0,20}+$"), 20);
}
public void render(int mouseX, int mouseY, float x, float y, int width) {
this.render(mouseX, mouseY, x, y, width, false);
}
public void render(int mouseX, int mouseY, float x, float y, int width, boolean small) {
this.render(mouseX, mouseY, x, y, width, small, new DefaultInputTheme());
}
public void render(int mouseX, int mouseY, float x, float y, int width, boolean small, IInputTheme theme) {
this.render(mouseX, mouseY, x, y, width, small, theme, false);
}
public void render(int mouseX, int mouseY, float x, float y, int width, boolean small, IInputTheme theme, boolean center) {
int borderColor = theme.getBorderColor().getRGB();
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) {
borderColor = theme.getHoveredBorderColor().getRGB();
this.hovered = true;
} else {
this.hovered = false;
}
if(isFocused) {
borderColor = theme.getFocusedBorderColor().getRGB();
}
RenderUtil.drawRoundedOutline(x, y, width, (small ? 15 : 20), 3, isFocused ? 2 : 1, borderColor);
String renderText = name;
ColorUtils.setColor(theme.getBorderColor().getRGB());
if(value.length() != 0) {
renderText = value;
}
if(keyValue) {
if(key != -1) {
renderText = Keyboard.getKeyName(key);
} else {
renderText = "NONE";
}
if(isFocused) {
renderText = "...";
}
}
ColorUtils.setColor(theme.getFocusedBorderColor().getRGB());
float textX = x + 2;
if(center) {
textX = x + (width / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth(renderText, small ? 12 : 14, SilentFontRenderer.FontType.TITLE) / 2);
}
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), textX, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
}
public boolean isHovered() {
return hovered;
}
public boolean isFocused() {
return isFocused;
}
public void onClick(int mouseX, int mouseY, int x, int y, int width) {
this.onClick(mouseX, mouseY, x, y, width, false);
}
public void onClick(int mouseX, int mouseY, int x, int y, int width, boolean small) {
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, small ? 15 : 20)) {
this.isFocused = true;
} else {
this.isFocused = false;
}
}
public void onKeyTyped(char typedChar, int keyCode) {
if(isFocused) {
if(keyValue) {
if(keyCode == Keyboard.KEY_ESCAPE) {
key = -1;
isFocused = false;
return;
}
key = keyCode;
isFocused = false;
return;
}
if(keyCode == Keyboard.KEY_ESCAPE) {
isFocused = false;
return;
}
if(keyCode == Keyboard.KEY_BACK) {
if (value != null || value.length() != 0 || value != "") {
this.value = StringUtils.chop(this.value);
}
return;
}
String test = "";
if (GuiScreen.isKeyComboCtrlV(keyCode))
{
test += GuiScreen.getClipboardString();
if(this.pattern.matcher(test).matches()) {
value += ChatAllowedCharacters.filterAllowedCharacters(test);
}
return;
}
if(value.length() > maxLength - 1) {
NotificationUtils.showNotification("Error", "Maximum " + name + " size " + maxLength + " characters");
return;
}
test += typedChar;
if(this.pattern.matcher(test).matches()) {
value += ChatAllowedCharacters.filterAllowedCharacters(test);
}
}
}
public String getValue() {
return value;
}
public int getKey() {
return key;
}
public boolean isKeyValue() {
return keyValue;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,36 @@
package net.silentclient.client.gui.elements;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.utils.ColorUtils;
import java.awt.*;
public class Select {
public static void render(int mouseX, int mouseY, int x, int y, int width, String name, String selected) {
int left = Select.getLeft(x, width);
boolean firstHovered = Select.prevHovered(mouseX, mouseY, x, y, width);
boolean twoHovered = Select.nextHovered(mouseX, mouseY, x, y, width);
Client.getInstance().getSilentFontRenderer().drawString(name + ":", x + 100, y - 2, 12, SilentFontRenderer.FontType.TITLE);
ColorUtils.setColor(new Color(255, 255, 255, firstHovered ? 127 : 255).getRGB());
Client.getInstance().getSilentFontRenderer().drawString("<", left, y - 2, 12, SilentFontRenderer.FontType.TITLE);
ColorUtils.setColor(new Color(255, 255, 255).getRGB());
Client.getInstance().getSilentFontRenderer().drawString(selected, left + 5 + ((Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE) + 5 + 100 + 5 + Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE)) / 2 - Client.getInstance().getSilentFontRenderer().getStringWidth(selected, 12, SilentFontRenderer.FontType.TITLE) / 2), y - 2, 12, SilentFontRenderer.FontType.TITLE);
ColorUtils.setColor(new Color(255, 255, 255, twoHovered ? 127 : 255).getRGB());
Client.getInstance().getSilentFontRenderer().drawString(">", left + Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE) + 5 + 100 + 5, y - 2, 12, SilentFontRenderer.FontType.TITLE);
ColorUtils.setColor(new Color(255, 255, 255).getRGB());
}
public static int getLeft(int x, int width) {
return (int) (x + width - (Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE) + 5 + 100 + 5 + Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE) + 5));
}
public static boolean prevHovered(int mouseX, int mouseY, int x, int y, int width) {
return MouseUtils.isInside(mouseX, mouseY, Select.getLeft(x, width), y - 2, Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE), 12);
}
public static boolean nextHovered(int mouseX, int mouseY, int x, int y, int width) {
return MouseUtils.isInside(mouseX, mouseY, Select.getLeft(x, width) + Client.getInstance().getSilentFontRenderer().getStringWidth("<", 12, SilentFontRenderer.FontType.TITLE) + 5 + 100 + 5, y - 2, Client.getInstance().getSilentFontRenderer().getStringWidth(">", 12, SilentFontRenderer.FontType.TITLE), 12);
}
}

Some files were not shown because too many files have changed in this diff Show More