This commit is contained in:
kirillsaint 2023-07-05 15:27:33 +06:00
parent 94d0798a41
commit 104454503e
13 changed files with 184 additions and 25 deletions

View File

@ -20,6 +20,7 @@ import net.silentclient.client.gui.clickgui.ClickGUI;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.util.BackgroundPanorama;
import net.silentclient.client.keybinds.KeyBindManager;
import net.silentclient.client.mixin.SilentClientTweaker;
import net.silentclient.client.mods.ModInstances;
import net.silentclient.client.mods.SettingsManager;
import net.silentclient.client.mods.settings.FPSBoostMod;
@ -55,7 +56,7 @@ public class Client {
}
private BuildData buildData = new BuildData();
private UserData userData = new UserData();
private UserData userData = new UserData(SilentClientTweaker.TOKEN);
public File dir;
private SettingsManager settingsManager;
public ConfigManager configManager;
@ -81,6 +82,7 @@ public class Client {
public static BackgroundPanorama backgroundPanorama;
private KeyBindManager keyBindManager;
private IMetadataSerializer iMetadataSerializer;
private MouseCursorHandler mouseCursorHandler;
public static void memoryDebug(String paramString) {
LogManager.getLogger().info("-- Start Memory Debug -- " + paramString);
@ -109,22 +111,6 @@ public class Client {
in.close();
} catch (Exception e1) {
Client.logger.catching(e1);
}
try {
InputStream in = new FileInputStream(new File(Minecraft.getMinecraft().mcDataDir, "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();
} catch (Exception err) {
}
logger.info("---------[ Silent Client Initialising ]---------");
logger.info("MC Version: 1.8.9");
@ -264,9 +250,8 @@ public class Client {
}
}
if(account.getCustomSkin()) {
logger.info("STARTING > custom-skin");
}
logger.info("STARTING > mouse-cursor-handler");
this.mouseCursorHandler = new MouseCursorHandler();
} catch(Exception err) {
logger.info("STARTING > ERROR: " + err.getMessage());
throw err;
@ -558,4 +543,8 @@ public class Client {
public void setiMetadataSerializer(IMetadataSerializer iMetadataSerializer) {
this.iMetadataSerializer = iMetadataSerializer;
}
public MouseCursorHandler getMouseCursorHandler() {
return mouseCursorHandler;
}
}

View File

@ -1,10 +1,33 @@
package net.silentclient.client.gui;
import net.minecraft.client.gui.GuiScreen;
import net.silentclient.client.Client;
import net.silentclient.client.gui.elements.Input;
import net.silentclient.client.utils.MouseCursorHandler;
import java.io.IOException;
import java.util.ArrayList;
public class SilentScreen extends GuiScreen {
protected ArrayList<Input> silentInputs = new ArrayList<>();
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
MouseCursorHandler.CursorType cursorType = MouseCursorHandler.CursorType.NORMAL;
for(Input input : silentInputs) {
if(input.isHovered()) {
cursorType = MouseCursorHandler.CursorType.EDIT_TEXT;
}
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
Client.getInstance().getMouseCursorHandler().disableCursor();
}
}

View File

@ -205,10 +205,7 @@ public class ClickGUI extends SilentScreen {
PremiumGui.drawScreen(x, y, width, height, mouseX, mouseY, partialTicks, nametagMessageInput);
}
for (int i = 0; i < this.buttonList.size(); ++i)
{
((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY);
}
super.drawScreen(mouseX, mouseY, partialTicks);
scrollAnimation.setAnimation((float) scrollY, 16);
@ -442,6 +439,7 @@ public class ClickGUI extends SilentScreen {
@Override
public void onGuiClosed() {
super.onGuiClosed();
Client.getInstance().configManager.save();
MenuBlurUtils.unloadBlur();
}

View File

@ -23,6 +23,7 @@ public class Input {
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;
@ -63,6 +64,9 @@ public class Input {
int borderColor = new Color(255, 255, 255, 41).getRGB();
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) {
borderColor = new Color(255, 255, 255, 61).getRGB();
this.hovered = true;
} else {
this.hovered = false;
}
if(isFocused) {
@ -89,6 +93,10 @@ public class Input {
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), x + 2, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
}
public boolean isHovered() {
return hovered;
}
public boolean isFocused() {
return isFocused;
}

View File

@ -6,6 +6,7 @@ import java.text.DecimalFormat;
import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.MouseCursorHandler;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@ -88,8 +89,13 @@ public class HUDConfigScreen extends GuiScreen {
Client.getInstance().getSilentFontRenderer().drawString(0, 36, "selectedMod: " + (this.mod != null ? this.mod.getClass().getName() : "null"), 6, FontType.TITLE);
}
MouseCursorHandler.CursorType cursorType = MouseCursorHandler.CursorType.NORMAL;
for(Mod m : Client.getInstance().getModInstances().getMods()) {
if(m.isEnabled() && m instanceof ModDraggable) {
if(((ModDraggable) m).isHovered(mouseX, mouseY, scaledresolution) || ((ModDraggable) m).isDragging()) {
cursorType = MouseCursorHandler.CursorType.MOVE;
}
((ModDraggable) m).renderEditing(mouseX, mouseY, scaledresolution, debug, this);
if(((ModDraggable) m).isDragging()) {
@ -98,6 +104,8 @@ public class HUDConfigScreen extends GuiScreen {
}
}
Client.getInstance().getMouseCursorHandler().enableCursor(cursorType);
if (this.buttonList != null && this.buttonList.size() != 0)
{
if (this.tutorial)
@ -199,6 +207,7 @@ public class HUDConfigScreen extends GuiScreen {
((ModDraggable) m).setDragging(false);
}
}
Client.getInstance().getMouseCursorHandler().disableCursor();
}
@Override

View File

@ -13,11 +13,19 @@ import java.util.List;
public class SilentClientTweaker implements ITweaker {
private List<String> launchArgs = new ArrayList<>();
public static boolean hasOptifine = false;
public static String TOKEN = "";
@Override
public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile)
{
Client.logger.info("Silent Client Tweak Loader: Options");
if (args.contains("--sctoken")) {
final int index = args.indexOf("--sctoken");
try {
SilentClientTweaker.TOKEN = (String)args.get(index + 1);
}
catch (final Exception ex) {}
}
try {
Class.forName("optifine.OptiFineTweaker");
hasOptifine = true;

View File

@ -0,0 +1,120 @@
package net.silentclient.client.utils;
import org.apache.logging.log4j.LogManager;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor;
import org.lwjgl.input.Mouse;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class MouseCursorHandler {
private Map<CursorType, Cursor> cursors;
private CursorType currentCursor;
private boolean customCursorDisabled;
public MouseCursorHandler() {
this.cursors = new HashMap<CursorType, Cursor>();
this.currentCursor = CursorType.NORMAL;
this.customCursorDisabled = false;
final int minCursorSize = Cursor.getMinCursorSize();
final int maxCursorSize = Cursor.getMaxCursorSize();
LogManager.getLogger().info("Min Cursor Size: " + minCursorSize + " max: " + maxCursorSize);
if (maxCursorSize < 24) {
this.customCursorDisabled = true;
return;
}
this.loadCursorType(CursorType.MOVE);
this.loadCursorType(CursorType.NWSE_RESIZE);
this.loadCursorType(CursorType.NESW_RESIZE);
this.loadCursorType(CursorType.EDIT_TEXT);
this.loadCursorType(CursorType.POINTER);
}
public void loadCursorType(final CursorType cursorType) {
try {
this.cursors.put(cursorType, this.loadCursor(ImageIO.read(this.getClass().getResourceAsStream("/assets/minecraft/silentclient/mouse/" + cursorType.name().toLowerCase(Locale.US) + ".png"))));
}
catch (final Exception ex) {
LogManager.getLogger().catching((Throwable)ex);
}
}
public Cursor loadCursor(final BufferedImage bufferedImage) throws LWJGLException {
final int width = bufferedImage.getWidth();
final int height = bufferedImage.getHeight();
final int min = Math.min(Math.max(width, Cursor.getMinCursorSize()), Cursor.getMaxCursorSize());
final int[] src = new int[min * min];
int n = 0;
for (int i = 0; i < min; ++i) {
for (int j = 0; j < min; ++j) {
int rgb = 0;
try {
rgb = bufferedImage.getRGB(i, j);
}
catch (final Exception ex) {}
src[n++] = rgb;
}
}
final IntBuffer intBuffer = BufferUtils.createIntBuffer(min * min);
intBuffer.put(src);
intBuffer.rewind();
LogManager.getLogger().info("Loading cursor: w: " + width + " h: " + height);
return new Cursor(min, min, width / 2, height / 2, 1, intBuffer, (IntBuffer)null);
}
public boolean enableCursor(final CursorType cursorType) {
if (this.customCursorDisabled) {
return false;
}
if (this.currentCursor.equals(cursorType)) {
return true;
}
if (cursorType.equals(CursorType.NORMAL)) {
this.disableCursor();
return true;
}
try {
final Cursor nativeCursor = this.cursors.get(cursorType);
if (nativeCursor != null) {
Mouse.setNativeCursor(nativeCursor);
this.currentCursor = cursorType;
return true;
}
}
catch (final Exception ex) {
LogManager.getLogger().catching((Throwable)ex);
}
return false;
}
public void disableCursor() {
if (this.customCursorDisabled) {
return;
}
if (this.currentCursor != CursorType.NORMAL) {
try {
Mouse.setNativeCursor((Cursor)null);
this.currentCursor = CursorType.NORMAL;
}
catch (final Exception ex) {
LogManager.getLogger().catching((Throwable)ex);
}
}
}
public enum CursorType
{
NORMAL,
NESW_RESIZE,
NWSE_RESIZE,
MOVE,
EDIT_TEXT,
POINTER;
}
}

View File

@ -7,6 +7,10 @@ public class UserData {
this.access_token = "";
}
public UserData(String token) {
this.access_token = token;
}
public String getAccessToken() {
return access_token;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 354 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B