[fix] AutoLog shouldn't run totem check if player inventory is empty

closes #1854
This commit is contained in:
Xiaro 2021-01-16 12:54:24 -05:00
parent fbaaaed520
commit e5cead1975
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 7 additions and 1 deletions

View File

@ -53,7 +53,7 @@ internal object AutoLog : Module(
when {
CombatUtils.getHealthSmart(player) < health -> log(HEALTH)
totem && player.allSlots.countItem(Items.TOTEM_OF_UNDYING) < minTotems -> log(TOTEM)
totem && checkTotems() -> log(TOTEM)
crystals && checkCrystals() -> log(END_CRYSTAL)
creeper && checkCreeper() -> {
/* checkCreeper() does log() */
@ -65,6 +65,12 @@ internal object AutoLog : Module(
}
}
private fun SafeClientEvent.checkTotems() : Boolean {
val slots = player.allSlots
return slots.any { it.hasStack }
&& slots.countItem(Items.TOTEM_OF_UNDYING) < minTotems
}
private fun SafeClientEvent.checkCrystals(): Boolean {
val maxSelfDamage = CombatManager.crystalMap.values.maxByOrNull { it.second }?.second ?: 0.0f
return CombatUtils.getHealthSmart(player) - maxSelfDamage < health