From 479a50a489fc603b3d53e6ba0cc2a55a7db0d054 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Mon, 1 Jan 2024 10:38:07 +1100 Subject: [PATCH] Made thirst sprint prevention configurable --- .../toughasnails/config/ThirstConfig.java | 2 ++ .../thirst/ThirstHooksClient.java | 26 +++---------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/common/src/main/java/toughasnails/config/ThirstConfig.java b/common/src/main/java/toughasnails/config/ThirstConfig.java index 0fa21ff2..ce25d2d8 100644 --- a/common/src/main/java/toughasnails/config/ThirstConfig.java +++ b/common/src/main/java/toughasnails/config/ThirstConfig.java @@ -14,6 +14,7 @@ public class ThirstConfig extends Config { public boolean enableThirst; public boolean enableHandDrinking; + public boolean thirstPreventSprint; public double thirstExhaustionThreshold; public int handDrinkingThirst; public double handDrinkingHydration; @@ -29,6 +30,7 @@ public void load() // Toggles enableThirst = add("toggles.enable_thirst", true, "Enable or disable thirst."); enableHandDrinking = add("toggles.enable_hand_drinking", false, "Enable or disable hand drinking."); + thirstPreventSprint = add("toggles.thirst_prevent_sprint", true, "Prevent sprinting when thirsty."); // General options thirstExhaustionThreshold = addNumber("general.exhaustion_threshold", 8.0D, 0.0D, Double.MAX_VALUE, "The threshold at which exhaustion causes a reduction in hydration and the thirst bar."); diff --git a/common/src/main/java/toughasnails/thirst/ThirstHooksClient.java b/common/src/main/java/toughasnails/thirst/ThirstHooksClient.java index 00dfd61b..1dc890f4 100644 --- a/common/src/main/java/toughasnails/thirst/ThirstHooksClient.java +++ b/common/src/main/java/toughasnails/thirst/ThirstHooksClient.java @@ -7,28 +7,10 @@ import net.minecraft.client.player.LocalPlayer; import net.minecraft.world.entity.player.Player; import toughasnails.api.thirst.ThirstHelper; +import toughasnails.init.ModConfig; -public class ThirstHooksClient { - public static void onAiStep(LocalPlayer player) - { - if (player.isSprinting()) - { - boolean sprintingAllowable = canSprintWithThirst(player); - - if (player.isSwimming()) - { - if (!player.onGround() && !player.input.shiftKeyDown && !sprintingAllowable || !player.isInWater()) - { - player.setSprinting(false); - } - } - else if (!sprintingAllowable) - { - player.setSprinting(false); - } - } - } - +public class ThirstHooksClient +{ public static void onAiStepSetSprinting(LocalPlayer player, boolean sprinting) { // Don't allow sprinting if the player has insufficient thirst @@ -40,6 +22,6 @@ public static void onAiStepSetSprinting(LocalPlayer player, boolean sprinting) private static boolean canSprintWithThirst(LocalPlayer player) { - return ThirstHelper.getThirst(player).getThirst() > 6 || player.getAbilities().mayfly; + return !ModConfig.thirst.thirstPreventSprint || ThirstHelper.getThirst(player).getThirst() > 6 || player.getAbilities().mayfly; } }