Merge pull request #40 from Silent-Client/TEST2

Test2
This commit is contained in:
kirillsaint 2023-09-06 23:09:44 +06:00 committed by GitHub
commit 7558ebd33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View File

@ -1,10 +1,6 @@
package net.silentclient.client.gui.font;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@ -12,10 +8,14 @@ import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.silentclient.client.Client;
import org.apache.commons.io.Charsets;
import org.lwjgl.opengl.GL11;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Map;
public class SilentFontRenderer {
private static final ResourceLocation silentFontHeader = new ResourceLocation("silentclient/fonts/silent-font-0.png");
private static final ResourceLocation silentFontTitle = new ResourceLocation("silentclient/fonts/silent-font-1.png");
@ -302,7 +302,7 @@ public class SilentFontRenderer {
this.renderString(x, y, string, 128 / fontHeight, fontType, true);
}
public void drawString(String string, int x, int y, int fontHeight, FontType fontType, int maxWidth)
public void drawString(String string, float x, float y, int fontHeight, FontType fontType, int maxWidth)
{
this.getClass();
if(this.getStringWidth(string, fontHeight, fontType) > maxWidth) {

View File

@ -11,14 +11,15 @@ import java.text.DecimalFormat;
public class RegularSlider {
public static void render(float x, float y, int width, String name, double max, double value) {
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE);
int valueWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE, 142 - valueWidth);
RenderUtil.drawRoundedRect(x, y + 15, width, 9, 3, Color.black.getRGB());
if(value != 0) {
RenderUtil.drawRoundedRect(x, y + 15, width * (float) (value / max), 9, 3, -1);
}
float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE);
float textLeft = x + width - valueWidth;
Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE);
}

View File

@ -7,6 +7,7 @@ import net.minecraft.client.settings.KeyBinding;
import net.silentclient.client.Client;
import net.silentclient.client.keybinds.KeyBindManager;
import net.silentclient.client.mixin.ducks.GameSettingsExt;
import net.silentclient.client.mods.player.ZoomMod;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import org.spongepowered.asm.mixin.Mixin;
@ -52,6 +53,9 @@ public class GameSettingsMixin implements GameSettingsExt {
*/
@Overwrite
public static boolean isKeyDown(KeyBinding key) {
if(Client.getInstance().getModInstances().getZoomMod().isEnabled() && key.getKeyDescription().equalsIgnoreCase("of.key.zoom") && key.getKeyCode() == Client.getInstance().getSettingsManager().getSettingByClass(ZoomMod.class, "Keybind").getKeybind()) {
return false;
}
int keyCode = key.getKeyCode();
if (keyCode != 0 && keyCode < 256) {
return keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode);