Skip to content

Commit 65751e3

Browse files
committed
Tickshift improvements
1 parent f3757f6 commit 65751e3

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

common/src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ void onTickPost(CallbackInfo ci) {
3535
EventFlow.post(new TickEvent.Post());
3636
}
3737

38+
@Inject(method = "render", at = @At("HEAD"))
39+
void onLoopTickPre(CallbackInfo ci) {
40+
EventFlow.post(new TickEvent.GameLoop.Pre());
41+
}
42+
43+
@Inject(method = "render", at = @At("RETURN"))
44+
void onLoopTickPost(CallbackInfo ci) {
45+
EventFlow.post(new TickEvent.GameLoop.Post());
46+
}
47+
3848
@Inject(at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;info(Ljava/lang/String;)V", shift = At.Shift.AFTER, remap = false), method = "stop")
3949
private void onShutdown(CallbackInfo ci) {
4050
EventFlow.post(new ClientEvent.Shutdown());

common/src/main/kotlin/com/lambda/event/events/TickEvent.kt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,30 @@ import com.lambda.event.events.TickEvent.Pre
1818
*/
1919
abstract class TickEvent : Event {
2020
/**
21-
* A class representing a [TickEvent] that is triggered before each tick of the game loop.
21+
* A class representing a [TickEvent] that is triggered before each tick of the tick loop.
2222
*/
2323
class Pre : TickEvent()
2424

2525
/**
26-
* A class representing a [TickEvent] that is triggered after each tick of the game loop.
26+
* A class representing a [TickEvent] that is triggered after each tick of the tick loop.
2727
*/
2828
class Post : TickEvent()
2929

30+
/**
31+
* A class representing a [TickEvent] that is triggered on each tick of the game loop.
32+
*/
33+
abstract class GameLoop : TickEvent() {
34+
/**
35+
* A class representing a [TickEvent.Player] that is triggered before each tick of the game loop.
36+
*/
37+
class Pre : TickEvent()
38+
39+
/**
40+
* A class representing a [TickEvent.Player] that is triggered after each tick of the game loop.
41+
*/
42+
class Post : TickEvent()
43+
}
44+
3045
/**
3146
* A class representing a [TickEvent] that is triggered when the player gets ticked.
3247
*/

common/src/main/kotlin/com/lambda/module/modules/movement/Blink.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ import com.lambda.util.ClientPacket
1414
import com.lambda.util.PacketUtils.handlePacketSilently
1515
import com.lambda.util.PacketUtils.sendPacketSilently
1616
import com.lambda.util.math.ColorUtils.setAlpha
17+
import com.lambda.util.math.VecUtils.minus
1718
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket
1819
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket
1920
import net.minecraft.util.math.BlockPos
2021
import net.minecraft.util.math.Box
22+
import net.minecraft.util.math.Vec3d
2123
import java.util.concurrent.ConcurrentLinkedDeque
2224

2325
object Blink : Module(
@@ -61,6 +63,16 @@ object Blink : Module(
6163
return@listener
6264
}
6365

66+
listener<PacketEvent.Send.Post> { event ->
67+
val packet = event.packet
68+
if (packet !is PlayerMoveC2SPacket) return@listener
69+
70+
val vec = Vec3d(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0))
71+
if (vec == Vec3d.ZERO) return@listener
72+
73+
lastBox = player.boundingBox.offset(vec - player.pos)
74+
}
75+
6476
listener<PacketEvent.Receive.Pre> { event ->
6577
if (!isActive || !shiftVelocity) return@listener
6678

@@ -81,12 +93,6 @@ object Blink : Module(
8193
while (packetPool.isNotEmpty()) {
8294
packetPool.poll().let { packet ->
8395
connection.sendPacketSilently(packet)
84-
85-
if (packet is PlayerMoveC2SPacket && packet.changesPosition()) {
86-
lastBox = player.boundingBox
87-
.offset(player.pos.negate())
88-
.offset(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0))
89-
}
9096
}
9197
}
9298

common/src/main/kotlin/com/lambda/module/modules/movement/TickShift.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ object TickShift : Module(
2626
private val boostAmount by setting("Boost", 3.0, 1.1..20.0, 0.01)
2727
private val slowdown by setting("Slowdown", 0.35, 0.01..0.9, 0.01)
2828
private val delaySetting by setting("Delay", 0, 0..2000, 10)
29-
private val strict by setting("Strict", true)
30-
private val shiftVelocity by setting("Shift velocity", true)
29+
private val grim by setting("Grim", true)
30+
private val strictSetting by setting("Strict", true) { !grim }
31+
private val shiftVelocity by setting("Shift velocity", true) { grim }
3132
private val requiresAura by setting("Requires Aura", false)
3233

34+
private val strict get() = grim || strictSetting
35+
3336
val isActive: Boolean get() {
3437
if (requiresAura && (!KillAura.isEnabled || KillAura.target == null)) return false
3538
return System.currentTimeMillis() - lastBoost > delaySetting
@@ -90,7 +93,7 @@ object TickShift : Module(
9093
}
9194

9295
listener<PacketEvent.Send.Pre> { event ->
93-
if (!isActive) return@listener
96+
if (!isActive || !grim || event.isCanceled()) return@listener
9497
if (event.packet !is CommonPongC2SPacket) return@listener
9598

9699
pingPool.add(event.packet)
@@ -99,7 +102,7 @@ object TickShift : Module(
99102
}
100103

101104
listener<PacketEvent.Receive.Pre> { event ->
102-
if (!isActive || !shiftVelocity) return@listener
105+
if (!isActive || !grim || !shiftVelocity || event.isCanceled()) return@listener
103106

104107
if (event.packet !is EntityVelocityUpdateS2CPacket) return@listener
105108
if (event.packet.id != player.id) return@listener

0 commit comments

Comments
 (0)