From 142fa63169f27ea928d28636a7c7ddebdcbf1fcb Mon Sep 17 00:00:00 2001 From: ManInMyVan Date: Sun, 3 Nov 2024 20:54:44 -0700 Subject: [PATCH] feat: MotionWhenHurt in KeepSprint --- .../minecraft/entity/MixinPlayerEntity.java | 12 ++++++++++++ .../module/modules/combat/ModuleKeepSprint.kt | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java index 833a02f178d..9b4f1beeb29 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/entity/MixinPlayerEntity.java @@ -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()) { diff --git a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleKeepSprint.kt b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleKeepSprint.kt index c39fa1e8600..f462771a4a3 100644 --- a/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleKeepSprint.kt +++ b/src/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/ModuleKeepSprint.kt @@ -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 @@ -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 { + 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 } }