-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Auto Rod #5419
base: nextgen
Are you sure you want to change the base?
feat: Auto Rod #5419
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this. Use Chronometer.
return -1 | ||
} | ||
|
||
private fun getAllNearbyEnemies(): List<Entity?>? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TargetTracker
/** | ||
* Find rod in inventory | ||
*/ | ||
private fun findRod(startSlot: Int, endSlot: Int): Int { | ||
for (i in startSlot until endSlot) { | ||
val stack = mc.player?.inventory?.getStack(i) | ||
if (stack != null && stack.item == Items.FISHING_ROD) { | ||
return i | ||
} | ||
} | ||
return -1 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slots.Hotbar.findSlotIndex(Items.FISHING_ROD)
|
||
init { | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is clearly a lot that has to be changed on this code, as it does not pass our code standards. However, I will take it in my own hand and look if I can work with your code instead of writing it from scratch.
|
||
object ModuleAutoRod : ClientModule("AutoRod", Category.COMBAT) { | ||
|
||
object facingEnemy : ToggleableConfigurable(this, "FacingEnemy", true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"FacingEnemy" - Follow Kotlin Naming Convention
|
||
object facingEnemy : ToggleableConfigurable(this, "FacingEnemy", true) { | ||
|
||
object ignoreOnEnemyLowHealth : ToggleableConfigurable(this, "IgnoreOnEnemyLowHealth", true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IgnoreOnEnemyLowHealth
same here with Naming Convention.
private val pushTimer = Chronometer() | ||
private val rodPullTimer = Chronometer() | ||
private var rodInUse = false | ||
private var switchBack: Int? = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type of Int? is not required to be defined in this case.
private val pushDelay by int("PushDelay", 100, 50..1000) | ||
private val pullbackDelay by int("PullbackDelay", 500, 50..1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No suffix parameter.
val tickHandler = tickHandler { | ||
// Check if player is using rod | ||
val usingRod = | ||
(mc.player?.isUsingItem == true && mc.player?.mainHandStack?.item == Items.FISHING_ROD) || rodInUse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mc.player.isUsingItem
can be replaced with player.isUsingItem
(mc.player?.isUsingItem == true && mc.player?.mainHandStack?.item == Items.FISHING_ROD) || rodInUse | |
(player.isUsingItem && player.mainHandStack.item == Items.FISHING_ROD) || rodInUse |
|
||
} else { | ||
// Stop using rod | ||
mc.player?.stopUsingItem() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mc.player?.stopUsingItem() | |
player.stopUsingItem() |
var facingEntity = mc.targetedEntity | ||
if (facingEntity == null) { | ||
|
||
var finaltarget: Entity? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finaltarget
does not follow Kotlin Naming Convention as well - should be finalTarget
instead.
if(finaltarget == null){ | ||
return@tickHandler | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(finaltarget == null){ | |
return@tickHandler | |
} | |
if(finaltarget == null) { | |
return@tickHandler | |
} |
|
||
if (rod && pushTimer.hasElapsed(pushDelay.toLong())) { | ||
// Check if player has rod in hand | ||
if (mc.player?.mainHandStack != Items.FISHING_ROD) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (mc.player?.mainHandStack != Items.FISHING_ROD) { | |
if (player.mainHandStack != Items.FISHING_ROD) { |
return@tickHandler | ||
} | ||
// Switch to rod | ||
switchBack = mc.player?.inventory?.getSlotWithStack(mc.player?.inventory?.mainHandStack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switchBack = mc.player?.inventory?.getSlotWithStack(mc.player?.inventory?.mainHandStack) | |
switchBack = player.inventory.getSlotWithStack(player.inventory.mainHandStack) |
if (rod == null) { | ||
return | ||
} | ||
mc.player?.inventory?.selectedSlot = rod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not change the selected slot like that in LiquidBounce Nextgen. LiquidBounce Nextgen offers a much util for that instead called SilentHotbar
.
} | ||
mc.player?.inventory?.selectedSlot = rod | ||
// We do not need to send our own packet, because sendUseItem will handle it for us. | ||
KeyBinding.setKeyPressed(mc.options.useKey.boundKey, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not set key press states in LiquidBounce Nextgen like that. It should rather use the KeybindIsPressedEvent
instead.
@1zun4 modified,but I have no idea about using KeybindIsPressedEvent and make it work.So I keep it as it. |
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private val pushTimer = Chronometer() | ||
private val rodPullTimer = Chronometer() | ||
private var rodInUse = false | ||
private var switchBack: Int = -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private var switchBack: Int = -1 | |
private var switchBack = -1 |
val enemyHealthThreshold by int( | ||
"EnemyHealthThreshold", 5, 1..20 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val enemyHealthThreshold by int( | |
"EnemyHealthThreshold", 5, 1..20 | |
) | |
val enemyHealthThreshold by int("EnemyHealthThreshold", 5, 1..20) |
object ModuleAutoRod : ClientModule("AutoRod", Category.COMBAT) { | ||
|
||
object FacingEnemy : ToggleableConfigurable(this, "FacingEnemy", true) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
object ModuleAutoRod : ClientModule("AutoRod", Category.COMBAT) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val rod = Slots.Hotbar.findSlot(Items.FISHING_ROD)?.hotbarSlot | ||
if (rod == null) { | ||
// There is no rod in hotbar | ||
return@tickHandler | ||
} | ||
// Switch to rod | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val rod = Slots.Hotbar.findSlot(Items.FISHING_ROD)?.hotbarSlot | |
if (rod == null) { | |
// There is no rod in hotbar | |
return@tickHandler | |
} | |
// Switch to rod | |
val rod = Slots.Hotbar.findSlot(Items.FISHING_ROD)?.hotbarSlot ?: return@tickHandler | |
// Switch to rod |
val usingRod = | ||
(player.isUsingItem == true && player.mainHandStack?.item == Items.FISHING_ROD) || rodInUse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val usingRod = | |
(player.isUsingItem == true && player.mainHandStack?.item == Items.FISHING_ROD) || rodInUse | |
val usingRod = player.isUsingItem && player.mainHandStack?.item == Items.FISHING_ROD || rodInUse |
// Switch back to previous item | ||
player.inventory?.selectedSlot = switchBack!! | ||
interaction.syncSelectedSlot() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (usingRod) { | ||
// Check if rod pull timer has reached delay | ||
// mc.player.fishEntity?.caughtEntity != null is always null | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else { | ||
var rod = false | ||
|
||
if (FacingEnemy.enabled && player.getActualHealth()!! >= IgnoreOnEnemyLowHealth.playerHealthThreshold) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (FacingEnemy.enabled && player.getActualHealth()!! >= IgnoreOnEnemyLowHealth.playerHealthThreshold) { | |
if (FacingEnemy.enabled && player.getActualHealth() >= IgnoreOnEnemyLowHealth.playerHealthThreshold) { |
any reason you're using getActualHealth here?
return@tickHandler | ||
} | ||
finalTarget.distanceTo(player).let { it1 -> | ||
if (it1 > range || it1 < ModuleKillAura.range && ModuleKillAura.enabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you using killaura range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adapt KillAura simply
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elaborate
(player.isUsingItem) || | ||
KillAuraAutoBlock.blockVisual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(player.isUsingItem) || | |
KillAuraAutoBlock.blockVisual | |
player.isUsingItem || KillAuraAutoBlock.blockVisual |
// Check if the enemy's health is below the threshold. | ||
if (IgnoreOnEnemyLowHealth.enabled) { | ||
if ((facingEntity is LivingEntity) && | ||
facingEntity.health >= IgnoreOnEnemyLowHealth.enemyHealthThreshold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use getActualHealth() for other entities
var finalTarget: Entity? = null | ||
finalTarget = targetTracker.lockedOnTarget | ||
if(finalTarget == null) { | ||
return@tickHandler | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var finalTarget: Entity? = null | |
finalTarget = targetTracker.lockedOnTarget | |
if(finalTarget == null) { | |
return@tickHandler | |
} | |
val finalTarget = targetTracker.lockedOnTarget ?: return@tickHandler |
The branch carried AutoRod from legacy to nextgen.