generated from nea89o/Forge1.8.9Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed Toggleable to Killable for clarity
- Loading branch information
1 parent
75b646a
commit fb81d0a
Showing
9 changed files
with
114 additions
and
88 deletions.
There are no files selected for viewing
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
34 changes: 22 additions & 12 deletions
34
src/main/java/com/github/freedownloadhere/pitplayer/combat/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 |
---|---|---|
@@ -1,29 +1,39 @@ | ||
package com.github.freedownloadhere.pitplayer.combat | ||
|
||
import com.github.freedownloadhere.pitplayer.extensions.settings | ||
import com.github.freedownloadhere.pitplayer.interfaces.Toggleable | ||
import com.github.freedownloadhere.pitplayer.interfaces.Killable | ||
import com.github.freedownloadhere.pitplayer.utils.KeyBindHelper | ||
import kotlinx.coroutines.delay | ||
|
||
object AutoClicker : Toggleable("AutoClicker") { | ||
private var cps = 10L | ||
set(v) { | ||
field = v | ||
timeBeforeNextClick = 1000L / v | ||
} | ||
import com.github.freedownloadhere.pitplayer.utils.RandomHelper | ||
|
||
object AutoClicker : Killable("Auto Clicker") { | ||
// 10 cps default | ||
private var timeBeforeNextClick = 100L | ||
private var lastClickTime = 0L | ||
private var maxErrorTime = 10L | ||
private var shouldUpdate = false | ||
|
||
fun update(deltaTime : Long) { | ||
if(cps < 1) disable() | ||
if(!toggled) return | ||
if(killed) return | ||
if(!shouldUpdate) return | ||
|
||
lastClickTime += deltaTime | ||
val errorTime = RandomHelper.fromRange(-maxErrorTime .. maxErrorTime) | ||
lastClickTime += deltaTime + errorTime | ||
|
||
if(lastClickTime >= timeBeforeNextClick) { | ||
KeyBindHelper.press(settings.keyBindAttack) | ||
lastClickTime = 0L | ||
} | ||
} | ||
|
||
fun cps(cps : Long) { | ||
timeBeforeNextClick = 1000L / cps | ||
} | ||
|
||
fun start() { | ||
shouldUpdate = true | ||
} | ||
|
||
fun stop() { | ||
shouldUpdate = false | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/freedownloadhere/pitplayer/interfaces/Killable.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,24 @@ | ||
package com.github.freedownloadhere.pitplayer.interfaces | ||
|
||
import com.github.freedownloadhere.pitplayer.debug.Debug | ||
|
||
/* | ||
This should only be used for debugging purposes. | ||
It's meant to entirely halt any class that misbehaves during testing. | ||
*/ | ||
open class Killable(private val moduleName : String, kill : Boolean = false) { | ||
var killed : Boolean = kill | ||
private set | ||
fun killToggle() { | ||
if(killed) unkill() | ||
else kill() | ||
} | ||
fun kill() { | ||
killed = true | ||
Debug.Logger.regular("Killed \u00A7a$moduleName") | ||
} | ||
fun unkill() { | ||
killed = false | ||
Debug.Logger.regular("Un-killed \u00A7c$moduleName") | ||
} | ||
} |
20 changes: 0 additions & 20 deletions
20
src/main/java/com/github/freedownloadhere/pitplayer/interfaces/Toggleable.kt
This file was deleted.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
src/main/java/com/github/freedownloadhere/pitplayer/utils/Keybinds.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 |
---|---|---|
@@ -1,9 +1,8 @@ | ||
package com.github.freedownloadhere.pitplayer.utils | ||
|
||
import com.github.freedownloadhere.pitplayer.utils.KeyBindHelper | ||
import net.minecraft.client.settings.KeyBinding | ||
import org.lwjgl.input.Keyboard | ||
|
||
enum class Keybinds(val key: KeyBinding, val action: () -> Unit) { | ||
ToggleRemote(KeyBinding("key.pitplayer.toggleremote", Keyboard.KEY_J, "key.category.pitplayer"), { KeyBindHelper.toggle() }); | ||
ToggleRemote(KeyBinding("key.pitplayer.toggleremote", Keyboard.KEY_J, "key.category.pitplayer"), { KeyBindHelper.killToggle() }); | ||
} |
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