diff --git a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java index fe396bc..1727401 100644 --- a/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java +++ b/src/main/java/net/silentclient/client/cosmetics/gui/OutfitsGui.java @@ -101,6 +101,9 @@ public class OutfitsGui extends SilentScreen { 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); diff --git a/src/main/java/net/silentclient/client/emotes/DabEmote.java b/src/main/java/net/silentclient/client/emotes/DabEmote.java new file mode 100644 index 0000000..1137645 --- /dev/null +++ b/src/main/java/net/silentclient/client/emotes/DabEmote.java @@ -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) { + + } +} diff --git a/src/main/java/net/silentclient/client/emotes/animation/EmoteSimpleAnimation.java b/src/main/java/net/silentclient/client/emotes/animation/EmoteSimpleAnimation.java new file mode 100644 index 0000000..2774faf --- /dev/null +++ b/src/main/java/net/silentclient/client/emotes/animation/EmoteSimpleAnimation.java @@ -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; + } +} diff --git a/src/main/java/net/silentclient/client/gui/elements/Switch.java b/src/main/java/net/silentclient/client/gui/elements/Switch.java index fdfd40b..8ae6b57 100644 --- a/src/main/java/net/silentclient/client/gui/elements/Switch.java +++ b/src/main/java/net/silentclient/client/gui/elements/Switch.java @@ -8,16 +8,21 @@ import net.silentclient.client.gui.util.RenderUtil; public class Switch { public static void render(int mouseX, int mouseY, float x, float y, SimpleAnimation animation, boolean checked, boolean disabled) { - render(mouseX, mouseY, x, y, animation, checked, disabled, new DefaultSwitchTheme()); + render(mouseX, mouseY, x, y, animation, checked, disabled, null, new DefaultSwitchTheme()); } - public static void render(int mouseX, int mouseY, float x, float y, SimpleAnimation animation, boolean checked, boolean disabled, ISwitchSchema theme) { + public static void render(int mouseX, int mouseY, float x, float y, SimpleAnimation animation, boolean checked, boolean disabled, String tooltip) { + render(mouseX, mouseY, x, y, animation, checked, disabled, tooltip, new DefaultSwitchTheme()); + } + + public static void render(int mouseX, int mouseY, float x, float y, SimpleAnimation animation, boolean checked, boolean disabled, String tooltip, ISwitchSchema theme) { RenderUtil.drawRoundedRect(x, y, 15, 8, 8, disabled ? theme.getDisabledBackgroundColor().getRGB() : checked ? theme.getSelectedBackgroundColor().getRGB() : theme.getBackgroundColor().getRGB()); if(isHovered(mouseX, mouseY, x, y)) { RenderUtil.drawRoundedOutline(x, y, 15, 8, 8, 2, theme.getBorderColor().getRGB()); } RenderUtil.drawRoundedRect(x + 0.5F + (animation.getValue()), y + 0.5F, 7, 7, 7, theme.getCircleColor().getRGB()); animation.setAnimation(checked && !disabled ? 15 - 8 : 0, 20); + Tooltip.render(mouseX, mouseY, x, y, 15, 8, tooltip); } public static boolean isHovered(int mouseX, int mouseY, float x, float y) { diff --git a/src/main/java/net/silentclient/client/gui/elements/Tooltip.java b/src/main/java/net/silentclient/client/gui/elements/Tooltip.java new file mode 100644 index 0000000..30c15f5 --- /dev/null +++ b/src/main/java/net/silentclient/client/gui/elements/Tooltip.java @@ -0,0 +1,31 @@ +package net.silentclient.client.gui.elements; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ScaledResolution; +import net.silentclient.client.Client; +import net.silentclient.client.gui.font.SilentFontRenderer; +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; + +public class Tooltip { + public static void render(int mouseX, int mouseY, float x, float y, int width, int height, String text) { + if(MouseUtils.isInside(mouseX, mouseY, x, y, width, height) && text != null) { + float tooltipWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(text, 10, SilentFontRenderer.FontType.TITLE) + 4; + float tooltipX = x + ((width / 2) - (tooltipWidth / 2)); + float tooltipY = y + height + 2; + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + if(tooltipX < 2) { + tooltipX = 2; + } + if(tooltipX + tooltipWidth > scaledResolution.getScaledWidth()) { + tooltipX = scaledResolution.getScaledWidth() - tooltipWidth - 2; + } + if(tooltipY + 14 > scaledResolution.getScaledHeight()) { + tooltipY = y - 16; + } + RenderUtils.drawRect(tooltipX, tooltipY, tooltipWidth, 14, Theme.backgroundColor().getRGB()); + Client.getInstance().getSilentFontRenderer().drawString(text, tooltipX + 2, tooltipY + 2, 10, SilentFontRenderer.FontType.TITLE); + } + } +} diff --git a/src/main/java/net/silentclient/client/gui/elements/TooltipIconButton.java b/src/main/java/net/silentclient/client/gui/elements/TooltipIconButton.java index 8648e0a..f294d4d 100644 --- a/src/main/java/net/silentclient/client/gui/elements/TooltipIconButton.java +++ b/src/main/java/net/silentclient/client/gui/elements/TooltipIconButton.java @@ -2,10 +2,6 @@ package net.silentclient.client.gui.elements; import net.minecraft.client.Minecraft; import net.minecraft.util.ResourceLocation; -import net.silentclient.client.Client; -import net.silentclient.client.gui.font.SilentFontRenderer; -import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; -import net.silentclient.client.gui.theme.Theme; public class TooltipIconButton extends IconButton { private final String tooltipText; @@ -18,14 +14,6 @@ public class TooltipIconButton extends IconButton { @Override public void drawButton(Minecraft mc, int mouseX, int mouseY) { super.drawButton(mc, mouseX, mouseY); - if(this.hovered) { - float tooltipWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(this.tooltipText, 10, SilentFontRenderer.FontType.TITLE) + 4; - float tooltipX = this.xPosition + ((this.width / 2) - (tooltipWidth / 2)); - if(tooltipX < 2) { - tooltipX = 2; - } - RenderUtils.drawRect(tooltipX, this.yPosition + this.height + 2, tooltipWidth, 14, Theme.backgroundColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawString(this.tooltipText, tooltipX + 2, this.yPosition + this.height + 2 + 2, 10, SilentFontRenderer.FontType.TITLE); - } + Tooltip.render(mouseX, mouseY, this.xPosition, this.yPosition, this.width, this.height, this.tooltipText); } } diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java index c0f9515..1d59315 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ClickGUI.java @@ -140,7 +140,7 @@ public class ClickGUI extends SilentScreen { RenderUtil.drawImage(new ResourceLocation(m.getIcon()), modOffsetX + ((65 / 2) - 10), y + modOffsetY - scrollAnimation.getValue() + ((70 / 2) - 10), 20, 20, false); } if(selectedCategory.equals(ModCategory.MODS)) { - Switch.render(mouseX, mouseY, switchX, switchY, m.switchAniamation, m.isEnabled(), m.isForceDisabled()); + Switch.render(mouseX, mouseY, switchX, switchY, m.switchAniamation, m.isEnabled(), m.isForceDisabled(), m.isForceDisabled() ? "Force disabled" : null); } if(switchHovered || isHovered) { diff --git a/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java b/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java index 57489d7..0383c54 100644 --- a/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java +++ b/src/main/java/net/silentclient/client/gui/lite/clickgui/ModSettings.java @@ -139,18 +139,7 @@ public class ModSettings extends SilentScreen { ScaledResolution r = new ScaledResolution(mc); int s = r.getScaleFactor(); int translatedY = r.getScaledHeight() - y - height; - GL11.glScissor(x * s, translatedY * s, width * s, height * s); - - if(mod.getCategory() == ModCategory.MODS) { - RenderUtil.drawImage(new ResourceLocation("silentclient/icons/reset_settings.png"), x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10); - if(MouseUtils.isInside(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10)) { - cursorType = MouseCursorHandler.CursorType.POINTER; - } - Switch.render(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue(), mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled()); - if(Switch.isHovered(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue())) { - cursorType = MouseCursorHandler.CursorType.POINTER; - } - } + GL11.glScissor(x * s, translatedY * s, this.width * s, height * s); Client.getInstance().getSilentFontRenderer().drawString(mod.getName(), x + 100, (int) (y + 5) + scrollAnimation.getValue(), 14, SilentFontRenderer.FontType.TITLE); MouseCursorHandler.CursorType cursorTypeCustom = mod.renderCustomLiteComponent(x + 100, (int) (y + 25 + scrollAnimation.getValue()), width, height, mouseX, mouseY); @@ -226,6 +215,17 @@ public class ModSettings extends SilentScreen { settingIndex++; settingY += settingHeight; + } + if(mod.getCategory() == ModCategory.MODS) { + RenderUtil.drawImage(new ResourceLocation("silentclient/icons/reset_settings.png"), x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10); + Tooltip.render(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10, "Reset"); + if(MouseUtils.isInside(mouseX, mouseY, x + width - (10 + 8) - 15, y + 5 + scrollAnimation.getValue(), 10, 10)) { + cursorType = MouseCursorHandler.CursorType.POINTER; + } + Switch.render(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue(), mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null); + if(Switch.isHovered(mouseX, mouseY, x + width - (10 + 8), y + 6 + scrollAnimation.getValue())) { + cursorType = MouseCursorHandler.CursorType.POINTER; + } } GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glPopMatrix(); diff --git a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java index d1c8596..1dafa1f 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/ModMenu.java @@ -160,7 +160,7 @@ public class ModMenu extends SilentScreen { Client.getInstance().getSilentFontRenderer().drawString(mod.getName(), modX, modY + 10 - 6, 12, SilentFontRenderer.FontType.TITLE); if(modCategory == ModCategory.MODS) { - Switch.render(mouseX, mouseY, 129, modY + 10 - 4, mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled()); + Switch.render(mouseX, mouseY, 129, modY + 10 - 4, mod.switchAniamation, mod.isEnabled(), mod.isForceDisabled(), mod.isForceDisabled() ? "Force disabled" : null); if(Switch.isHovered(mouseX, mouseY, 129, modY + 10 - 4)) { cursorType = MouseCursorHandler.CursorType.POINTER; } @@ -183,7 +183,9 @@ public class ModMenu extends SilentScreen { boolean isHovered = mouseInContent(mouseX, mouseY, height) && MouseUtils.isInside(mouseX, mouseY, 3, configY, 144, 20); if(isHovered) { cursorType = MouseCursorHandler.CursorType.POINTER; - RenderUtil.drawRoundedRect(3, configY, 144, 20, 3, new Color(255, 255, 255, 30).getRGB()); + if(!MouseUtils.isInside(mouseX, mouseY, 132, configY + 10 - 6, 12, 12)) { + RenderUtil.drawRoundedRect(3, configY, 144, 20, 3, new Color(255, 255, 255, 30).getRGB()); + } } RenderUtil.drawRoundedOutline(3, configY, 144, 20, 3, 1, Theme.borderColor().getRGB()); diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java b/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java index a6df2cd..80c5c5a 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/components/ServerComponent.java @@ -16,9 +16,8 @@ import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; -import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.elements.Tooltip; import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils; -import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; import net.silentclient.client.gui.multiplayer.SilentMultiplayerGui; import net.silentclient.client.gui.theme.Theme; import net.silentclient.client.gui.util.RenderUtil; @@ -186,12 +185,7 @@ public class ServerComponent { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(Gui.icons); Gui.drawModalRectWithCustomSizedTexture((int) x + 240 - 15, (int) y + 2, (float)(k * 10), (float)(176 + l * 8), 10, 8, 256.0F, 256.0F); - if(MouseUtils.isInside(mouseX, mouseY, x + 240 - 15, y + 2, 10, 8)) { - float toastWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(s1, 10, SilentFontRenderer.FontType.TITLE) + 4; - float toastX = x + 240 - 15 + (10 / 2) - (toastWidth / 2); - RenderUtils.drawRect(toastX, y + 2 + 10 + 1, toastWidth, 14, Theme.backgroundColor().getRGB()); - Client.getInstance().getSilentFontRenderer().drawString(s1, toastX + 2, y + 2 + 10 + 1 + 2, 10, SilentFontRenderer.FontType.TITLE); - } + Tooltip.render(mouseX, mouseY, x + 240 - 15, y + 2, 10, 8, s1); return cursorType; } diff --git a/src/main/java/net/silentclient/client/mods/player/EmoteMod.java b/src/main/java/net/silentclient/client/mods/player/EmoteMod.java new file mode 100644 index 0000000..808a4a4 --- /dev/null +++ b/src/main/java/net/silentclient/client/mods/player/EmoteMod.java @@ -0,0 +1,31 @@ +package net.silentclient.client.mods.player; + +import net.silentclient.client.Client; +import net.silentclient.client.event.EventTarget; +import net.silentclient.client.event.impl.KeyEvent; +import net.silentclient.client.mods.Mod; +import net.silentclient.client.mods.ModCategory; +import org.lwjgl.input.Keyboard; + +public class EmoteMod extends Mod { + public static boolean active = false; + + public EmoteMod() { + super("Emotes", ModCategory.MODS, null); + } + + @Override + public void setup() { + super.setup(); + this.addKeybindSetting("Keybind", this, Keyboard.KEY_B); + } + + @EventTarget + public void onKey(KeyEvent event) { + if(event.getKey() == Client.getInstance().getSettingsManager().getSettingByName(this, "Keybind").getKeybind()) { + active = !active; + if(active) { + } + } + } +} diff --git a/src/main/java/net/silentclient/client/utils/RawInputHandler.java b/src/main/java/net/silentclient/client/utils/RawInputHandler.java index e1bc887..db4e3f8 100644 --- a/src/main/java/net/silentclient/client/utils/RawInputHandler.java +++ b/src/main/java/net/silentclient/client/utils/RawInputHandler.java @@ -4,16 +4,19 @@ import net.java.games.input.Controller; import net.java.games.input.ControllerEnvironment; import net.java.games.input.Mouse; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.util.MouseHelper; +import net.silentclient.client.Client; public class RawInputHandler { - public static Controller[] controllers; + public static Controller[] controllers; public static Mouse mouse; public static int dx = 0; public static int dy = 0; public static void init() { controllers = ControllerEnvironment.getDefaultEnvironment().getControllers(); + startThread(); } public static void getMouse() { @@ -28,36 +31,50 @@ public class RawInputHandler { } public static void toggleRawInput(boolean enable) { - if(enable) { - Minecraft.getMinecraft().mouseHelper = new RawMouseHelper(); - controllers = ControllerEnvironment.getDefaultEnvironment().getControllers(); + EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + float saveYaw = player.rotationYaw; + float savePitch = player.rotationPitch; - Thread inputThread = new Thread(() -> { - while (true) { - RawInputHandler.getMouse(); - if (mouse != null) { - mouse.poll(); - - dx += (int) mouse.getX().getPollData(); - dy += (int) mouse.getY().getPollData(); - } else { - RawInputHandler.rescan(); - } - try { - Thread.sleep(1); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - }); - inputThread.setName("inputThread"); - inputThread.start(); - } else { + if (Minecraft.getMinecraft().mouseHelper instanceof RawMouseHelper && !enable) { + Client.logger.info("[SC]: Disabling Raw Mouse Input"); Minecraft.getMinecraft().mouseHelper = new MouseHelper(); + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + } else { + Client.logger.info("[SC]: Enabling Raw Mouse Input"); + Minecraft.getMinecraft().mouseHelper = new RawMouseHelper(); + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); } + player.rotationYaw = saveYaw; + player.rotationPitch = savePitch; } public static void rescan() { RawInputHandler.getMouse(); } -} + + public static void startThread() { + Thread inputThread = new Thread(() -> { + while(true){ + if (mouse != null && Minecraft.getMinecraft().currentScreen == null) { + mouse.poll(); + dx += (int)mouse.getX().getPollData(); + dy += (int)mouse.getY().getPollData(); + } else if (mouse != null) { + mouse.poll(); + } else { + getMouse(); + } + + try { + Thread.sleep(1); + } catch(InterruptedException e) { + e.printStackTrace(); + } + } + }); + inputThread.setName("inputThread"); + inputThread.start(); + } +} \ No newline at end of file