From 3dcd40f9306690754a1e98dc874b9ad87678929b Mon Sep 17 00:00:00 2001 From: cyde <47931007+ytcyde@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:10:28 +0100 Subject: [PATCH] stuff --- .../module/modules/combat/AimAssist.java | 2 +- .../argon/module/modules/combat/AutoWTap.java | 153 ++++++++++++-- .../module/modules/render/TargetHud.java | 196 ++++++++++++------ .../dev/lvstrng/argon/utils/RenderUtils.java | 70 ++++++- 4 files changed, 332 insertions(+), 89 deletions(-) diff --git a/src/main/java/dev/lvstrng/argon/module/modules/combat/AimAssist.java b/src/main/java/dev/lvstrng/argon/module/modules/combat/AimAssist.java index e403af86..535cd8dc 100644 --- a/src/main/java/dev/lvstrng/argon/module/modules/combat/AimAssist.java +++ b/src/main/java/dev/lvstrng/argon/module/modules/combat/AimAssist.java @@ -224,4 +224,4 @@ public void onMouseMove(MouseMoveEvent event) { move = false; timer.reset(); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/lvstrng/argon/module/modules/combat/AutoWTap.java b/src/main/java/dev/lvstrng/argon/module/modules/combat/AutoWTap.java index f54e24d6..2686d954 100644 --- a/src/main/java/dev/lvstrng/argon/module/modules/combat/AutoWTap.java +++ b/src/main/java/dev/lvstrng/argon/module/modules/combat/AutoWTap.java @@ -12,25 +12,37 @@ import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; import org.lwjgl.glfw.GLFW; public final class AutoWTap extends Module implements PacketSendListener, HudListener { - private final MinMaxSetting delay = new MinMaxSetting(EncryptedString.of("Delay"), 0, 1000, 1,230, 270); + private final MinMaxSetting delay = new MinMaxSetting(EncryptedString.of("Delay"), 0, 1000, 1, 230, 270); private final BooleanSetting inAir = new BooleanSetting(EncryptedString.of("In Air"), false) .setDescription(EncryptedString.of("Whether it should W tap in air")); + private final BooleanSetting targetSelection = new BooleanSetting(EncryptedString.of("Target Selection"), false) + .setDescription(EncryptedString.of("Optimizes tapping based on target distance")); private final TimerUtils sprintTimer = new TimerUtils(); private final TimerUtils tapTimer = new TimerUtils(); private boolean holdingForward; private boolean sprinting; private int currentDelay; private boolean jumpedWhileHitting; + private Entity targetEntity; + private boolean shouldSTap; + private boolean isSTapping; + private boolean wasHoldingForward; + private boolean completedSTap = false; + private boolean wasMovingForward; + private boolean wasInAir = false; + private boolean wtapCancelled = false; public AutoWTap() { super(EncryptedString.of("Auto WTap"), EncryptedString.of("Automatically W Taps for you so the opponent takes more knockback"), -1, Category.COMBAT); - addSettings(delay, inAir); + addSettings(delay, inAir, targetSelection); } @Override @@ -39,6 +51,7 @@ public void onEnable() { eventManager.add(HudListener.class, this); currentDelay = delay.getRandomValueInt(); jumpedWhileHitting = false; + wtapCancelled = false; super.onEnable(); } @@ -46,33 +59,114 @@ public void onEnable() { public void onDisable() { eventManager.remove(PacketSendListener.class, this); eventManager.remove(HudListener.class, this); + if (isSTapping) { + mc.options.backKey.setPressed(false); + isSTapping = false; + } + if (wasHoldingForward) { + mc.options.forwardKey.setPressed(true); + wasHoldingForward = false; + } + wasMovingForward = false; + completedSTap = false; + wasInAir = false; + wtapCancelled = false; super.onDisable(); } @Override public void onRenderHud(HudEvent event) { + // Handle normal W-tap if target selection is disabled + if (!targetSelection.getValue()) { + handleNormalWTap(); + return; + } + + // Check if forward key is not pressed - immediately stop all movement + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_W) != 1) { + resetMovementState(); + wasMovingForward = false; + completedSTap = false; + targetEntity = null; + return; + } + + // Target Selection logic + if ((isSTapping && GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_SPACE) == 1) || + (wasInAir && mc.player.isOnGround())) { + resetMovementState(); + completedSTap = true; + wasInAir = false; + return; + } + + if (!mc.player.isOnGround()) { + wasInAir = true; + } + + if (jumpedWhileHitting) { + if (!mc.player.isOnGround()) { + resetMovementState(); + return; + } else { + jumpedWhileHitting = false; + } + } + + if (targetEntity == null || !wasMovingForward || (!inAir.getValue() && !mc.player.isOnGround())) { + resetMovementState(); + return; + } + + double distance = mc.player.squaredDistanceTo(targetEntity); + + if (!completedSTap && distance >= 2.25 && distance <= 7.29) { + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_W) == 1) { + wasHoldingForward = true; + mc.options.forwardKey.setPressed(false); + } + mc.options.backKey.setPressed(true); + isSTapping = true; + } + else if (distance > 7.29) { + if (isSTapping) { + resetMovementState(); + completedSTap = true; + } + if (distance > 9.0) { + targetEntity = null; + completedSTap = false; + } + } + } + + private void handleNormalWTap() { if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_W) != 1) { sprinting = false; holdingForward = false; + wtapCancelled = false; return; } - if (!inAir.getValue() && !mc.player.isOnGround()) + if (!inAir.getValue() && !mc.player.isOnGround()) { return; - - if (mc.player.isOnGround()) { - jumpedWhileHitting = false; } - if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_SPACE) == 1 && !inAir.getValue()) { + // Cancel W-tap if space is pressed + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_SPACE) == 1) { if (holdingForward || sprinting) { mc.options.forwardKey.setPressed(true); holdingForward = false; sprinting = false; + wtapCancelled = true; return; } } + if (wtapCancelled) { + return; + } + if (holdingForward && tapTimer.delay(1)) { mc.options.forwardKey.setPressed(false); sprintTimer.reset(); @@ -87,6 +181,17 @@ public void onRenderHud(HudEvent event) { } } + private void resetMovementState() { + if (isSTapping) { + mc.options.backKey.setPressed(false); + isSTapping = false; + } + if (wasHoldingForward) { + mc.options.forwardKey.setPressed(true); + wasHoldingForward = false; + } + } + @Override public void onPacketSend(PacketSendEvent event) { if (!(event.packet instanceof PlayerInteractEntityC2SPacket packet)) @@ -94,25 +199,37 @@ public void onPacketSend(PacketSendEvent event) { packet.handle(new PlayerInteractEntityC2SPacket.Handler() { @Override - public void interact(Hand hand) { - } + public void interact(Hand hand) {} @Override - public void interactAt(Hand hand, Vec3d pos) { - } + public void interactAt(Hand hand, Vec3d pos) {} @Override public void attack() { - if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_SPACE) == 1 && !inAir.getValue()) { - jumpedWhileHitting = true; - } - if (!inAir.getValue() && !mc.player.isOnGround()) return; - if (!jumpedWhileHitting && mc.options.forwardKey.isPressed() && mc.player.isSprinting()) { - sprintTimer.reset(); - holdingForward = true; + if (targetSelection.getValue()) { + wasMovingForward = GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_W) == 1 && mc.player.isSprinting(); + if (wasMovingForward) { + targetEntity = mc.targetedEntity; + completedSTap = false; + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_W) == 1) { + wasHoldingForward = true; + mc.options.forwardKey.setPressed(false); + } + } + } else { + if (GLFW.glfwGetKey(mc.getWindow().getHandle(), GLFW.GLFW_KEY_SPACE) == 1) { + wtapCancelled = true; + return; + } + + if (mc.options.forwardKey.isPressed() && mc.player.isSprinting()) { + sprintTimer.reset(); + holdingForward = true; + wtapCancelled = false; + } } } }); diff --git a/src/main/java/dev/lvstrng/argon/module/modules/render/TargetHud.java b/src/main/java/dev/lvstrng/argon/module/modules/render/TargetHud.java index 768875bb..35d96fe9 100644 --- a/src/main/java/dev/lvstrng/argon/module/modules/render/TargetHud.java +++ b/src/main/java/dev/lvstrng/argon/module/modules/render/TargetHud.java @@ -20,13 +20,21 @@ import java.awt.*; public final class TargetHud extends Module implements HudListener, PacketSendListener { - private final NumberSetting xCoord = new NumberSetting(EncryptedString.of("X"), 0, 1920, 500, 1); - private final NumberSetting yCoord = new NumberSetting(EncryptedString.of("Y"), 0, 1080, 500, 1); + private final NumberSetting xCoord = new NumberSetting(EncryptedString.of("X"), 0, 1920, 700, 1); + private final NumberSetting yCoord = new NumberSetting(EncryptedString.of("Y"), 0, 1080, 600, 1); private final BooleanSetting hudTimeout = new BooleanSetting(EncryptedString.of("Timeout"), true) .setDescription(EncryptedString.of("Target hud will disappear after 10 seconds")); private long lastAttackTime = 0; public static float animation; private static final long timeout = 10000; + private float healthAnimation = 0f; + private float damageAnimation = 0f; + private long lastDamageTime = 0; + private float opacity = 0f; + private PlayerEntity lastTarget = null; + private float initialAnimation = 0f; + private boolean isFirstRender = true; + private float scaleAnimation = 0f; public TargetHud() { super(EncryptedString.of("Target HUD"), @@ -38,6 +46,15 @@ public TargetHud() { @Override public void onEnable() { + // Reset animations when enabled + opacity = 0f; + animation = 0f; + healthAnimation = 0f; + damageAnimation = 0f; + initialAnimation = 0f; + isFirstRender = true; + lastTarget = null; + scaleAnimation = 0f; eventManager.add(HudListener.class, this); eventManager.add(PacketSendListener.class, this); super.onEnable(); @@ -53,88 +70,129 @@ public void onDisable() { @Override public void onRenderHud(HudEvent event) { DrawContext context = event.context; - int x = xCoord.getValueInt(); int y = yCoord.getValueInt(); RenderUtils.unscaledProjection(); if ((!hudTimeout.getValue() || (System.currentTimeMillis() - lastAttackTime <= timeout)) && mc.player.getAttacking() != null && mc.player.getAttacking() instanceof PlayerEntity player && player.isAlive()) { - animation = RenderUtils.fast(animation, mc.player.getAttacking() instanceof PlayerEntity player1 && player1.isAlive() ? 0 : 1, 15f); - - PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(player.getUuid()); - float tx = (float) x; - float ty = (float) y; - MatrixStack matrixStack = context.getMatrices(); - float thetaRotation = 90 * animation; - matrixStack.push(); - matrixStack.translate(tx, ty, 0); - - matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(thetaRotation)); - matrixStack.translate(-tx, -ty, 0); - - RenderUtils.renderRoundedQuad(context.getMatrices(), new Color(0, 0, 0, 175), x, y, x + 340, y + 200, 5, 5, 5, 5, 10); - RenderUtils.renderRoundedQuad(context.getMatrices(), Utils.getMainColor(255, 1), x, y + 27, x + 340, y + 29, 0, 0, 0, 0, 10); - - TextRenderer.drawString(player.getName().getString() + " - " + MathUtils.roundToDecimal(player.distanceTo(mc.player), 0.5) + " blocks", context, x + 23, y + 5, Color.WHITE.getRGB()); - - if (entry == null) { - int charOff1 = x + 5; - CharSequence chars = "Type: Bot"; - - TextRenderer.drawString(chars, context, charOff1, y + 35, new Color(255, 80, 80, 255).getRGB()); - - matrixStack.pop(); - RenderUtils.scaledProjection(); - return; - } else { - int charOff1 = x + 5; - CharSequence chars = "Type: Player"; - - TextRenderer.drawString(chars, context, charOff1, y + 35, Color.white.getRGB()); + + // Initialize values on first render + if (isFirstRender) { + healthAnimation = player.getHealth() / player.getMaxHealth(); + opacity = 0f; + animation = 0f; + scaleAnimation = 0f; + isFirstRender = false; + } + + // Single fast scale animation + scaleAnimation = RenderUtils.fast(scaleAnimation, 1f, 40f); + + PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(player.getUuid()); + MatrixStack matrixStack = context.getMatrices(); + matrixStack.push(); + + // Center point for scaling + float centerX = x + 120; + float centerY = y + 42; + + // Apply scale transformation from center + matrixStack.translate(centerX, centerY, 0); + matrixStack.scale(scaleAnimation, scaleAnimation, 1f); + matrixStack.translate(-centerX, -centerY, 0); + + // Calculate dynamic width based on name length and ensure space for ping + String playerName = player.getName().getString(); + String pingText = entry != null ? entry.getLatency() + "ms" : "0ms"; + int pingWidth = mc.textRenderer.getWidth(pingText) + 32; // Increased padding to 32 + int nameWidth = Math.max(240, Math.min(300, mc.textRenderer.getWidth(playerName) + 150 + pingWidth)); + + // Colors with opacity matching scale + Color bgColor = new Color(20, 20, 25, 230); + Color accentColor = new Color(255, 255, 255, 25); + Color borderColor = new Color(255, 255, 255, 30); + Color textColor = new Color(255, 255, 255, (int)(255 * opacity * scaleAnimation)); + + // Enhanced background blur and shadow + RenderUtils.renderBlurredBackground(context.getMatrices(), x, y, nameWidth, 85, new Color(20, 20, 25, 100)); + RenderUtils.renderDropShadow(context.getMatrices(), x, y, nameWidth, 85, 6f, new Color(0, 0, 0, 160)); + + // Background with dynamic width + RenderUtils.renderRoundedQuad(context.getMatrices(), new Color(20, 20, 25, 200), x, y, x + nameWidth, y + 85, 8, 8, 8, 8, 15); + RenderUtils.renderRoundedQuad(context.getMatrices(), accentColor, x, y, x + nameWidth, y + 42, 8, 8, 0, 0, 15); + + // Player head with border + if (entry != null) { + RenderUtils.renderRoundedQuad(context.getMatrices(), borderColor, x + 8, y + 8, x + 34, y + 34, 5, 5, 5, 5, 10); + PlayerSkinDrawer.draw(context, entry.getSkinTextures().texture(), x + 9, y + 9, 24); } - TextRenderer.drawString("Health: " + Math.round((player.getHealth() + player.getAbsorptionAmount())), context, x + 5, y + 65, Color.GREEN.getRGB()); - context.fill(x, y + 200, x + 4, (y + 200) - Math.min(Math.round((player.getHealth() + player.getAbsorptionAmount()) * 5), 171), Color.GREEN.darker().getRGB()); - //RenderUtils.renderRoundedOutline(context, Color.green, x, y + 200, x, (y + 200) - Math.min(Math.round((player.getHealth() + player.getAbsorptionAmount()) * 5), 174), 0, 0, 0, 0, 3, 30); - - TextRenderer.drawString("Invisible: " + (player.isInvisible() ? "Yes" : "No"), context, x + 5, y + 95, Color.WHITE.getRGB()); - - TextRenderer.drawString("Ping: " + entry.getLatency(), context, x + 5, y + 125, Color.WHITE.getRGB()); - - PlayerSkinDrawer.draw(context, entry.getSkinTextures().texture(), x + 3, y + 3, 20); - - if (player.hurtTime != 0) { - int charOff1 = x + 125; - CharSequence chars = ("Damage Tick: " + player.hurtTime); - - TextRenderer.drawString(chars, context, charOff1, y + 65, Color.WHITE.getRGB()); - //TextRenderer.drawString("Damage Tick: " + player.hurtTime, context, x + 125, y + 65, Color.WHITE.getRGB()); - context.fill(x + 125, y + 80, (x + 125) + (player.hurtTime * 15), y + 83, getDamageTickColor(player.hurtTime).getRGB()); + // Player name with shadow + TextRenderer.drawString(playerName, context, x + 42, y + 12, textColor.getRGB()); + + // Ping indicator (moved further left) + int ping = entry != null ? entry.getLatency() : 0; + Color pingColor = getPingColor(ping); + TextRenderer.drawString(pingText, context, x + nameWidth - mc.textRenderer.getWidth(pingText) - 32, y + 12, pingColor.getRGB()); + + // Health bar container with dynamic width + RenderUtils.renderRoundedQuad(context.getMatrices(), new Color(0, 0, 0, 100), x + 42, y + 28, x + nameWidth - 8, y + 36, 3, 3, 3, 3, 10); + + // Animated health bar + float targetHealth = (player.getHealth() + player.getAbsorptionAmount()) / player.getMaxHealth(); + healthAnimation = RenderUtils.fast(healthAnimation, targetHealth, 10f); + int healthWidth = (int)((nameWidth - 50) * healthAnimation); + + Color healthColor = getHealthColor(healthAnimation); + RenderUtils.renderRoundedQuad(context.getMatrices(), healthColor, x + 42, y + 28, x + 42 + healthWidth, y + 36, 3, 3, 3, 3, 10); + + // Health and distance info (adjusted Y position) + String healthText = String.format("%.1f❤", player.getHealth() + player.getAbsorptionAmount()); + TextRenderer.drawString(healthText, context, x + 42, y + 50, healthColor.getRGB()); + String distanceText = String.format("%.1fm", player.distanceTo(mc.player)); + TextRenderer.drawString(distanceText, context, x + 100, y + 50, Color.WHITE.getRGB()); + + // Damage indicator effect with dynamic width + if (player.hurtTime > 0) { + damageAnimation = 1f; + lastDamageTime = System.currentTimeMillis(); + } else if (System.currentTimeMillis() - lastDamageTime > 500) { + damageAnimation = RenderUtils.fast(damageAnimation, 0f, 5f); + } + + if (damageAnimation > 0) { + RenderUtils.renderRoundedQuad(context.getMatrices(), + new Color(255, 0, 0, (int)(60 * damageAnimation)), + x, y, x + nameWidth, y + 85, 8, 8, 8, 8, 15); } + matrixStack.pop(); } else { - animation = RenderUtils.fast(animation, 1, 15f); + scaleAnimation = RenderUtils.fast(scaleAnimation, 0f, 40f); + if (scaleAnimation <= 0.01f) { + lastTarget = null; + isFirstRender = true; + } } RenderUtils.scaledProjection(); } - private Color getDamageTickColor(int hurtTime) { - return switch (hurtTime) { - case 0 -> null; - case 10 -> new Color(255, 0, 0, 255); - case 9 -> new Color(255, 50, 0, 255); - case 8 -> new Color(255, 100, 0, 255); - case 7 -> new Color(255, 150, 0, 255); - case 6 -> new Color(255, 255, 0, 255); - case 5 -> new Color(200, 255, 0, 255); - case 4 -> new Color(175, 255, 0, 255); - case 3 -> new Color(100, 255, 0, 255); - case 2 -> new Color(50, 255, 0, 255); - case 1 -> new Color(0, 255, 0, 255); - default -> throw new IllegalStateException("uv" + hurtTime); - }; - } + private Color getHealthColor(float health) { + return new Color( + (int)(255 * (1 - health)), + (int)(255 * (0.8f + health * 0.2f)), + (int)(255 * (health * 0.3f)), + 255 + ); + } + + private Color getPingColor(int ping) { + if (ping < 50) return new Color(0, 255, 0); + if (ping < 100) return new Color(255, 255, 0); + if (ping < 150) return new Color(255, 150, 0); + return new Color(255, 0, 0); + } @Override public void onPacketSend(PacketSendListener.PacketSendEvent event) { diff --git a/src/main/java/dev/lvstrng/argon/utils/RenderUtils.java b/src/main/java/dev/lvstrng/argon/utils/RenderUtils.java index c84d7a27..ffaf19a7 100644 --- a/src/main/java/dev/lvstrng/argon/utils/RenderUtils.java +++ b/src/main/java/dev/lvstrng/argon/utils/RenderUtils.java @@ -121,7 +121,7 @@ public static void renderRoundedOutlineInternal(Matrix4f matrix, float cr, float double rad = current[2]; float cos = (float) (rad); bufferBuilder.vertex(matrix, (float) current[0], (float) current[1] + cos, 0.0F).color(cr, cg, cb, ca); - bufferBuilder.vertex(matrix, (float) (current[0]), (float) (current[1] + cos + width), 0.0F).color(cr, cg, cb, ca); + bufferBuilder.vertex(matrix, (float) (current[0] + cos), (float) (current[1] + cos + width), 0.0F).color(cr, cg, cb, ca); BufferRenderer.drawWithGlobalProgram(bufferBuilder.end()); } @@ -365,4 +365,72 @@ private static void useBuffer(VertexFormat.DrawMode mode, VertexFormat format, S BufferRenderer.drawWithGlobalProgram(bb.end()); cleanup(); } + + public static void renderBlurredBox(MatrixStack matrices, float x, float y, float width, float height, float blurRadius, Color color) { + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + + // Render blur + for (int i = 0; i < 3; i++) { + float spread = (blurRadius * 0.5f) * (i + 1); + Color blurColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() / (i + 2)); + renderRoundedQuad(matrices, blurColor, x - spread, y - spread, x + width + spread, y + height + spread, 8, 8, 8, 8, 15); + } + + RenderSystem.disableBlend(); + } + + public static void renderDropShadow(MatrixStack matrices, float x, float y, float width, float height, float shadowRadius, Color shadowColor) { + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + + // Enhanced Gaussian-like drop shadow with more visible layers + float[] alphaSteps = {0.32f, 0.24f, 0.16f, 0.08f, 0.04f}; + float[] spreadSteps = {0.6f, 1.2f, 1.8f, 2.4f, 3f}; + + for (int i = 0; i < 5; i++) { + float spread = shadowRadius * spreadSteps[i]; + Color currentColor = new Color(0, 0, 0, (int)(160 * alphaSteps[i])); + renderRoundedQuad(matrices, currentColor, + x + spread * 0.25f, + y + spread * 0.75f, // More vertical offset for depth + x + width + spread * 0.25f, + y + height + spread * 0.75f, + 8, 8, 8, 8, 15); + } + + RenderSystem.disableBlend(); + } + + public static void renderBlurredBackground(MatrixStack matrices, float x, float y, float width, float height, Color color) { + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + + // Multi-layer blur effect + float[] alphaSteps = {0.6f, 0.4f, 0.2f, 0.1f}; + float[] spreadSteps = {1f, 2f, 3f, 4f}; + + // Base dark background + Color bgColor = new Color(0, 0, 0, 180); + renderRoundedQuad(matrices, bgColor, x, y, x + width, y + height, 8, 8, 8, 8, 15); + + // Blur layers + for (int i = 0; i < 4; i++) { + float spread = spreadSteps[i]; + Color blurColor = new Color( + color.getRed(), + color.getGreen(), + color.getBlue(), + (int)(80 * alphaSteps[i]) + ); + renderRoundedQuad(matrices, blurColor, + x - spread, + y - spread, + x + width + spread, + y + height + spread, + 8, 8, 8, 8, 15); + } + + RenderSystem.disableBlend(); + } } \ No newline at end of file