From a1387d70d88c598834575a510f8eaa981dec240b Mon Sep 17 00:00:00 2001 From: Zywl <86253343+opZywl@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:48:17 -0300 Subject: [PATCH] feat/fix: esp gaussian mode & fixed esp inside dorender not following condition --- .../features/module/modules/visual/ESP.kt | 21 ++++++------ .../render/MixinRendererLivingEntity.java | 33 ++++++++++++++----- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/ESP.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/ESP.kt index a7409af2a6..9e0d13c4fd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/ESP.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/visual/ESP.kt @@ -40,7 +40,7 @@ object ESP : Module("ESP", Category.VISUAL, hideModule = false) { val mode by choices( "Mode", - arrayOf("Box", "OtherBox", "WireFrame", "2D", "Real2D", "Outline", "Glow"), "Box" + arrayOf("Box", "OtherBox", "WireFrame", "2D", "Real2D", "Gaussian", "Outline", "Glow"), "Box" ) val outlineWidth by float("Outline-Width", 3f, 0.5f..5f) { mode == "Outline" } @@ -54,7 +54,7 @@ object ESP : Module("ESP", Category.VISUAL, hideModule = false) { private val espColorMode by choices("ESP-Color", arrayOf("Custom", "Rainbow"), "Custom") private val espColor = ColorSettingsInteger(this, "ESP", withAlpha = false) - { espColorMode == "Custom" }.with(255, 255, 255) + { espColorMode in arrayOf("Custom", "Gaussian") }.with(255, 255, 255) private val maxRenderDistance by object : IntegerValue("MaxRenderDistance", 100, 1..200) { override fun onUpdate(value: Int) { @@ -72,17 +72,12 @@ object ESP : Module("ESP", Category.VISUAL, hideModule = false) { field = if (value <= 0.0) maxRenderDistance.toDouble().pow(2.0) else value } - private val colorTeam by boolean("Team", false) + private val colorTeam by boolean("TeamColor", false) private val bot by boolean("Bots", true) var renderNameTags = true - private val entities by EntityLookup() - .filter { bot || !isBot(it) } - .filter { isSelected(it, false) } - .filter { !onLook || isLookingOnEntities(it, maxAngleDifference.toDouble()) } - .filter { mc.thePlayer.getDistanceSqToEntity(it) <= maxRenderDistanceSq } - .filter { thruBlocks || isEntityHeightVisible(it) } + private val entities by EntityLookup().filter { shouldRender(it) } val onRender3D = handler { if (entities.isEmpty()) @@ -222,7 +217,13 @@ object ESP : Module("ESP", Category.VISUAL, hideModule = false) { } fun shouldRender(entity: EntityLivingBase): Boolean { - return (bot || !isBot(entity)) + val player = mc.thePlayer ?: return false + + return (player.getDistanceSqToEntity(entity) <= maxRenderDistanceSq + && (thruBlocks || isEntityHeightVisible(entity)) + && (!onLook || isLookingOnEntities(entity, maxAngleDifference.toDouble())) + && isSelected(entity, false) + && (bot || !isBot(entity))) } } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/render/MixinRendererLivingEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/render/MixinRendererLivingEntity.java index 8c32bc727e..7b0b570509 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/render/MixinRendererLivingEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/render/MixinRendererLivingEntity.java @@ -99,6 +99,8 @@ protected void rotateCorpse(T p_rotateCorpse_1_, fl @Inject(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At("HEAD"), cancellable = true) private void injectChamsPre(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo callbackInfo) { final Chams chams = Chams.INSTANCE; + final ESP esp = ESP.INSTANCE; + boolean shouldRender = chams.handleEvents() && chams.getTargets() && EntityUtils.INSTANCE.isSelected(entity, false) || esp.handleEvents() && esp.shouldRender(entity) && esp.getMode().equals("Gaussian"); final NoRender noRender = NoRender.INSTANCE; if (noRender.handleEvents() && noRender.shouldStopRender(entity)) { @@ -106,21 +108,23 @@ private void injectChamsPre(T entity, double x, dou return; } - if (chams.getState() && chams.getTargets() && chams.getLegacyMode() && ((chams.getLocalPlayerValue() && entity == mc.thePlayer) || EntityUtils.INSTANCE.isSelected(entity, false))) { + if (shouldRender) { glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1.0F, -1000000F); + glPolygonOffset(1f, -1000000F); } } @Inject(method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V", at = @At("RETURN")) private void injectChamsPost(T entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo callbackInfo) { final Chams chams = Chams.INSTANCE; + final ESP esp = ESP.INSTANCE; + boolean shouldRender = chams.handleEvents() && chams.getTargets() && EntityUtils.INSTANCE.isSelected(entity, false) || esp.handleEvents() && esp.shouldRender(entity) && esp.getMode().equals("Gaussian"); final NoRender noRender = NoRender.INSTANCE; - if (chams.getState() && chams.getTargets() && chams.getLegacyMode() && ((chams.getLocalPlayerValue() && entity == mc.thePlayer) || EntityUtils.INSTANCE.isSelected(entity, false))) { + if (shouldRender) { if (!(noRender.getState() && noRender.shouldStopRender(entity))) { - glPolygonOffset(1.0F, 1000000F); - glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1f, 1000000F); + glDisable(GL_POLYGON_OFFSET_FILL); } } } @@ -298,8 +302,16 @@ protected void renderModel(T entitylivingbaseIn, fl boolean chamsFlag = (chams.handleEvents() && chams.getTargets() && !chams.getLegacyMode() && ((chams.getLocalPlayerValue() && entitylivingbaseIn == mc.thePlayer) || EntityUtils.INSTANCE.isSelected(entitylivingbaseIn, false))); boolean semiVisible = !visible && (!entitylivingbaseIn.isInvisibleToPlayer(mc.thePlayer) || (trueSight.handleEvents() && trueSight.getEntities())); if(visible || semiVisible) { - if(!this.bindEntityTexture(entitylivingbaseIn)) - return; + final ESP esp = ESP.INSTANCE; + boolean shouldRenderGaussianESP = esp.handleEvents() && esp.shouldRender(entitylivingbaseIn) && esp.getMode().equals("Gaussian"); + if (!shouldRenderGaussianESP) { + if (!bindEntityTexture(entitylivingbaseIn)) { + return; + } + } else { + bindTexture(0); + RenderUtils.INSTANCE.glColor(esp.getColor(entitylivingbaseIn)); + } if (semiVisible) { pushMatrix(); @@ -310,8 +322,7 @@ protected void renderModel(T entitylivingbaseIn, fl alphaFunc(516, 0.003921569F); } - final ESP esp = ESP.INSTANCE; - if (esp.handleEvents() && esp.shouldRender(entitylivingbaseIn) && EntityUtils.INSTANCE.isSelected(entitylivingbaseIn, false)) { + if (esp.handleEvents() && esp.shouldRender(entitylivingbaseIn)) { boolean fancyGraphics = mc.gameSettings.fancyGraphics; mc.gameSettings.fancyGraphics = false; @@ -441,6 +452,10 @@ protected void renderModel(T entitylivingbaseIn, fl glPopMatrix(); } + if (shouldRenderGaussianESP) { + resetColor(); + } + if (semiVisible) { disableBlend(); alphaFunc(516, 0.1F);