Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
fix clicker CPS
Browse files Browse the repository at this point in the history
  • Loading branch information
CubeWhy committed Aug 1, 2023
1 parent 0d9bb77 commit 49f570e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
24 changes: 18 additions & 6 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/main/java/org/cubewhy/lunarcn/utils/ClickUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.cubewhy.lunarcn.utils;

public class ClickUtils {
public static long getRandomClickCPS(int min, int max) {
return (long) (Math.random() * (1000 / min - 1000 / max + 1) + 1000 / max);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.cubewhy.lunarcn.event.events.TickEvent
import org.cubewhy.lunarcn.module.Module
import org.cubewhy.lunarcn.module.ModuleCategory
import org.cubewhy.lunarcn.module.ModuleInfo
import org.cubewhy.lunarcn.utils.ClickUtils
import org.cubewhy.lunarcn.utils.MSTimer
import org.cubewhy.lunarcn.value.BooleanValue
import org.cubewhy.lunarcn.value.IntValue
Expand Down Expand Up @@ -35,7 +36,7 @@ class AutoClicker : Module() {
if (minCPS.value > maxCPS.value) {
maxCPS.value = minCPS.value // min can't > max
}
if (targetClick.value && mc.pointedEntity != null || Mouse.isButtonDown(0)) {
if ((targetClick.value && mc.pointedEntity != null) || Mouse.isButtonDown(0)) {
handleClickLeft() // click the mouse
}
}
Expand All @@ -44,12 +45,7 @@ class AutoClicker : Module() {
* Click the mouse with the cps
* */
private fun handleClickLeft() {
val cps = Random.nextInt(minCPS.value, maxCPS.value)
delay = if (getLeftCPS() >= cps) {
100
} else {
30
}
delay = ClickUtils.getRandomClickCPS(minCPS.value, maxCPS.value)

if (timer.hasTimePassed(delay)) {
mc.clickMouse() // click mouse
Expand Down

0 comments on commit 49f570e

Please sign in to comment.