From 81a91f83f22c7cbc7c35fd34a3b8c5b07decfb07 Mon Sep 17 00:00:00 2001 From: plulsls Date: Tue, 22 Jun 2021 11:56:13 +0800 Subject: [PATCH] update to 0.2.9; fix #8 --- gradle.properties | 2 +- .../feature/realSneaking/RealSneakingEventHandler.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2869007..af2587e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.17 yarn_mappings=1.17+build.13 loader_version=0.11.6 # Mod Properties -mod_version=0.2.8 +mod_version=0.2.9 maven_group=com.plusls archives_base_name=oh-my-minecraft-client # Dependencies diff --git a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java b/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java index 77fb90b..e61fb1f 100644 --- a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java +++ b/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java @@ -9,12 +9,18 @@ public static void init() { ClientTickEvents.START_CLIENT_TICK.register(RealSneakingEventHandler::preClientTick); } + final private static float MIN_STEP_HEIGHT = 0.001f; + private static float prevStepHeight; + private static void preClientTick(MinecraftClient minecraftClient) { if (minecraftClient.player != null) { + if (minecraftClient.player.stepHeight - MIN_STEP_HEIGHT >= 0.00001) { + prevStepHeight = minecraftClient.player.stepHeight; + } if (Configs.FeatureToggle.REAL_SNEAKING.getBooleanValue() && minecraftClient.player.isSneaking()) { - minecraftClient.player.stepHeight = 0.001f; + minecraftClient.player.stepHeight = MIN_STEP_HEIGHT; } else { - minecraftClient.player.stepHeight = 0.6f; + minecraftClient.player.stepHeight = prevStepHeight; } } }