This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CubeWhy
committed
Aug 1, 2023
1 parent
370fbeb
commit 1104bb8
Showing
7 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/org/cubewhy/lunarcn/event/events/MouseEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.cubewhy.lunarcn.event.events; | ||
|
||
import org.cubewhy.lunarcn.event.Event; | ||
|
||
public class MouseEvent extends Event { | ||
|
||
public final MouseButton button; | ||
|
||
public MouseEvent(MouseButton button) { | ||
this.button = button; | ||
|
||
} | ||
public enum MouseButton { | ||
LEFT, | ||
MIDDLE, | ||
RIGHT | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/kotlin/org/cubewhy/lunarcn/module/impl/cheats/AutoClicker.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.cubewhy.lunarcn.module.impl.cheats | ||
|
||
import org.cubewhy.lunarcn.event.EventTarget | ||
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.MSTimer | ||
import org.cubewhy.lunarcn.value.BooleanValue | ||
import org.cubewhy.lunarcn.value.IntValue | ||
import org.lwjgl.input.Mouse | ||
import kotlin.random.Random | ||
|
||
@ModuleInfo(name = "AutoClicker", description = "Click agent", category = ModuleCategory.CHEATS) | ||
class AutoClicker : Module() { | ||
private val maxCPS = IntValue("MaxCPS", 6, 0, 40) | ||
private val minCPS = IntValue("MinCPS", 2, 0, 40) | ||
|
||
private val targetClick = BooleanValue("TargetClick", false) | ||
|
||
private val leftLastPressed: Long = -1 | ||
private val rightLastPressed: Long = -1 | ||
private var delay: Long = -1; | ||
|
||
private val leftHasPressed = false | ||
private val rightHasPressed = false | ||
|
||
private val clicksLeft = ArrayList<Long>() | ||
private val clicksRight = ArrayList<Long>() | ||
|
||
private val timer = MSTimer() | ||
|
||
@EventTarget | ||
fun onTick(event: TickEvent) { | ||
if (minCPS.value > maxCPS.value) { | ||
maxCPS.value = minCPS.value // min can't > max | ||
} | ||
if (targetClick.value && mc.pointedEntity != null || Mouse.isButtonDown(0)) { | ||
handleClickLeft() // click the mouse | ||
} | ||
} | ||
|
||
/** | ||
* Click the mouse with the cps | ||
* */ | ||
private fun handleClickLeft() { | ||
val cps = Random.nextInt(minCPS.value, maxCPS.value) | ||
delay = if (getLeftCPS() >= cps) { | ||
100 | ||
} else { | ||
30 | ||
} | ||
|
||
if (timer.hasTimePassed(delay)) { | ||
mc.clickMouse() // click mouse | ||
timer.reset() // reset the timer | ||
} | ||
} | ||
|
||
private fun getLeftCPS(): Int { | ||
val time = System.currentTimeMillis() | ||
this.clicksLeft.removeIf { clickTime: Long -> clickTime + 1000 < time } | ||
return this.clicksLeft.size | ||
} | ||
|
||
private fun getRightCPS(): Int { | ||
val time = System.currentTimeMillis() | ||
this.clicksRight.removeIf { clickTime: Long -> clickTime + 1000 < time } | ||
return this.clicksRight.size | ||
} | ||
} |