Skip to content

Commit 3e266b0

Browse files
committed
depth test / block outline start / immediate region esp where you update vertices each frame
1 parent 4044077 commit 3e266b0

File tree

13 files changed

+219
-231
lines changed

13 files changed

+219
-231
lines changed

src/main/kotlin/com/lambda/graphics/esp/RegionESP.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ import com.lambda.Lambda.mc
2121
import com.lambda.graphics.mc.LambdaRenderPipelines
2222
import com.lambda.graphics.mc.RegionRenderer
2323
import com.lambda.graphics.mc.RenderRegion
24-
import com.lambda.util.extension.tickDelta
24+
import com.lambda.util.extension.tickDeltaF
2525
import com.mojang.blaze3d.systems.RenderSystem
26-
import java.util.concurrent.ConcurrentHashMap
27-
import kotlin.math.floor
2826
import org.joml.Matrix4f
2927
import org.joml.Vector3f
3028
import org.joml.Vector4f
29+
import java.util.concurrent.ConcurrentHashMap
30+
import kotlin.math.floor
3131

3232
/**
3333
* Base class for region-based ESP systems. Provides unified rendering logic and region management.
3434
*/
35-
abstract class RegionESP(val name: String, val depthTest: Boolean) {
35+
abstract class RegionESP(val name: String, var depthTest: Boolean) {
3636
protected val renderers = ConcurrentHashMap<Long, RegionRenderer>()
3737

3838
/** Get or create a ShapeScope for a specific world position. */
@@ -53,9 +53,9 @@ abstract class RegionESP(val name: String, val depthTest: Boolean) {
5353

5454
/**
5555
* Render all active regions.
56-
* @param tickDelta Progress within current tick (used for interpolation)
56+
* @param tickDeltaF Progress within current tick (used for interpolation)
5757
*/
58-
open fun render(tickDelta: Float = mc.tickDelta) {
58+
fun render() {
5959
val camera = mc.gameRenderer?.camera ?: return
6060
val cameraPos = camera.pos
6161

@@ -78,7 +78,7 @@ abstract class RegionESP(val name: String, val depthTest: Boolean) {
7878
}
7979

8080
// Render Faces
81-
RegionRenderer.createRenderPass("$name Faces")?.use { pass ->
81+
RegionRenderer.createRenderPass("$name Faces", depthTest)?.use { pass ->
8282
val pipeline =
8383
if (depthTest) LambdaRenderPipelines.ESP_QUADS
8484
else LambdaRenderPipelines.ESP_QUADS_THROUGH
@@ -91,7 +91,7 @@ abstract class RegionESP(val name: String, val depthTest: Boolean) {
9191
}
9292

9393
// Render Edges
94-
RegionRenderer.createRenderPass("$name Edges")?.use { pass ->
94+
RegionRenderer.createRenderPass("$name Edges", depthTest)?.use { pass ->
9595
val pipeline =
9696
if (depthTest) LambdaRenderPipelines.ESP_LINES
9797
else LambdaRenderPipelines.ESP_LINES_THROUGH
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright 2026 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.graphics.mc
19+
20+
import com.lambda.graphics.esp.RegionESP
21+
import com.lambda.graphics.esp.ShapeScope
22+
import java.util.concurrent.ConcurrentHashMap
23+
import kotlin.math.floor
24+
25+
/**
26+
* Interpolated region-based ESP system for smooth entity rendering.
27+
*
28+
* This system rebuilds and uploads vertices every frame. Callers are responsible for providing
29+
* interpolated positions (e.g., using entity.prevX/x with tickDelta). The tick() method swaps
30+
* builders to allow smooth transitions between frames.
31+
*/
32+
class ImmediateRegionESP(name: String, depthTest: Boolean = false) : RegionESP(name, depthTest) {
33+
// Current frame builders (being populated this tick)
34+
private val currBuilders = ConcurrentHashMap<Long, ShapeScope>()
35+
36+
override fun shapes(x: Double, y: Double, z: Double, block: ShapeScope.() -> Unit) {
37+
val key = getRegionKey(x, y, z)
38+
val scope =
39+
currBuilders.getOrPut(key) {
40+
val size = RenderRegion.REGION_SIZE
41+
val rx = (size * floor(x / size)).toInt()
42+
val ry = (size * floor(y / size)).toInt()
43+
val rz = (size * floor(z / size)).toInt()
44+
ShapeScope(RenderRegion(rx, ry, rz))
45+
}
46+
scope.apply(block)
47+
}
48+
49+
override fun clear() {
50+
currBuilders.clear()
51+
}
52+
53+
fun tick() {
54+
currBuilders.clear()
55+
}
56+
57+
override fun upload() {
58+
val activeKeys = currBuilders.keys.toSet()
59+
60+
currBuilders.forEach { (key, scope) ->
61+
val renderer = renderers.getOrPut(key) { RegionRenderer(scope.region) }
62+
renderer.upload(scope.builder.collector)
63+
}
64+
65+
renderers.forEach { (key, renderer) ->
66+
if (key !in activeKeys) {
67+
renderer.clearData()
68+
}
69+
}
70+
}
71+
}

src/main/kotlin/com/lambda/graphics/mc/InterpolatedRegionESP.kt

Lines changed: 0 additions & 139 deletions
This file was deleted.

src/main/kotlin/com/lambda/graphics/mc/RegionRenderer.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,24 @@ class RegionRenderer(val region: RenderRegion) {
126126
companion object {
127127
/** Helper to create a render pass targeting the main framebuffer. */
128128
fun createRenderPass(label: String): RenderPass? {
129+
return createRenderPass(label, useDepth = true)
130+
}
131+
132+
/**
133+
* Helper to create a render pass targeting the main framebuffer.
134+
* @param label Debug label for the render pass
135+
* @param useDepth Whether to attach the depth buffer for depth testing
136+
*/
137+
fun createRenderPass(label: String, useDepth: Boolean): RenderPass? {
129138
val framebuffer = mc.framebuffer ?: return null
139+
val depthView = if (useDepth) framebuffer.depthAttachmentView else null
130140
return RenderSystem.getDevice()
131141
.createCommandEncoder()
132142
.createRenderPass(
133143
{ label },
134144
framebuffer.colorAttachmentView,
135145
OptionalInt.empty(),
136-
framebuffer.depthAttachmentView,
146+
depthView,
137147
OptionalDouble.empty()
138148
)
139149
}

src/main/kotlin/com/lambda/graphics/mc/RegionShapeBuilder.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import com.lambda.graphics.renderer.esp.DynamicAABB
2424
import com.lambda.module.modules.client.StyleEditor
2525
import com.lambda.threading.runSafe
2626
import com.lambda.util.BlockUtils.blockState
27-
import com.lambda.util.extension.partialTicks
27+
import com.lambda.util.extension.tickDelta
2828
import net.minecraft.block.BlockState
2929
import net.minecraft.block.entity.BlockEntity
3030
import net.minecraft.entity.Entity
@@ -35,7 +35,6 @@ import net.minecraft.util.math.Vec3d
3535
import net.minecraft.util.shape.VoxelShape
3636
import java.awt.Color
3737
import kotlin.math.min
38-
import kotlin.math.sqrt
3938

4039
/**
4140
* Shape builder for region-based rendering. All coordinates are automatically converted to
@@ -138,7 +137,7 @@ class RegionShapeBuilder(val region: RenderRegion) {
138137
val pair = box.pair ?: return
139138
val prev = pair.first
140139
val curr = pair.second
141-
val tickDelta = mc.partialTicks
140+
val tickDelta = mc.tickDelta
142141
val interpolated = Box(
143142
lerp(tickDelta, prev.minX, curr.minX),
144143
lerp(tickDelta, prev.minY, curr.minY),
@@ -231,7 +230,7 @@ class RegionShapeBuilder(val region: RenderRegion) {
231230
val pair = box.pair ?: return
232231
val prev = pair.first
233232
val curr = pair.second
234-
val tickDelta = mc.partialTicks
233+
val tickDelta = mc.tickDelta
235234
val interpolated = Box(
236235
lerp(tickDelta, prev.minX, curr.minX),
237236
lerp(tickDelta, prev.minY, curr.minY),

src/main/kotlin/com/lambda/interaction/managers/breaking/BreakManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import com.lambda.util.BlockUtils.calcItemBlockBreakingDelta
7777
import com.lambda.util.BlockUtils.isEmpty
7878
import com.lambda.util.BlockUtils.isNotBroken
7979
import com.lambda.util.BlockUtils.isNotEmpty
80-
import com.lambda.util.extension.partialTicks
80+
import com.lambda.util.extension.tickDelta
8181
import com.lambda.util.item.ItemUtils.block
8282
import com.lambda.util.math.lerp
8383
import com.lambda.util.player.gamemode
@@ -248,7 +248,7 @@ object BreakManager : Manager<BreakRequest>(
248248

249249
val currentProgress = currentDelta / adjustedThreshold
250250
val nextTicksProgress = (currentDelta + breakDelta) / adjustedThreshold
251-
val interpolatedProgress = lerp(mc.partialTicks, currentProgress, nextTicksProgress)
251+
val interpolatedProgress = lerp(mc.tickDelta, currentProgress, nextTicksProgress)
252252

253253
val fillColor = if (config.dynamicFillColor) lerp(
254254
interpolatedProgress,

src/main/kotlin/com/lambda/module/modules/combat/AutoDisconnect.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.lambda.util.Formatting.format
3131
import com.lambda.util.combat.CombatUtils.hasDeadlyCrystal
3232
import com.lambda.util.combat.DamageUtils.isFallDeadly
3333
import com.lambda.util.extension.fullHealth
34-
import com.lambda.util.extension.tickDelta
34+
import com.lambda.util.extension.tickDeltaF
3535
import com.lambda.util.player.SlotUtils.allStacks
3636
import com.lambda.util.text.buildText
3737
import com.lambda.util.text.color
@@ -219,7 +219,7 @@ object AutoDisconnect : Module(
219219
}),
220220
Creeper({ creeper }, {
221221
fastEntitySearch<CreeperEntity>(15.0).find {
222-
it.getLerpedFuseTime(mc.tickDelta) > 0.0
222+
it.getLerpedFuseTime(mc.tickDeltaF) > 0.0
223223
&& it.pos.distanceTo(player.pos) <= 5.0
224224
}?.let { creeper ->
225225
buildText {

src/main/kotlin/com/lambda/module/modules/combat/AutoTotem.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import com.lambda.util.NamedEnum
3131
import com.lambda.util.combat.CombatUtils.hasDeadlyCrystal
3232
import com.lambda.util.combat.DamageUtils.isFallDeadly
3333
import com.lambda.util.extension.fullHealth
34-
import com.lambda.util.extension.tickDelta
34+
import com.lambda.util.extension.tickDeltaF
3535
import com.lambda.util.world.fastEntitySearch
3636
import net.minecraft.entity.mob.CreeperEntity
3737
import net.minecraft.entity.player.PlayerEntity
@@ -85,7 +85,7 @@ object AutoTotem : Module(
8585
enum class Reason(val check: SafeContext.() -> Boolean) {
8686
Health({ player.fullHealth < minimumHealth }),
8787
Creeper({ creeper && fastEntitySearch<CreeperEntity>(15.0).any {
88-
it.getLerpedFuseTime(mc.tickDelta) > 0.0
88+
it.getLerpedFuseTime(mc.tickDeltaF) > 0.0
8989
&& it.pos.distanceTo(player.pos) <= 5.0
9090
} }),
9191
Player({ players && fastEntitySearch<PlayerEntity>(minPlayerDistance.toDouble()).any { otherPlayer ->

0 commit comments

Comments
 (0)