-
-
Notifications
You must be signed in to change notification settings - Fork 417
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
1 parent
d6fb0d3
commit 4c74e1e
Showing
2 changed files
with
73 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2014-2024 Wurst-Imperium and contributors. | ||
* | ||
* This source code is subject to the terms of the GNU General Public | ||
* License, version 3. If a copy of the GPL was not distributed with this | ||
* file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt | ||
*/ | ||
package net.wurstclient.test; | ||
|
||
import static net.wurstclient.test.WurstClientTestHelper.*; | ||
|
||
import java.time.Duration; | ||
|
||
import net.minecraft.client.option.Perspective; | ||
|
||
public enum NoFallHackTest | ||
{ | ||
; | ||
|
||
public static void testNoFallHack() | ||
{ | ||
System.out.println("Testing NoFall hack"); | ||
setPerspective(Perspective.THIRD_PERSON_BACK); | ||
runChatCommand("gamemode survival"); | ||
assertOnGround(); | ||
assertPlayerHealth(20); | ||
|
||
// Fall 10 blocks with NoFall enabled | ||
runWurstCommand("t NoFall on"); | ||
runChatCommand("tp ~ ~10 ~"); | ||
waitUntil("player is on ground", mc -> mc.player.isOnGround()); | ||
waitForWorldTicks(1); | ||
takeScreenshot("nofall_on_10_blocks", Duration.ZERO); | ||
assertPlayerHealth(20); | ||
|
||
// Fall 10 blocks with NoFall disabled | ||
runWurstCommand("t NoFall off"); | ||
runChatCommand("tp ~ ~10 ~"); | ||
waitUntil("player is on ground", mc -> mc.player.isOnGround()); | ||
waitForWorldTicks(1); | ||
takeScreenshot("nofall_off_10_blocks", Duration.ZERO); | ||
assertPlayerHealth(13); | ||
|
||
// Clean up | ||
submitAndWait(mc -> mc.player.heal(20)); | ||
runChatCommand("gamemode creative"); | ||
setPerspective(Perspective.FIRST_PERSON); | ||
} | ||
|
||
private static void assertOnGround() | ||
{ | ||
if(!submitAndGet(mc -> mc.player.isOnGround())) | ||
throw new RuntimeException("Player is not on ground"); | ||
} | ||
|
||
private static void assertPlayerHealth(float expectedHealth) | ||
{ | ||
float actualHealth = submitAndGet(mc -> mc.player.getHealth()); | ||
if(actualHealth != expectedHealth) | ||
throw new RuntimeException("Player's health is wrong. Expected: " | ||
+ expectedHealth + ", actual: " + actualHealth); | ||
} | ||
} |
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