Skip to content

Commit

Permalink
feat: MotionWhenHurt in KeepSprint
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInMyVan committed Dec 7, 2024
1 parent 665d6b7 commit 142fa63
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,27 @@ private Vec3d hookSlowVelocity(Vec3d instance, double x, double y, double z) {
return instance.multiply(x, y, z);
}

@SuppressWarnings("UnreachableCode")
@WrapWithCondition(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;setSprinting(Z)V", ordinal = 0))
private boolean hookSlowVelocity(PlayerEntity instance, boolean b) {
if ((Object) this == MinecraftClient.getInstance().player) {
ModuleKeepSprint.INSTANCE.setSprinting(b);
return !ModuleKeepSprint.INSTANCE.getRunning() || b;
}

return true;
}

@SuppressWarnings({"UnreachableCode", "ConstantValue"})
@ModifyExpressionValue(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSprinting()Z"))
private boolean hookSlowVelocity(boolean original) {
if ((Object) this == MinecraftClient.getInstance().player && ModuleKeepSprint.INSTANCE.getRunning()) {
return ModuleKeepSprint.INSTANCE.getSprinting();
}

return original;
}

@ModifyReturnValue(method = "getEntityInteractionRange", at = @At("RETURN"))
private double hookEntityInteractionRange(double original) {
if ((Object) this == MinecraftClient.getInstance().player && ModuleReach.INSTANCE.getRunning()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package net.ccbluex.liquidbounce.features.module.modules.combat

import net.ccbluex.liquidbounce.event.events.PlayerPostTickEvent
import net.ccbluex.liquidbounce.event.handler
import net.ccbluex.liquidbounce.features.module.Category
import net.ccbluex.liquidbounce.features.module.ClientModule
import net.ccbluex.liquidbounce.utils.kotlin.random
Expand All @@ -30,8 +32,21 @@ import net.ccbluex.liquidbounce.utils.kotlin.random
*/
object ModuleKeepSprint : ClientModule("KeepSprint", Category.COMBAT) {
private val motion by floatRange("Motion", 100f..100f, 0f..100f, "%")
private val motionWhenHurt by floatRange("MotionWhenHurt", 100f..100f, 0f..100f, "%")
private val hurtTicks by intRange("HurtTicks", 1..10, 1..10)

// prevents getting slowed multiple times in a tick (without knockback item)
var sprinting = false

@Suppress("unused")
private val postTickHandler = handler<PlayerPostTickEvent> {
sprinting = mc.player?.isSprinting ?: false
}

fun getMotion(): Double {
return motion.random() / 100.0
return when {
mc.player?.hurtTime in hurtTicks -> motionWhenHurt
else -> motion
}.random() / 100.0
}
}

0 comments on commit 142fa63

Please sign in to comment.