Skip to content

Commit

Permalink
refactor(Esp): sub package for modes (#5603)
Browse files Browse the repository at this point in the history
  • Loading branch information
1zun4 authored Feb 13, 2025
1 parent c895038 commit 0ba86a2
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import com.llamalad7.mixinextras.sugar.Local;
import net.ccbluex.liquidbounce.api.models.cosmetics.CosmeticCategory;
import net.ccbluex.liquidbounce.features.cosmetic.CosmeticService;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleESP;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleFreeCam;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleRotations;
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleTrueSight;
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP;
import net.ccbluex.liquidbounce.interfaces.EntityRenderStateAddition;
import net.ccbluex.liquidbounce.utils.aiming.Rotation;
import net.ccbluex.liquidbounce.utils.aiming.RotationManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import net.ccbluex.liquidbounce.event.EventManager;
import net.ccbluex.liquidbounce.event.events.DrawOutlinesEvent;
import net.ccbluex.liquidbounce.features.module.modules.render.*;
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP;
import net.ccbluex.liquidbounce.features.module.modules.render.esp.modes.EspOutlineMode;
import net.ccbluex.liquidbounce.render.engine.Color4b;
import net.ccbluex.liquidbounce.render.engine.RenderingFlags;
import net.ccbluex.liquidbounce.render.shader.shaders.OutlineShader;
Expand Down Expand Up @@ -117,7 +119,7 @@ private void injectOutlineESP(Entity entity, double cameraX, double cameraY, dou

Color4b color;

if (ModuleESP.OutlineMode.INSTANCE.getRunning() && entity instanceof LivingEntity && CombatExtensionsKt.shouldBeShown(entity)) {
if (EspOutlineMode.INSTANCE.getRunning() && entity instanceof LivingEntity && CombatExtensionsKt.shouldBeShown(entity)) {
color = ModuleESP.INSTANCE.getColor((LivingEntity) entity);
} else if (ModuleItemESP.OutlineMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) {
color = ModuleItemESP.INSTANCE.getColor();
Expand Down Expand Up @@ -203,7 +205,7 @@ private boolean injectHasOutline2(boolean original, @Local Entity entity) {
private boolean shouldRenderOutline(Entity entity) {
if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) {
return true;
} else if (ModuleESP.GlowMode.INSTANCE.getRunning() && CombatExtensionsKt.shouldBeShown(entity)) {
} else if (EspOutlineMode.INSTANCE.getRunning() && CombatExtensionsKt.shouldBeShown(entity)) {
return true;
} else if (ModuleTNTTimer.INSTANCE.getRunning() && ModuleTNTTimer.INSTANCE.getEsp() && entity instanceof TntEntity) {
return true;
Expand All @@ -221,7 +223,7 @@ private boolean shouldRenderOutline(Entity entity) {
*/
@ModifyExpressionValue(method = "renderEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I"))
private int injectTeamColor(int original, @Local Entity entity) {
if (entity instanceof LivingEntity livingEntity && ModuleESP.GlowMode.INSTANCE.getRunning()) {
if (entity instanceof LivingEntity livingEntity && EspOutlineMode.INSTANCE.getRunning()) {
return ModuleESP.INSTANCE.getColor(livingEntity).toARGB();
} else if (ModuleItemESP.GlowMode.INSTANCE.getRunning() && ModuleItemESP.INSTANCE.shouldRender(entity)) {
return ModuleItemESP.INSTANCE.getColor().toARGB();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import net.ccbluex.liquidbounce.features.module.modules.combat.velocity.ModuleVe
import net.ccbluex.liquidbounce.features.module.modules.exploit.*
import net.ccbluex.liquidbounce.features.module.modules.exploit.disabler.ModuleDisabler
import net.ccbluex.liquidbounce.features.module.modules.exploit.dupe.ModuleDupe
import net.ccbluex.liquidbounce.features.module.modules.exploit.servercrasher.ModuleServerCrasher
import net.ccbluex.liquidbounce.features.module.modules.exploit.phase.ModulePhase
import net.ccbluex.liquidbounce.features.module.modules.exploit.servercrasher.ModuleServerCrasher
import net.ccbluex.liquidbounce.features.module.modules.`fun`.*
import net.ccbluex.liquidbounce.features.module.modules.misc.*
import net.ccbluex.liquidbounce.features.module.modules.misc.antibot.ModuleAntiBot
Expand Down Expand Up @@ -72,6 +72,7 @@ import net.ccbluex.liquidbounce.features.module.modules.player.invcleaner.Module
import net.ccbluex.liquidbounce.features.module.modules.player.nofall.ModuleNoFall
import net.ccbluex.liquidbounce.features.module.modules.player.offhand.ModuleOffhand
import net.ccbluex.liquidbounce.features.module.modules.render.*
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP
import net.ccbluex.liquidbounce.features.module.modules.render.murdermystery.ModuleMurderMystery
import net.ccbluex.liquidbounce.features.module.modules.render.nametags.ModuleNametags
import net.ccbluex.liquidbounce.features.module.modules.render.trajectories.ModuleTrajectories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,48 @@
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render
package net.ccbluex.liquidbounce.features.module.modules.render.esp

import net.ccbluex.liquidbounce.config.types.Choice
import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.misc.FriendManager
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.render.*
import net.ccbluex.liquidbounce.features.module.modules.render.esp.modes.EspBoxMode
import net.ccbluex.liquidbounce.features.module.modules.render.esp.modes.EspGlowMode
import net.ccbluex.liquidbounce.features.module.modules.render.esp.modes.EspOutlineMode
import net.ccbluex.liquidbounce.render.GenericEntityHealthColorMode
import net.ccbluex.liquidbounce.render.GenericRainbowColorMode
import net.ccbluex.liquidbounce.render.GenericStaticColorMode
import net.ccbluex.liquidbounce.render.engine.Color4b
import net.ccbluex.liquidbounce.utils.combat.EntityTaggingManager
import net.ccbluex.liquidbounce.utils.combat.shouldBeShown
import net.ccbluex.liquidbounce.utils.entity.RenderedEntities
import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition
import net.minecraft.entity.LivingEntity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.util.math.Box

/**
* ESP module
*
* Allows you to see targets through walls.
*/

object ModuleESP : ClientModule("ESP", Category.RENDER) {

override val baseKey: String
get() = "liquidbounce.module.esp"

private val modes = choices("Mode", GlowMode, arrayOf(BoxMode, OutlineMode, GlowMode))
val modes = choices("Mode", EspGlowMode, arrayOf(
EspBoxMode,
EspOutlineMode,
EspGlowMode
))

private val colorModes = choices("ColorMode", 0) {
arrayOf(
GenericEntityHealthColorMode(it),
GenericStaticColorMode(it, Color4b.WHITE.with(a = 100)),
GenericStaticColorMode(it, Color4b.Companion.WHITE.with(a = 100)),
GenericRainbowColorMode(it)
)
}

private val friendColor by color("Friends", Color4b.GREEN)

sealed class EspMode(
name: String,
val requiresTrueSight: Boolean = false
) : Choice(name) {
override val parent
get() = modes
}
private val friendColor by color("Friends", Color4b.Companion.GREEN)

override fun enable() {
RenderedEntities.subscribe(this)
Expand All @@ -72,49 +67,16 @@ object ModuleESP : ClientModule("ESP", Category.RENDER) {
RenderedEntities.unsubscribe(this)
}

private object BoxMode : EspMode("Box") {

private val outline by boolean("Outline", true)

@Suppress("unused")
val renderHandler = handler<WorldRenderEvent> { event ->
val matrixStack = event.matrixStack

val entitiesWithBoxes = RenderedEntities.map { entity ->
val dimensions = entity.getDimensions(entity.pose)

val d = dimensions.width.toDouble() / 2.0

entity to Box(-d, 0.0, -d, d, dimensions.height.toDouble(), d).expand(0.05)
}

renderEnvironmentForWorld(matrixStack) {
BoxRenderer.drawWith(this) {
entitiesWithBoxes.forEach { (entity, box) ->
val pos = entity.interpolateCurrentPosition(event.partialTicks)
val color = getColor(entity)

val baseColor = color.with(a = 50)
val outlineColor = color.with(a = 100)
fun getColor(entity: LivingEntity): Color4b {
val baseColor = getBaseColor(entity)

withPositionRelativeToCamera(pos) {
drawBox(
box,
baseColor,
outlineColor.takeIf { outline }
)
}
}
}
}
if (entity.hurtTime > 0) {
return Color4b.Companion.RED
}

return baseColor
}

object GlowMode : EspMode("Glow", requiresTrueSight = true)

object OutlineMode : EspMode("Outline", requiresTrueSight = true)

private fun getBaseColor(entity: LivingEntity): Color4b {
if (entity is PlayerEntity) {
if (FriendManager.isFriend(entity) && friendColor.a > 0) {
Expand All @@ -127,16 +89,9 @@ object ModuleESP : ClientModule("ESP", Category.RENDER) {
return colorModes.activeChoice.getColor(entity)
}

fun getColor(entity: LivingEntity): Color4b {
val baseColor = getBaseColor(entity)

if (entity.hurtTime > 0) {
return Color4b.RED
}

return baseColor
}

/**
* Check if the entity requires true sight to be shown with the current ESP mode
*/
fun requiresTrueSight(entity: LivingEntity) =
modes.activeChoice.requiresTrueSight && entity.shouldBeShown()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render.esp.modes

import net.ccbluex.liquidbounce.event.events.WorldRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP.getColor
import net.ccbluex.liquidbounce.render.BoxRenderer
import net.ccbluex.liquidbounce.render.renderEnvironmentForWorld
import net.ccbluex.liquidbounce.render.withPositionRelativeToCamera
import net.ccbluex.liquidbounce.utils.entity.RenderedEntities
import net.ccbluex.liquidbounce.utils.entity.interpolateCurrentPosition
import net.minecraft.util.math.Box

object EspBoxMode : EspMode("Box") {

private val outline by boolean("Outline", true)

@Suppress("unused")
private val renderHandler = handler<WorldRenderEvent> { event ->
val matrixStack = event.matrixStack
val entitiesWithBoxes = RenderedEntities.map { entity ->
val dimensions = entity.getDimensions(entity.pose)

val d = dimensions.width.toDouble() / 2.0

entity to Box(-d, 0.0, -d, d, dimensions.height.toDouble(), d).expand(0.05)
}

renderEnvironmentForWorld(matrixStack) {
BoxRenderer.Companion.drawWith(this) {
entitiesWithBoxes.forEach { (entity, box) ->
val pos = entity.interpolateCurrentPosition(event.partialTicks)
val color = getColor(entity)

val baseColor = color.with(a = 50)
val outlineColor = color.with(a = 100)

withPositionRelativeToCamera(pos) {
drawBox(
box,
baseColor,
outlineColor.takeIf { outline }
)
}
}
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render.esp.modes

object EspGlowMode : EspMode("Glow", requiresTrueSight = true)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render.esp.modes

import net.ccbluex.liquidbounce.config.types.Choice
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP.modes

sealed class EspMode(
name: String,
val requiresTrueSight: Boolean = false
) : Choice(name) {
override val parent
get() = modes
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
*
* Copyright (c) 2015 - 2025 CCBlueX
*
* LiquidBounce is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiquidBounce is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
*/
package net.ccbluex.liquidbounce.features.module.modules.render.esp.modes

object EspOutlineMode : EspMode("Outline", requiresTrueSight = true)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import com.mojang.blaze3d.systems.RenderSystem
import net.ccbluex.liquidbounce.event.events.OverlayRenderEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.misc.HideAppearance
import net.ccbluex.liquidbounce.features.module.modules.render.ModuleESP
import net.ccbluex.liquidbounce.features.module.modules.render.esp.ModuleESP
import net.ccbluex.liquidbounce.integration.theme.component.Component
import net.ccbluex.liquidbounce.render.*
import net.ccbluex.liquidbounce.render.engine.Color4b
Expand Down

0 comments on commit 0ba86a2

Please sign in to comment.