From cd608af8905189fb0e6b6cd78ed256d6c75c9d85 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Fri, 18 Aug 2023 18:22:01 +0600 Subject: [PATCH 1/3] Better Friend List Overlay --- .../gui/friends/FriendsListOverlay.java | 36 +++++++++++++++---- .../client/gui/lite/LiteAccountPicker.java | 2 +- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java b/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java index a2d5485..a3f3268 100644 --- a/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java +++ b/src/main/java/net/silentclient/client/gui/friends/FriendsListOverlay.java @@ -10,6 +10,7 @@ import net.silentclient.client.gui.animation.SimpleAnimation; import net.silentclient.client.gui.elements.Button; import net.silentclient.client.gui.elements.IconButton; import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.lite.LiteAccountPicker; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.theme.Theme; @@ -55,11 +56,18 @@ public class FriendsListOverlay extends GuiScreen { GlStateManager.pushMatrix(); int width = 150; GlStateManager.translate(this.introAnimation.getValue(), 0, 0); - this.introAnimation.setAnimation(0, 30); + this.introAnimation.setValue(0); RenderUtils.drawRect(0, 0, width, height, Theme.backgroundColor().getRGB()); - 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"), 3, 5, 18, 18, false); + if(!LiteAccountPicker.avatars.containsKey(Client.getInstance().getAccount().original_username)) { + LiteAccountPicker.avatars.put(Client.getInstance().getAccount().original_username, new LiteAccountPicker.MinecraftAvatar(Client.getInstance().getAccount().original_username)); + } + + if(!LiteAccountPicker.avatars.get(Client.getInstance().getAccount().original_username).initSkin) { + LiteAccountPicker.avatars.get(Client.getInstance().getAccount().original_username).loadSkin(); + } + RenderUtil.drawImage(LiteAccountPicker.avatars.get(Client.getInstance().getAccount().original_username).imageLocation, 3, 5, 18, 18, false); ColorUtils.setColor(new Color(9, 165, 51).getRGB()); - font.drawString(Client.getInstance().getAccount().original_username, 23, 5 - 2, 12, SilentFontRenderer.FontType.TITLE); + font.drawString(Client.getInstance().getAccount().original_username, 23, 5 - 1, 12, SilentFontRenderer.FontType.TITLE); ColorUtils.setColor(new Color(255, 255, 255, 127).getRGB()); font.drawString(mc.getCurrentServerData() == null ? "Online" : "Playing on " + mc.getCurrentServerData().serverIP, 23, 5 + 8, 10, SilentFontRenderer.FontType.TITLE, 90); super.drawScreen(mouseX, mouseY, partialTicks); @@ -73,13 +81,20 @@ public class FriendsListOverlay extends GuiScreen { GL11.glScissor(0 * s, translatedY * s, width * s, listHeight * s); if(!showRequests) { for(FriendsResponse.Friend friend : Client.getInstance().getFriends().getFriends()) { - RenderUtil.drawImage(friend.getIcon().getLocation(), 3, friendY, 18, 18, false); + if(!LiteAccountPicker.avatars.containsKey(friend.username)) { + LiteAccountPicker.avatars.put(friend.username, new LiteAccountPicker.MinecraftAvatar(friend.username)); + } + + if(!LiteAccountPicker.avatars.get(friend.username).initSkin) { + LiteAccountPicker.avatars.get(friend.username).loadSkin(); + } + RenderUtil.drawImage(LiteAccountPicker.avatars.get(friend.username).imageLocation, 3, friendY, 18, 18, false); if(friend.isOnline()) { ColorUtils.setColor(new Color(9, 165, 51).getRGB()); } else { ColorUtils.setColor(new Color(255, 255, 255).getRGB()); } - font.drawString(friend.getUsername(), 23, friendY - 2, 12, SilentFontRenderer.FontType.TITLE); + font.drawString(friend.getUsername(), 23, friendY - 1, 12, SilentFontRenderer.FontType.TITLE); ColorUtils.setColor(new Color(255, 255, 255, 127).getRGB()); font.drawString(friend.isOnline() ? friend.getCurrentServer().equals("") ? "Online" : "Playing on " + friend.getCurrentServer() : "Offline", 23, friendY + 8, 10, SilentFontRenderer.FontType.TITLE, 108); RenderUtil.drawImage(new ResourceLocation("silentclient/icons/cross.png"), 135, friendY + 3, 12, 12, false); @@ -87,9 +102,16 @@ public class FriendsListOverlay extends GuiScreen { } } else { for(FriendsResponse.Request request : Client.getInstance().getFriends().getRequests()) { - RenderUtil.drawImage(request.getIcon().getLocation(), 3, friendY, 18, 18, false); + if(!LiteAccountPicker.avatars.containsKey(request.username)) { + LiteAccountPicker.avatars.put(request.username, new LiteAccountPicker.MinecraftAvatar(request.username)); + } + + if(!LiteAccountPicker.avatars.get(request.username).initSkin) { + LiteAccountPicker.avatars.get(request.username).loadSkin(); + } + RenderUtil.drawImage(LiteAccountPicker.avatars.get(request.username).imageLocation, 3, friendY, 18, 18, false); ColorUtils.setColor(new Color(255, 255, 255).getRGB()); - font.drawString(request.getUsername(), 23, friendY - 2, 12, SilentFontRenderer.FontType.TITLE); + font.drawString(request.getUsername(), 23, friendY - 1, 12, SilentFontRenderer.FontType.TITLE); ColorUtils.setColor(new Color(255, 255, 255, 127).getRGB()); font.drawString(request.isIncoming() ? "Incoming Friend Request" : "Outgoing Friend Request", 23, friendY + 8, 10, SilentFontRenderer.FontType.TITLE); if(request.isIncoming()) { diff --git a/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java b/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java index 77887ca..15f7b02 100644 --- a/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java +++ b/src/main/java/net/silentclient/client/gui/lite/LiteAccountPicker.java @@ -118,7 +118,7 @@ public class LiteAccountPicker extends AccountPicker { this.open = false; } - public class MinecraftAvatar { + public static class MinecraftAvatar { public ResourceLocation imageLocation = new ResourceLocation("silentclient/images/steve_head.png"); public BufferedImage image = null; public boolean initSkin = false; From 88e28374ef5e0a2ed7d29e80c33d836c1883edac Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Fri, 18 Aug 2023 18:24:22 +0600 Subject: [PATCH 2/3] Fixed Tab Icons --- .../client/mixin/mixins/GuiPlayerTabOverlayMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java index 1c80701..8e3dedb 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GuiPlayerTabOverlayMixin.java @@ -178,7 +178,7 @@ public abstract class GuiPlayerTabOverlayMixin { { EntityPlayer entityplayer = this.mc.theWorld.getPlayerEntityByUUID(gameprofile.getId()); try { - isSilent = Boolean.parseBoolean(Players.getPlayerStatus(entityplayer == mc.thePlayer, entityplayer.getName().toString(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer)); + isSilent = Boolean.parseBoolean(Players.getPlayerStatus(entityplayer == mc.thePlayer, entityplayer.getName().toString(), entityplayer.getUniqueID(), (AbstractClientPlayer) entityplayer)) && Client.getInstance().getModInstances().getModByClass(TabMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(TabMod.class, "Show Nametag Icons").getValBoolean(); } catch (Exception e) { isSilent = false; } From c9abb0273ee4c3b7feb6b083104a884fd8023741 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Mon, 21 Aug 2023 15:29:49 +0600 Subject: [PATCH 3/3] Better Math --- .../silentclient/client/math/JavaMath.java | 12 ++++++ .../silentclient/client/math/LibGDXMath.java | 29 +++++++++++++++ .../silentclient/client/math/RandomMath.java | 12 ++++++ .../client/math/RivensFullMath.java | 27 ++++++++++++++ .../client/math/RivensHalfMath.java | 33 +++++++++++++++++ .../silentclient/client/math/RivensMath.java | 37 +++++++++++++++++++ .../silentclient/client/math/TaylorMath.java | 33 +++++++++++++++++ .../client/mixin/mixins/MathHelperMixin.java | 27 ++++++++++++++ src/main/resources/mixins.SilentClient.json | 3 +- 9 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/silentclient/client/math/JavaMath.java create mode 100644 src/main/java/net/silentclient/client/math/LibGDXMath.java create mode 100644 src/main/java/net/silentclient/client/math/RandomMath.java create mode 100644 src/main/java/net/silentclient/client/math/RivensFullMath.java create mode 100644 src/main/java/net/silentclient/client/math/RivensHalfMath.java create mode 100644 src/main/java/net/silentclient/client/math/RivensMath.java create mode 100644 src/main/java/net/silentclient/client/math/TaylorMath.java create mode 100644 src/main/java/net/silentclient/client/mixin/mixins/MathHelperMixin.java diff --git a/src/main/java/net/silentclient/client/math/JavaMath.java b/src/main/java/net/silentclient/client/math/JavaMath.java new file mode 100644 index 0000000..14b2a2b --- /dev/null +++ b/src/main/java/net/silentclient/client/math/JavaMath.java @@ -0,0 +1,12 @@ +package net.silentclient.client.math; + +public class JavaMath { + + public static float sin(float radians) { + return (float) Math.sin((double) radians); + } + + public static float cos(float radians) { + return (float) Math.cos((double) radians); + } +} diff --git a/src/main/java/net/silentclient/client/math/LibGDXMath.java b/src/main/java/net/silentclient/client/math/LibGDXMath.java new file mode 100644 index 0000000..db7167f --- /dev/null +++ b/src/main/java/net/silentclient/client/math/LibGDXMath.java @@ -0,0 +1,29 @@ +package net.silentclient.client.math; + +public class LibGDXMath { + + public static final float BF_PI = 3.1415927F; + public static final float BF_degreesToRadians = 0.017453292F; + private static final float[] BF_table = new float[16384]; + + public static float sin(float radians) { + return LibGDXMath.BF_table[(int) (radians * 2607.5945F) & 16383]; + } + + public static float cos(float radians) { + return LibGDXMath.BF_table[(int) ((radians + 1.5707964F) * 2607.5945F) & 16383]; + } + + static { + int i; + + for (i = 0; i < 16384; ++i) { + LibGDXMath.BF_table[i] = (float) Math.sin((double) (((float) i + 0.5F) / 16384.0F * 6.2831855F)); + } + + for (i = 0; i < 360; i += 90) { + LibGDXMath.BF_table[(int) ((float) i * 45.511112F) & 16383] = (float) Math.sin((double) ((float) i * 0.017453292F)); + } + + } +} diff --git a/src/main/java/net/silentclient/client/math/RandomMath.java b/src/main/java/net/silentclient/client/math/RandomMath.java new file mode 100644 index 0000000..8cc2fc1 --- /dev/null +++ b/src/main/java/net/silentclient/client/math/RandomMath.java @@ -0,0 +1,12 @@ +package net.silentclient.client.math; + +public class RandomMath { + + public static float sin(float radians) { + return (float) Math.random() * radians; + } + + public static float cos(float radians) { + return (float) Math.random() * radians; + } +} diff --git a/src/main/java/net/silentclient/client/math/RivensFullMath.java b/src/main/java/net/silentclient/client/math/RivensFullMath.java new file mode 100644 index 0000000..5b60fd4 --- /dev/null +++ b/src/main/java/net/silentclient/client/math/RivensFullMath.java @@ -0,0 +1,27 @@ +package net.silentclient.client.math; + +public class RivensFullMath { + + private static final float BF_SIN_TO_COS = 1.5707964F; + private static final int BF_SIN_BITS = 12; + private static final int BF_SIN_MASK = ~(-1 << RivensFullMath.BF_SIN_BITS); + private static final int BF_SIN_COUNT = RivensFullMath.BF_SIN_MASK + 1; + private static final float BF_radFull = 6.2831855F; + private static final float BF_radToIndex = (float) RivensFullMath.BF_SIN_COUNT / RivensFullMath.BF_radFull; + private static final float[] BF_sinFull = new float[RivensFullMath.BF_SIN_COUNT]; + + public static float sin(float rad) { + return RivensFullMath.BF_sinFull[(int) (rad * RivensFullMath.BF_radToIndex) & RivensFullMath.BF_SIN_MASK]; + } + + public static float cos(float rad) { + return sin(rad + RivensFullMath.BF_SIN_TO_COS); + } + + static { + for (int i = 0; i < RivensFullMath.BF_SIN_COUNT; ++i) { + RivensFullMath.BF_sinFull[i] = (float) Math.sin(((double) i + (double) Math.min(1, i % (RivensFullMath.BF_SIN_COUNT / 4)) * 0.5D) / (double) RivensFullMath.BF_SIN_COUNT * (double) RivensFullMath.BF_radFull); + } + + } +} diff --git a/src/main/java/net/silentclient/client/math/RivensHalfMath.java b/src/main/java/net/silentclient/client/math/RivensHalfMath.java new file mode 100644 index 0000000..aa84682 --- /dev/null +++ b/src/main/java/net/silentclient/client/math/RivensHalfMath.java @@ -0,0 +1,33 @@ +package net.silentclient.client.math; + +public class RivensHalfMath { + + private static final float BF_SIN_TO_COS = 1.5707964F; + private static final int BF_SIN_BITS = 12; + private static final int BF_SIN_MASK = ~(-1 << RivensHalfMath.BF_SIN_BITS); + private static final int BF_SIN_MASK2 = RivensHalfMath.BF_SIN_MASK >> 1; + private static final int BF_SIN_COUNT = RivensHalfMath.BF_SIN_MASK + 1; + private static final int BF_SIN_COUNT2 = RivensHalfMath.BF_SIN_MASK2 + 1; + private static final float BF_radFull = 6.2831855F; + private static final float BF_radToIndex = (float) RivensHalfMath.BF_SIN_COUNT / RivensHalfMath.BF_radFull; + private static final float[] BF_sinHalf = new float[RivensHalfMath.BF_SIN_COUNT2]; + + public static float sin(float rad) { + int index1 = (int) (rad * RivensHalfMath.BF_radToIndex) & RivensHalfMath.BF_SIN_MASK; + int index2 = index1 & RivensHalfMath.BF_SIN_MASK2; + int mul = index1 == index2 ? 1 : -1; + + return RivensHalfMath.BF_sinHalf[index2] * (float) mul; + } + + public static float cos(float rad) { + return sin(rad + RivensHalfMath.BF_SIN_TO_COS); + } + + static { + for (int i = 0; i < RivensHalfMath.BF_SIN_COUNT2; ++i) { + RivensHalfMath.BF_sinHalf[i] = (float) Math.sin(((double) i + (double) Math.min(1, i % (RivensHalfMath.BF_SIN_COUNT / 4)) * 0.5D) / (double) RivensHalfMath.BF_SIN_COUNT * (double) RivensHalfMath.BF_radFull); + } + + } +} diff --git a/src/main/java/net/silentclient/client/math/RivensMath.java b/src/main/java/net/silentclient/client/math/RivensMath.java new file mode 100644 index 0000000..35aa121 --- /dev/null +++ b/src/main/java/net/silentclient/client/math/RivensMath.java @@ -0,0 +1,37 @@ +package net.silentclient.client.math; + +public class RivensMath { + + private static final int BF_SIN_BITS = 12; + private static final int BF_SIN_MASK = ~(-1 << RivensMath.BF_SIN_BITS); + private static final int BF_SIN_COUNT = RivensMath.BF_SIN_MASK + 1; + private static final float BF_radFull = 6.2831855F; + private static final float BF_radToIndex = (float) RivensMath.BF_SIN_COUNT / RivensMath.BF_radFull; + private static final float BF_degFull = 360.0F; + private static final float BF_degToIndex = (float) RivensMath.BF_SIN_COUNT / RivensMath.BF_degFull; + private static final float[] BF_sin = new float[RivensMath.BF_SIN_COUNT]; + private static final float[] BF_cos = new float[RivensMath.BF_SIN_COUNT]; + + public static float sin(float rad) { + return RivensMath.BF_sin[(int) (rad * RivensMath.BF_radToIndex) & RivensMath.BF_SIN_MASK]; + } + + public static float cos(float rad) { + return RivensMath.BF_cos[(int) (rad * RivensMath.BF_radToIndex) & RivensMath.BF_SIN_MASK]; + } + + static { + int i; + + for (i = 0; i < RivensMath.BF_SIN_COUNT; ++i) { + RivensMath.BF_sin[i] = (float) Math.sin((double) (((float) i + 0.5F) / (float) RivensMath.BF_SIN_COUNT * RivensMath.BF_radFull)); + RivensMath.BF_cos[i] = (float) Math.cos((double) (((float) i + 0.5F) / (float) RivensMath.BF_SIN_COUNT * RivensMath.BF_radFull)); + } + + for (i = 0; i < 360; i += 90) { + RivensMath.BF_sin[(int) ((float) i * RivensMath.BF_degToIndex) & RivensMath.BF_SIN_MASK] = (float) Math.sin((double) i * 3.141592653589793D / 180.0D); + RivensMath.BF_cos[(int) ((float) i * RivensMath.BF_degToIndex) & RivensMath.BF_SIN_MASK] = (float) Math.cos((double) i * 3.141592653589793D / 180.0D); + } + + } +} diff --git a/src/main/java/net/silentclient/client/math/TaylorMath.java b/src/main/java/net/silentclient/client/math/TaylorMath.java new file mode 100644 index 0000000..682ca29 --- /dev/null +++ b/src/main/java/net/silentclient/client/math/TaylorMath.java @@ -0,0 +1,33 @@ +package net.silentclient.client.math; + +public class TaylorMath { + + private static final float BF_SIN_TO_COS = 1.5707964F; + + public static float sin(float rad) { + double x = (double) rad; + double x2 = x * x; + double x3 = x2 * x; + double x5 = x2 * x3; + double x7 = x2 * x5; + double x9 = x2 * x7; + double x11 = x2 * x9; + double x13 = x2 * x11; + double x15 = x2 * x13; + double x17 = x2 * x15; + double val = x - x3 * 0.16666666666666666D; + + val += x5 * 0.008333333333333333D; + val -= x7 * 1.984126984126984E-4D; + val += x9 * 2.7557319223985893E-6D; + val -= x11 * 2.505210838544172E-8D; + val += x13 * 1.6059043836821613E-10D; + val -= x15 * 7.647163731819816E-13D; + val += x17 * 2.8114572543455206E-15D; + return (float) val; + } + + public static float cos(float rad) { + return sin(rad + TaylorMath.BF_SIN_TO_COS); + } +} diff --git a/src/main/java/net/silentclient/client/mixin/mixins/MathHelperMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/MathHelperMixin.java new file mode 100644 index 0000000..b47a09f --- /dev/null +++ b/src/main/java/net/silentclient/client/mixin/mixins/MathHelperMixin.java @@ -0,0 +1,27 @@ +package net.silentclient.client.mixin.mixins; + +import net.minecraft.util.MathHelper; +import net.silentclient.client.math.RivensHalfMath; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(MathHelper.class) +public class MathHelperMixin { + /** + * @author kirillsaint + * @reason custom math (faster) + */ + @Overwrite + public static float sin(float param) { + return RivensHalfMath.sin(param); + } + + /** + * @author kirillsaint + * @reason custom math (faster) + */ + @Overwrite + public static float cos(float param) { + return RivensHalfMath.cos(param); + } +} diff --git a/src/main/resources/mixins.SilentClient.json b/src/main/resources/mixins.SilentClient.json index a230184..efda61a 100644 --- a/src/main/resources/mixins.SilentClient.json +++ b/src/main/resources/mixins.SilentClient.json @@ -114,6 +114,7 @@ "accessors.optifine.CustomColorsAccessor", "accessors.optifine.ConfigAccessor", "mixins.NetworkPlayerInfoMixin", - "accessors.NetworkPlayerInfoAccessor" + "accessors.NetworkPlayerInfoAccessor", + "mixins.MathHelperMixin" ] } \ No newline at end of file