Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MotionWhenHurt in KeepSprint #4342

Open
wants to merge 2 commits into
base: nextgen
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
ManInMyVan marked this conversation as resolved.
Show resolved Hide resolved
}

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 = player.isSprinting
}

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