From e4f96cdd389f93ccd430e5b1ee1e2f636037516e Mon Sep 17 00:00:00 2001 From: Zywl <86253343+opZywl@users.noreply.github.com> Date: Wed, 20 Nov 2024 11:22:06 -0300 Subject: [PATCH] feat/fix: notifier module --- .../features/module/modules/client/AntiBot.kt | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/AntiBot.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/AntiBot.kt index 70950aa58e..31ff021aee 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/AntiBot.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/AntiBot.kt @@ -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 @@ -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 @@ -87,6 +85,8 @@ object AntiBot : Module("AntiBot", Category.CLIENT, hideModule = false) { private val tabDuplicateNames = mutableSetOf() private val entityTickMap = mutableMapOf() + val botList = mutableSetOf() + fun isBot(entity: EntityLivingBase): Boolean { // Check if entity is a player if (entity !is EntityPlayer) @@ -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) @@ -361,6 +382,7 @@ object AntiBot : Module("AntiBot", Category.CLIENT, hideModule = false) { tabDuplicateNames.clear() alwaysBehindList.clear() entityTickMap.clear() + botList.clear() } } \ No newline at end of file