@@ -12,13 +12,16 @@ import com.lambda.module.Module
1212import com.lambda.module.modules.client.GuiSettings
1313import com.lambda.module.modules.combat.KillAura
1414import com.lambda.module.tag.ModuleTag
15+ import com.lambda.util.ClientPacket
1516import com.lambda.util.PacketUtils.handlePacketSilently
17+ import com.lambda.util.PacketUtils.sendPacketSilently
1618import com.lambda.util.ServerPacket
1719import com.lambda.util.math.ColorUtils.multAlpha
1820import com.lambda.util.math.MathUtils.lerp
1921import com.lambda.util.math.VecUtils.dist
2022import com.lambda.util.math.VecUtils.minus
2123import com.lambda.util.math.VecUtils.plus
24+ import net.minecraft.entity.LivingEntity
2225import net.minecraft.network.packet.s2c.play.EntityAnimationS2CPacket
2326import net.minecraft.network.packet.s2c.play.EntityPositionS2CPacket
2427import net.minecraft.network.packet.s2c.play.EntityS2CPacket
@@ -38,19 +41,22 @@ object BackTrack : Module(
3841 description = " Gives reach advantage by delaying your packets" ,
3942 defaultTags = setOf(ModuleTag .MOVEMENT )
4043) {
44+ private val outbound by setting(" Outbound" , true )
4145 private val mode by setting(" Mode" , Mode .FIXED )
4246 private val delay by setting(" Delay" , 500 , 100 .. 2000 ) { mode == Mode .FIXED }
4347 private val maxDelay by setting(" Max Delay" , 1000 , 100 .. 2000 ) { mode == Mode .RANGED || mode == Mode .ADAPTIVE }
4448 private val distance by setting(" Distance" , 3.0 , 1.0 .. 5.0 , 0.1 ) { mode == Mode .RANGED || mode == Mode .ADAPTIVE }
4549
46- private val target get() = if ( KillAura .isDisabled) null else KillAura .target
50+ private var target: LivingEntity ? = null
4751 private var targetPos: Vec3d ? = null
4852
4953 private val box = DynamicAABB ()
5054
5155 private const val POSITION_PACKET_SCALE = 1 / 4096.0
5256 private val currentTime get() = System .currentTimeMillis()
53- private val packetPool = ConcurrentLinkedDeque <Pair <ServerPacket , Long >>()
57+
58+ private val sendPool = ConcurrentLinkedDeque <Pair <ClientPacket , Long >>()
59+ private val receivePool = ConcurrentLinkedDeque <Pair <ServerPacket , Long >>()
5460
5561 enum class Mode (val shouldSend : SafeContext .(Vec3d , Vec3d , Long ) -> Boolean ) {
5662 FIXED ({ _, _, timing ->
@@ -70,18 +76,22 @@ object BackTrack : Module(
7076
7177 init {
7278 listener<TickEvent .Pre > {
73- target?.let { target ->
74- val pos = targetPos ? : target.pos
75- targetPos = pos
76-
77- box.update(target.boundingBox.offset(pos - target.pos))
78- poolPackets()
79+ val prevTarget = target
80+ target = if (KillAura .isDisabled) null else KillAura .target
81+ val currentTarget = target
82+
83+ if (prevTarget != currentTarget || currentTarget == null ) {
84+ poolPackets(true )
85+ targetPos = null
86+ box.reset()
7987 return @listener
8088 }
8189
82- poolPackets(true )
83- targetPos = null
84- box.reset()
90+ val pos = targetPos ? : currentTarget.pos
91+ targetPos = pos
92+
93+ box.update(currentTarget.boundingBox.offset(pos - currentTarget.pos))
94+ poolPackets()
8595 }
8696
8797 listener<RenderEvent .DynamicESP > {
@@ -95,6 +105,12 @@ object BackTrack : Module(
95105 it.renderer.build(box, c.multAlpha(0.3 ), c.multAlpha(0.8 ))
96106 }
97107
108+ listener<PacketEvent .Send .Pre > { event ->
109+ if (! outbound || target == null ) return @listener
110+ sendPool.add(event.packet to currentTime)
111+ event.cancel()
112+ }
113+
98114 listener<PacketEvent .Receive .Pre > { event ->
99115 val target = target ? : return @listener
100116
@@ -126,16 +142,18 @@ object BackTrack : Module(
126142 }
127143 }
128144
129- packetPool .add(packet to currentTime)
145+ receivePool .add(packet to currentTime)
130146 event.cancel()
131147 }
132148
133149 listener<ConnectionEvent .Connect > {
134- packetPool.clear()
150+ receivePool.clear()
151+ sendPool.clear()
135152 }
136153
137154 onEnable {
138- poolPackets(true )
155+ receivePool.clear()
156+ sendPool.clear()
139157 }
140158
141159 onDisable {
@@ -144,8 +162,21 @@ object BackTrack : Module(
144162 }
145163
146164 private fun SafeContext.poolPackets (all : Boolean = false) {
147- while (packetPool.isNotEmpty()) {
148- val (packet, timing) = packetPool.poll() ? : break
165+ while (receivePool.isNotEmpty()) {
166+ val (packet, timing) = receivePool.poll() ? : break
167+
168+ val receive = all || targetPos?.let { serverPos ->
169+ target?.pos?.let { clientPos ->
170+ mode.shouldSend(this , clientPos, serverPos, timing)
171+ }
172+ } ? : true
173+
174+ if (! receive) break
175+ connection.handlePacketSilently(packet)
176+ }
177+
178+ while (sendPool.isNotEmpty()) {
179+ val (packet, timing) = sendPool.poll() ? : break
149180
150181 val send = all || targetPos?.let { serverPos ->
151182 target?.pos?.let { clientPos ->
@@ -154,7 +185,7 @@ object BackTrack : Module(
154185 } ? : true
155186
156187 if (! send) break
157- connection.handlePacketSilently (packet)
188+ connection.sendPacketSilently (packet)
158189 }
159190 }
160191}
0 commit comments