-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
131 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
common/src/main/java/toughasnails/thirst/ThirstHooksClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************* | ||
* Copyright 2023, the Glitchfiend Team. | ||
* All rights reserved. | ||
******************************************************************************/ | ||
package toughasnails.thirst; | ||
|
||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
import toughasnails.api.thirst.ThirstHelper; | ||
|
||
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 static void onAiStepSetSprinting(LocalPlayer player, boolean sprinting) | ||
{ | ||
// Don't allow sprinting if the player has insufficient thirst | ||
if (sprinting && !canSprintWithThirst(player)) | ||
sprinting = false; | ||
|
||
player.setSprinting(sprinting); | ||
} | ||
|
||
private static boolean canSprintWithThirst(LocalPlayer player) | ||
{ | ||
return ThirstHelper.getThirst(player).getThirst() > 6 || player.getAbilities().mayfly; | ||
} | ||
} |
Oops, something went wrong.