Skip to content

Commit

Permalink
feat/fix: notifier module
Browse files Browse the repository at this point in the history
  • Loading branch information
opZywl committed Nov 20, 2024
1 parent f6eacfb commit e4f96cd
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
*/
package net.ccbluex.liquidbounce.features.module.modules.client

import net.ccbluex.liquidbounce.event.AttackEvent
import net.ccbluex.liquidbounce.event.EventTarget
import net.ccbluex.liquidbounce.event.PacketEvent
import net.ccbluex.liquidbounce.event.WorldEvent
import net.ccbluex.liquidbounce.event.*
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.Module
import net.ccbluex.liquidbounce.utils.RotationUtils.angleDifference
Expand All @@ -27,6 +24,7 @@ import net.minecraft.network.play.server.S13PacketDestroyEntities
import net.minecraft.network.play.server.S14PacketEntity
import net.minecraft.network.play.server.S20PacketEntityProperties
import net.minecraft.potion.Potion
import java.util.*
import kotlin.math.abs
import kotlin.math.sqrt

Expand Down Expand Up @@ -87,6 +85,8 @@ object AntiBot : Module("AntiBot", Category.CLIENT, hideModule = false) {
private val tabDuplicateNames = mutableSetOf<String>()
private val entityTickMap = mutableMapOf<Int, Int>()

val botList = mutableSetOf<UUID>()

fun isBot(entity: EntityLivingBase): Boolean {
// Check if entity is a player
if (entity !is EntityPlayer)
Expand Down Expand Up @@ -222,6 +222,27 @@ object AntiBot : Module("AntiBot", Category.CLIENT, hideModule = false) {
return entity.name.isEmpty() || entity.name == mc.thePlayer.name
}

@EventTarget(ignoreCondition = true)
fun onUpdate(event: UpdateEvent) {
val world = mc.theWorld ?: return

for (entity in world.loadedEntityList) {
if (entity !is EntityPlayer) continue
val profile = entity.gameProfile ?: continue

if (isBot(entity)) {
if (profile.id !in botList) {
botList += profile.id
}
} else {
if (profile.id in botList) {
botList -= profile.id
}
}
}
}

// Alternative for isBot() check.
@EventTarget(ignoreCondition = true)
fun onPacket(event: PacketEvent) {
if (mc.thePlayer == null || mc.theWorld == null)
Expand Down Expand Up @@ -361,6 +382,7 @@ object AntiBot : Module("AntiBot", Category.CLIENT, hideModule = false) {
tabDuplicateNames.clear()
alwaysBehindList.clear()
entityTickMap.clear()
botList.clear()
}

}

0 comments on commit e4f96cd

Please sign in to comment.