@@ -21,7 +21,7 @@ import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121import com.lambda.config.applyEdits
2222import com.lambda.config.groups.Targeting
2323import com.lambda.context.SafeContext
24- import com.lambda.event.events.PlayerPacketEvent
24+ import com.lambda.event.events.InventoryEvent
2525import com.lambda.event.events.TickEvent
2626import com.lambda.event.listener.SafeListener.Companion.listen
2727import com.lambda.interaction.managers.hotbar.HotbarRequest
@@ -67,10 +67,7 @@ object KillAura : Module(
6767
6868 private var lastAttackTime = 0L
6969 private var hitDelay = 100.0
70-
71- private var prevY = 0.0
72- private var lastY = 0.0
73- private var lastOnGround = true
70+ private var cooldownFromSwap = false
7471
7572 enum class Group (override val displayName : String ) : NamedEnum {
7673 General (" General" ),
@@ -98,21 +95,17 @@ object KillAura : Module(
9895 }
9996 }
10097
101- listen<PlayerPacketEvent .Pre >(Int .MIN_VALUE ) { event ->
102- prevY = lastY
103- lastY = event.position.y
104- lastOnGround = event.onGround
105- }
98+ listen<InventoryEvent .HotbarSlot .Update > { cooldownFromSwap = true }
10699
107100 listen<TickEvent .Input .Post > {
108101 target?.let { entity ->
109102 // Wait until the rotation has a hit result on the entity
103+ var rotated = true
110104 if (rotate) runSafeAutomated {
111105 val rotationRequest = lookAtEntity(entity)?.rotation?.let { rotationRequest { rotation(it) } }?.submit() ? : return @listen
112- val cantContinue = ! rotationRequest.done || entity != = prevEntity || ! validServerRot
106+ rotated = rotationRequest.done && entity == = prevEntity && validServerRot
113107 prevEntity = entity
114108 validServerRot = rotationRequest.done
115- if (cantContinue) return @listen
116109 }
117110
118111 if (swap) {
@@ -126,12 +119,16 @@ object KillAura : Module(
126119 }
127120 }
128121
122+ if (! rotated) return @listen
123+
129124 // Cooldown check
130125 when (attackMode) {
131- AttackMode .Cooldown -> if (player.getAttackCooldownProgress(0.5f ) + (cooldownShrink / 20f ) < 1.0f ) return @listen
126+ AttackMode .Cooldown -> if (player.getAttackCooldownProgress(0.5f ) + (cooldownShrink / 20f ) < 1.0f && ! cooldownFromSwap ) return @listen
132127 AttackMode .Delay -> if (System .currentTimeMillis() - lastAttackTime < hitDelay) return @listen
133128 }
134129
130+ cooldownFromSwap = false
131+
135132 // Attack
136133 connection.sendPacket(PlayerInteractEntityC2SPacket .attack(target, player.isSneaking))
137134 if (interaction.gameMode != GameMode .SPECTATOR ) {
@@ -144,17 +141,5 @@ object KillAura : Module(
144141 hitDelay = (hitDelay1.. hitDelay2).random() * 50
145142 }
146143 }
147-
148- onEnable { reset() }
149- onDisable { reset() }
150- }
151-
152- private fun reset () {
153- lastY = 0.0
154- prevY = 0.0
155- lastOnGround = true
156-
157- lastAttackTime = 0L
158- hitDelay = 100.0
159144 }
160145}
0 commit comments