diff options
| author | Arslaan Pathan <[email protected]> | 2026-09-26 17:05:36 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-09-26 17:05:36 +1200 |
| commit | 14c68eb5ba16774f581d95a39e64a7b303954ffc (patch) | |
| tree | 2888ef11f47c6a639d440300ef580c247ad1bcb1 /src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java | |
| parent | 766ba1c1d977442332cadaaeca93d795baa559df (diff) | |
| download | arslaansmagichax-14c68eb5ba16774f581d95a39e64a7b303954ffc.tar.xz arslaansmagichax-14c68eb5ba16774f581d95a39e64a7b303954ffc.zip | |
migration to 26.2 - run migrateMappings with old loom then bring it back to new
Diffstat (limited to 'src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java')
| -rw-r--r-- | src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java new file mode 100644 index 0000000..7c67201 --- /dev/null +++ b/src/main/java/com/arslaancodes/arslaansmagichax/modules/impl/AutoClicker.java @@ -0,0 +1,47 @@ +package com.arslaancodes.arslaansmagichax.modules.impl; + +import com.arslaancodes.arslaansmagichax.modules.Category; +import com.arslaancodes.arslaansmagichax.modules.Module; +import com.arslaancodes.arslaansmagichax.modules.settings.ModeSetting; +import com.arslaancodes.arslaansmagichax.modules.settings.NumberSetting; +import java.util.Objects; +import java.util.Random; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.HitResult; + +public class AutoClicker extends Module { + private final NumberSetting cps = new NumberSetting("CPS", 5, 50, 12, 0.1); // default 10 CPS + private final ModeSetting mode = new ModeSetting("Mode", "NoDelay", "CPS", "NoDelay"); + private long nextClickTime = 0L; + + public AutoClicker() { + super("AutoClicker", "Automatically attacks entities under your crosshair.", -1, Category.COMBAT); + addSetting(mode); + addSetting(cps); + } + + @Override + public void tick() { + if (!isEnabled() || mc.player == null || mc.level == null) return; + if (mc.screen != null) return; + + HitResult hr = mc.hitResult; + if (!(hr instanceof EntityHitResult eResult)) return; + + Entity target = eResult.getEntity(); + if (target == null || !target.isAlive()) return; + + if (!Objects.equals(mode.getMode(), "NoDelay")) { + long now = System.currentTimeMillis(); + if (now < nextClickTime) return; + + double delayMs = 1000.0 / cps.getValue(); + nextClickTime = now + (long) Math.max(1, delayMs); + } + + mc.gameMode.attack(mc.player, target); + mc.player.swing(InteractionHand.MAIN_HAND); + } +} |
