Skip to content

Commit 61be371

Browse files
committed
Improved velocity and safewalk
1 parent 4a2d128 commit 61be371

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

common/src/main/java/com/lambda/mixin/network/ClientPlayNetworkHandlerMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ public boolean onServerMetadata(ClientPlayNetworkHandler clientPlayNetworkHandle
7474
// this.client.player.setVelocity(this.client.player.getVelocity().add((double)packet.getPlayerVelocityX(), (double)packet.getPlayerVelocityY(), (double)packet.getPlayerVelocityZ()));
7575
@Inject(method = "onExplosion(Lnet/minecraft/network/packet/s2c/play/ExplosionS2CPacket;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V"), cancellable = true)
7676
void injectVelocity(ExplosionS2CPacket packet, CallbackInfo ci) {
77-
if (Velocity.INSTANCE.isEnabled()) ci.cancel();
77+
if (Velocity.getExplosion()) ci.cancel();
7878
}
7979
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import com.lambda.event.events.MovementEvent
2121
import com.lambda.event.listener.SafeListener.Companion.listen
2222
import com.lambda.module.Module
2323
import com.lambda.module.tag.ModuleTag
24+
import com.lambda.util.player.MovementUtils.motionX
25+
import com.lambda.util.player.MovementUtils.motionZ
2426
import net.minecraft.entity.LivingEntity
2527

2628
object SafeWalk : Module(
@@ -46,8 +48,8 @@ object SafeWalk : Module(
4648

4749
private fun LivingEntity.isNearLedge(distance: Double, stepHeight: Double): Boolean {
4850
fun checkDirection(deltaX: Double, deltaZ: Double): Boolean {
49-
var dx = deltaX
50-
var dz = deltaZ
51+
var dx = deltaX + motionX
52+
var dz = deltaZ + motionZ
5153
while (dx != 0.0 || dz != 0.0) {
5254
if (world.isBlockSpaceEmpty(this, boundingBox.offset(dx, -stepHeight, dz))) {
5355
return true

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@
1717

1818
package com.lambda.module.modules.movement
1919

20+
import com.lambda.event.events.PacketEvent
21+
import com.lambda.event.listener.SafeListener.Companion.listen
2022
import com.lambda.module.Module
2123
import com.lambda.module.tag.ModuleTag
24+
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket
2225

2326
object Velocity : Module(
2427
name = "Velocity",
2528
description = "Modifies your velocity",
2629
defaultTags = setOf(ModuleTag.MOVEMENT),
27-
)
30+
) {
31+
private val knockback by setting("Knockback", true)
32+
33+
private val explosionSetting by setting("Explosion", true)
34+
@JvmStatic val explosion get() = isEnabled && explosionSetting
35+
36+
init {
37+
listen<PacketEvent.Receive.Pre> { event ->
38+
if (!knockback) return@listen
39+
if (event.packet !is EntityVelocityUpdateS2CPacket) return@listen
40+
if (event.packet.id != player.id) return@listen
41+
42+
event.cancel()
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)