From 022caf7feb32f7631496c8ce5eeaf95db42d1456 Mon Sep 17 00:00:00 2001 From: Doogie13 Date: Tue, 20 Sep 2022 19:42:59 +0100 Subject: [PATCH 1/4] Rewrite Step entirely --- .../com/lambda/mixin/entity/MixinEntity.java | 53 ++++++ .../client/manager/managers/TimerManager.kt | 2 +- .../client/module/modules/movement/Step.kt | 177 +++++++----------- 3 files changed, 122 insertions(+), 110 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index ef23be53d..ba3c06275 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -1,11 +1,15 @@ package com.lambda.mixin.entity; import com.lambda.client.module.modules.movement.SafeWalk; +import com.lambda.client.module.modules.movement.Step; import com.lambda.client.module.modules.movement.Velocity; import com.lambda.client.module.modules.player.Freecam; import com.lambda.client.module.modules.player.ViewLock; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.MoverType; +import net.minecraft.util.math.AxisAlignedBB; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -17,7 +21,9 @@ public abstract class MixinEntity { @Shadow private int entityId; + @Shadow private AxisAlignedBB boundingBox; private boolean modifiedSneaking = false; + float storedStepHeight = -1; @Inject(method = "applyEntityCollision", at = @At("HEAD"), cancellable = true) public void applyEntityCollisionHead(Entity entityIn, CallbackInfo ci) { @@ -48,4 +54,51 @@ public void turn(float yaw, float pitch, CallbackInfo ci) { if (Freecam.handleTurn(casted, yaw, pitch, ci)) return; ViewLock.handleTurn(casted, yaw, pitch, ci); } + + // this is after we handle XZ movement + @Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.onGround:Z", ordinal = 1)) + private void preStep(MoverType type, double x, double y, double z, CallbackInfo ci) { + + EntityPlayerSP player = Minecraft.getMinecraft().player; + + if (player == null) + return; + + if (entityId == player.getEntityId() && Step.INSTANCE.isEnabled()) { + + if (Step.INSTANCE.pre(boundingBox)) + return; + + storedStepHeight = player.stepHeight; + player.stepHeight = Step.INSTANCE.getStrict() ? 1.015f : Step.INSTANCE.getUpStep().getValue(); + + } + + } + + + // we want the seventh setEntityBoudingBox call and execute the mixin after it's called + /* + Then, shalt thou count to seven. No more. + No less. Seven shalt be the number thou shalt count, + and the number of the counting shall be seven. + Eight shalt thou not count, + nor either count thou Six, + excepting that thou then proceed to Seven. + Nine is right out. + */ + @Inject(method = "move", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.setEntityBoundingBox(Lnet/minecraft/util/math/AxisAlignedBB;)V", ordinal = 7, shift = At.Shift.AFTER)) + private void postStep(MoverType type, double x, double y, double z, CallbackInfo ci) { + + EntityPlayerSP player = Minecraft.getMinecraft().player; + + if (player == null || !Step.INSTANCE.isEnabled()) + return; + + if (entityId == player.getEntityId()) { + Step.INSTANCE.post(boundingBox); + } + + } + } diff --git a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt index e421a039d..676afa6ee 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt @@ -22,7 +22,7 @@ object TimerManager : Manager { init { listener { if (timer.tick(5L)) { - val removeTime = System.currentTimeMillis() - 250L + val removeTime = System.currentTimeMillis() - 500L modifications.values.removeIf { it.second < removeTime } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index f649cf49a..1747d6fc8 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -1,150 +1,109 @@ package com.lambda.client.module.modules.movement -import com.lambda.client.event.SafeClientEvent -import com.lambda.client.event.events.PacketEvent -import com.lambda.client.event.listener.listener -import com.lambda.client.manager.managers.PlayerPacketManager -import com.lambda.client.mixin.extension.playerY +import com.lambda.client.manager.managers.TimerManager.modifyTimer +import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module -import com.lambda.client.module.modules.combat.Surround.inHoleCheck -import com.lambda.client.setting.settings.impl.primitive.BooleanSetting import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.Bind -import com.lambda.client.util.EntityUtils.isInOrAboveLiquid import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener +import net.minecraft.client.Minecraft import net.minecraft.network.play.client.CPacketPlayer -import net.minecraftforge.fml.common.gameevent.InputEvent -import net.minecraftforge.fml.common.gameevent.TickEvent -import org.lwjgl.input.Keyboard +import net.minecraft.util.math.AxisAlignedBB +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent + /** - * The packet mode code is licensed under MIT and can be found here: - * https://github.com/fr1kin/ForgeHax/blob/2011740/src/main/java/com/matt/forgehax/mods/StepMod.java + * @author Doogie13 + * @since 20/09/2022 */ object Step : Module( name = "Step", - description = "Changes the vanilla behavior for stepping up blocks", category = Category.MOVEMENT, - modulePriority = 200 + description = "Allows you to step up blocks", + modulePriority = 201 ) { - private val mode by setting("Mode", Mode.PACKET) - private val upStep = setting("Up Step", true) - private val downStep = setting("Down Step", false) - private val entityStep by setting("Entities", true) - private val checkHole by setting("Check Hole", false) - private val height by setting("Height", 1.0f, 0.25f..2.0f, 0.25f) - private val downSpeed by setting("Down Speed", 0.2f, 0.0f..1.0f, 0.05f) - private val bindUpStep by setting("Bind Up Step", Bind()) - private val bindDownStep by setting("Bind Down Step", Bind()) - - private const val defaultHeight = 0.6f - - private val ignoredPackets = HashSet() - private var lastCollidedTick = 0 - private var onGroundTick = 0 - - @Suppress("UNUSED") + + private val mode by setting("Mode", Mode.NORMAL) + val strict by setting("Strict", false) + val upStep = setting("Step Height", 1f, 1f..2.5f, 2.5f, { !strict }) + private enum class Mode { - VANILLA, PACKET + VANILLA, NORMAL } + var playerY = 0.0 + var timering = false + init { + + upStep.valueListeners.add { _, _ -> + BaritoneUtils.settings?.assumeStep?.value = isEnabled + } + onDisable { + resetTimer() runSafe { - player.apply { - stepHeight = defaultHeight - ridingEntity?.stepHeight = 1.0f - } + player.stepHeight = .6f } - ignoredPackets.clear() } - onToggle { - BaritoneUtils.settings?.assumeStep?.value = it && upStep.value + safeListener { + if (!timering) + resetTimer() + else + timering = !timering } - listener { - val key = Keyboard.getEventKey() + } - if (bindUpStep.isDown(key)) { - upStep.value = !upStep.value - MessageSendHelper.sendChatMessage(upStep.toggleMsg()) - } + fun pre(bb : AxisAlignedBB) : Boolean { - if (bindDownStep.isDown(key)) { - downStep.value = !downStep.value - MessageSendHelper.sendChatMessage(downStep.toggleMsg()) - } - } - } + val player = Minecraft.getMinecraft().player - private fun BooleanSetting.toggleMsg() = "$chatName Turned ${this.name} ${if (this.value) "&aon" else "&coff"}&f!" + if (player.ridingEntity != null) + player.ridingEntity!!.stepHeight = if (strict) 1f else upStep.value - init { - safeListener { - if (it.phase != TickEvent.Phase.START || !shouldRunStep) return@safeListener - setStepHeight() - if (downStep.value && player.motionY <= 0.0 && player.ticksExisted - onGroundTick <= 3) downStep() - if (player.collidedHorizontally) lastCollidedTick = player.ticksExisted - if (player.onGround) onGroundTick = player.ticksExisted - } - } + playerY = bb.minY - private val SafeClientEvent.shouldRunStep: Boolean - get() = !mc.gameSettings.keyBindSneak.isKeyDown - && !player.isElytraFlying - && !player.capabilities.isFlying - && !player.isOnLadder - && !player.isInOrAboveLiquid - && (!checkHole || !inHoleCheck()) - - private fun SafeClientEvent.setStepHeight() { - player.stepHeight = if (upStep.value && player.onGround && player.collidedHorizontally) height else defaultHeight - player.ridingEntity?.let { - it.stepHeight = if (entityStep && it.collidedHorizontally) height else 1.0f - } - } + return player.isInWater || player.isInLava || !player.onGround || player.isOnLadder || player.movementInput.jump || player.fallDistance >= 0.1 - private fun SafeClientEvent.downStep() { - // Down step doesn't work for edge lower than 1 blocks anyways - val belowBB = player.entityBoundingBox.expand(0.0, -1.05, 0.0) - if (world.collidesWithAnyBlock(belowBB)) player.motionY -= downSpeed } - init { - safeListener { event -> - if (!upStep.value || mode != Mode.PACKET || !shouldRunStep) return@safeListener - if (event.packet !is CPacketPlayer || event.packet !is CPacketPlayer.Position && event.packet !is CPacketPlayer.PositionRotation) return@safeListener - if (ignoredPackets.remove(event.packet)) return@safeListener - - val prevPos = PlayerPacketManager.prevServerSidePosition - if (player.ticksExisted - lastCollidedTick <= 5) getStepArray(event.packet.playerY - prevPos.y)?.let { - for (posY in it) { - val packet = CPacketPlayer.Position(prevPos.x, prevPos.y + posY, prevPos.z, true) - ignoredPackets.add(packet) - connection.sendPacket(packet) - } - } - } - } + fun post(bb : AxisAlignedBB) { - private fun getStepArray(diff: Double) = when { - height >= diff && diff in 0.6..1.0 -> stepOne - height >= diff && diff in 1.0..1.5 -> stepOneHalf - height >= diff && diff in 1.5..2.0 -> stepTwo - else -> null - } + if (mode == Mode.VANILLA) + return - private val stepOne = doubleArrayOf(0.41999, 0.75320) - private val stepOneHalf = doubleArrayOf(0.41999, 0.75320, 1.00133, 1.16611, 1.24919, 1.17079) - private val stepTwo = doubleArrayOf(0.42, 0.78, 0.63, 0.51, 0.90, 1.21, 1.45, 1.43) + val player = Minecraft.getMinecraft().player + val connection = Minecraft.getMinecraft().connection?:return + + val height = bb.minY - playerY + + val values = ArrayList() + + if (height > 2.019) values.addAll(listOf(.425, .821, .699, .599, 1.022, 1.372, 1.652, 1.869, 2.019, 1.919)) + else if (height > 1.5) values.addAll(listOf(.42, .78, .63, .51, .9, 1.21, 1.45, 1.43)) + else if (height > 1.015) values.addAll(listOf(.42, .7532, 1.01, 1.093, 1.015)) + else if (height > .6) values.addAll(listOf(.42 * height, .7532 * height)) + + if (strict && height > .6) + values.add(height) + + var i = 0 + + for (v in values) { + + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + v, player.posZ, false)) + i++ + MessageSendHelper.sendChatMessage("$i $v") - init { - upStep.valueListeners.add { _, it -> - BaritoneUtils.settings?.assumeStep?.value = isEnabled && it } + + modifyTimer(50f * (i + 1)) + timering = true + } + } \ No newline at end of file From 3317d20c26abee1b6bd5b6960a823a28fc1c1157 Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+doogie13@users.noreply.github.com> Date: Thu, 26 Jan 2023 17:57:02 +0000 Subject: [PATCH 2/4] Step --- .../com/lambda/mixin/entity/MixinEntity.java | 17 +++------------ .../client/manager/managers/TimerManager.kt | 4 ++-- .../client/module/modules/movement/Step.kt | 21 +++++++++++-------- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index ba3c06275..bd3bcdc28 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -55,8 +55,8 @@ public void turn(float yaw, float pitch, CallbackInfo ci) { ViewLock.handleTurn(casted, yaw, pitch, ci); } - // this is after we handle XZ movement - @Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.onGround:Z", ordinal = 1)) + // these mixins are for step module before and after the step calculations are performed + @Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.stepHeight:F", ordinal = 3, shift = At.Shift.BEFORE)) private void preStep(MoverType type, double x, double y, double z, CallbackInfo ci) { EntityPlayerSP player = Minecraft.getMinecraft().player; @@ -76,18 +76,7 @@ private void preStep(MoverType type, double x, double y, double z, CallbackInfo } - - // we want the seventh setEntityBoudingBox call and execute the mixin after it's called - /* - Then, shalt thou count to seven. No more. - No less. Seven shalt be the number thou shalt count, - and the number of the counting shall be seven. - Eight shalt thou not count, - nor either count thou Six, - excepting that thou then proceed to Seven. - Nine is right out. - */ - @Inject(method = "move", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.setEntityBoundingBox(Lnet/minecraft/util/math/AxisAlignedBB;)V", ordinal = 7, shift = At.Shift.AFTER)) + @Inject(method = "move", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.resetPositionToBB ()V", ordinal = 1, shift = At.Shift.BEFORE)) private void postStep(MoverType type, double x, double y, double z, CallbackInfo ci) { EntityPlayerSP player = Minecraft.getMinecraft().player; diff --git a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt index 676afa6ee..1731c1093 100644 --- a/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt +++ b/src/main/kotlin/com/lambda/client/manager/managers/TimerManager.kt @@ -21,8 +21,8 @@ object TimerManager : Manager { init { listener { - if (timer.tick(5L)) { - val removeTime = System.currentTimeMillis() - 500L + if (timer.tick(6L)) { + val removeTime = System.currentTimeMillis() - 600L modifications.values.removeIf { it.second < removeTime } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index 1747d6fc8..c8c2b2e3a 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -5,7 +5,6 @@ import com.lambda.client.manager.managers.TimerManager.resetTimer import com.lambda.client.module.Category import com.lambda.client.module.Module import com.lambda.client.util.BaritoneUtils -import com.lambda.client.util.text.MessageSendHelper import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.Minecraft @@ -27,7 +26,7 @@ object Step : Module( private val mode by setting("Mode", Mode.NORMAL) val strict by setting("Strict", false) - val upStep = setting("Step Height", 1f, 1f..2.5f, 2.5f, { !strict }) + val upStep = setting("Step Height", 2.5f, 1f..2.5f, .5f, { !strict }) private enum class Mode { VANILLA, NORMAL @@ -50,10 +49,12 @@ object Step : Module( } safeListener { + if (!timering) resetTimer() - else - timering = !timering + + timering = false + } } @@ -76,11 +77,14 @@ object Step : Module( if (mode == Mode.VANILLA) return + val height = bb.minY - playerY + + if (height < .6) + return + val player = Minecraft.getMinecraft().player val connection = Minecraft.getMinecraft().connection?:return - val height = bb.minY - playerY - val values = ArrayList() if (height > 2.019) values.addAll(listOf(.425, .821, .699, .599, 1.022, 1.372, 1.652, 1.869, 2.019, 1.919)) @@ -91,17 +95,16 @@ object Step : Module( if (strict && height > .6) values.add(height) - var i = 0 + var i = 1 for (v in values) { connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + v, player.posZ, false)) i++ - MessageSendHelper.sendChatMessage("$i $v") } - modifyTimer(50f * (i + 1)) + modifyTimer(50f * i) timering = true } From 080ca5cc3cd1509cfb9d02ded43fa773d05c1550 Mon Sep 17 00:00:00 2001 From: Doogie13 <62295632+doogie13@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:40:15 +0000 Subject: [PATCH 3/4] Some minor changes --- .../com/lambda/client/module/modules/movement/Step.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index c8c2b2e3a..cfe7f2155 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -24,17 +24,17 @@ object Step : Module( modulePriority = 201 ) { - private val mode by setting("Mode", Mode.NORMAL) - val strict by setting("Strict", false) - val upStep = setting("Step Height", 2.5f, 1f..2.5f, .5f, { !strict }) + private val mode by setting("Mode", Mode.NCP, description = "Anticheat step bypass") + val strict by setting("Strict", false, description = "Bypass the new UpdatedNCP step checks") + val upStep = setting("Step Height", 2.5f, 1f..2.5f, .5f, { !strict }, description = "How high to step") private enum class Mode { - VANILLA, NORMAL + NCP, VANILLA } var playerY = 0.0 var timering = false - + init { upStep.valueListeners.add { _, _ -> From 4f1774f9e79e368f781ff3b1eacd534cf25089ea Mon Sep 17 00:00:00 2001 From: Constructor Date: Wed, 1 Feb 2023 04:29:53 +0100 Subject: [PATCH 4/4] Cleanup --- .../com/lambda/mixin/entity/MixinEntity.java | 25 +++---- .../client/module/modules/movement/Step.kt | 70 ++++++++----------- 2 files changed, 39 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/lambda/mixin/entity/MixinEntity.java b/src/main/java/com/lambda/mixin/entity/MixinEntity.java index bd3bcdc28..06cc5bd0f 100644 --- a/src/main/java/com/lambda/mixin/entity/MixinEntity.java +++ b/src/main/java/com/lambda/mixin/entity/MixinEntity.java @@ -58,36 +58,29 @@ public void turn(float yaw, float pitch, CallbackInfo ci) { // these mixins are for step module before and after the step calculations are performed @Inject(method = "move", at = @At(value = "FIELD", target = "net/minecraft/entity/Entity.stepHeight:F", ordinal = 3, shift = At.Shift.BEFORE)) private void preStep(MoverType type, double x, double y, double z, CallbackInfo ci) { - EntityPlayerSP player = Minecraft.getMinecraft().player; - if (player == null) - return; - - if (entityId == player.getEntityId() && Step.INSTANCE.isEnabled()) { - - if (Step.INSTANCE.pre(boundingBox)) - return; + if (player == null) return; + if (entityId == player.getEntityId() + && Step.INSTANCE.isEnabled() + && !Step.INSTANCE.pre(boundingBox, player) + ) { storedStepHeight = player.stepHeight; player.stepHeight = Step.INSTANCE.getStrict() ? 1.015f : Step.INSTANCE.getUpStep().getValue(); - } - } @Inject(method = "move", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.resetPositionToBB ()V", ordinal = 1, shift = At.Shift.BEFORE)) private void postStep(MoverType type, double x, double y, double z, CallbackInfo ci) { + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayerSP player = mc.player; - EntityPlayerSP player = Minecraft.getMinecraft().player; - - if (player == null || !Step.INSTANCE.isEnabled()) - return; + if (player == null || !Step.INSTANCE.isEnabled()) return; if (entityId == player.getEntityId()) { - Step.INSTANCE.post(boundingBox); + Step.INSTANCE.post(boundingBox, mc); } - } } diff --git a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt index cfe7f2155..1e874a4e2 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/movement/Step.kt @@ -8,6 +8,7 @@ import com.lambda.client.util.BaritoneUtils import com.lambda.client.util.threads.runSafe import com.lambda.client.util.threads.safeListener import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityPlayerSP import net.minecraft.network.play.client.CPacketPlayer import net.minecraft.util.math.AxisAlignedBB import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent @@ -32,11 +33,10 @@ object Step : Module( NCP, VANILLA } - var playerY = 0.0 - var timering = false + private var playerY = 0.0 + private var timing = false init { - upStep.valueListeners.add { _, _ -> BaritoneUtils.settings?.assumeStep?.value = isEnabled } @@ -49,64 +49,54 @@ object Step : Module( } safeListener { + if (!timing) resetTimer() - if (!timering) - resetTimer() - - timering = false - + timing = false } - } - fun pre(bb : AxisAlignedBB) : Boolean { - - val player = Minecraft.getMinecraft().player - - if (player.ridingEntity != null) - player.ridingEntity!!.stepHeight = if (strict) 1f else upStep.value + fun pre(bb: AxisAlignedBB, player: EntityPlayerSP): Boolean { + player.ridingEntity?.let { + it.stepHeight = if (strict) 1f else upStep.value + } playerY = bb.minY - return player.isInWater || player.isInLava || !player.onGround || player.isOnLadder || player.movementInput.jump || player.fallDistance >= 0.1 - + return player.isInWater + || player.isInLava + || !player.onGround + || player.isOnLadder + || player.movementInput.jump + || player.fallDistance >= 0.1 } - fun post(bb : AxisAlignedBB) { - - if (mode == Mode.VANILLA) - return + fun post(bb: AxisAlignedBB, mc: Minecraft) { + if (mode == Mode.VANILLA) return val height = bb.minY - playerY if (height < .6) return - val player = Minecraft.getMinecraft().player - val connection = Minecraft.getMinecraft().connection?:return + val player = mc.player + val connection = mc.connection ?: return val values = ArrayList() - if (height > 2.019) values.addAll(listOf(.425, .821, .699, .599, 1.022, 1.372, 1.652, 1.869, 2.019, 1.919)) - else if (height > 1.5) values.addAll(listOf(.42, .78, .63, .51, .9, 1.21, 1.45, 1.43)) - else if (height > 1.015) values.addAll(listOf(.42, .7532, 1.01, 1.093, 1.015)) - else if (height > .6) values.addAll(listOf(.42 * height, .7532 * height)) - - if (strict && height > .6) - values.add(height) - - var i = 1 - - for (v in values) { + when { + height > 2.019 -> values.addAll(listOf(.425, .821, .699, .599, 1.022, 1.372, 1.652, 1.869, 2.019, 1.919)) + height > 1.5 -> values.addAll(listOf(.42, .78, .63, .51, .9, 1.21, 1.45, 1.43)) + height > 1.015 -> values.addAll(listOf(.42, .7532, 1.01, 1.093, 1.015)) + height > .6 -> values.addAll(listOf(.42 * height, .7532 * height)) + } - connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + v, player.posZ, false)) - i++ + if (strict && height > .6) values.add(height) + values.forEach { + connection.sendPacket(CPacketPlayer.Position(player.posX, player.posY + it, player.posZ, false)) } - modifyTimer(50f * i) - timering = true - + modifyTimer(50f * values.size) + timing = true } - } \ No newline at end of file