Skip to content

Commit

Permalink
Merge branch 'master' into fakeplayer-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 authored Dec 29, 2024
2 parents 5285aed + 531549c commit c2c0e8b
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ jobs:
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY
echo "Imgur upload response for $filename: $response"
fi
fi
done
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ org.gradle.parallel=true
# check these at https://fabricmc.net/develop/ and
# https://modrinth.com/mod/fabric-api/versions
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.2
yarn_mappings=1.21.4+build.4
loader_version=0.16.9

# Fabric API
fabric_version=0.112.0+1.21.4
fabric_version=0.113.0+1.21.4

# Mod Properties
mod_version = v7.46.5-MC1.21.4
mod_version = v7.46.6-MC1.21.4
maven_group = net.wurstclient
archives_base_name = Wurst-Client

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/WurstClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public enum WurstClient
public static MinecraftClient MC;
public static IMinecraftClient IMC;

public static final String VERSION = "7.46.5";
public static final String VERSION = "7.46.6";
public static final String MC_VERSION = "1.21.4";

private WurstAnalytics analytics;
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/net/wurstclient/test/AutoMineHackTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 net.minecraft.block.Blocks;

public enum AutoMineHackTest
{
;

public static void testAutoMineHack()
{
System.out.println("Testing AutoMine hack");
runChatCommand("gamemode survival");

// Break a dirt block in survival mode
runChatCommand("setblock ~ ~1 ~2 minecraft:dirt");
waitForBlock(0, 1, 2, Blocks.DIRT);
runWurstCommand("t AutoMine on");
waitForBlock(0, 1, 2, Blocks.AIR);
takeScreenshot("automine_survival");

// Clean up
runWurstCommand("t AutoMine off");
runChatCommand("gamemode creative");
runChatCommand("kill @e[type=item]");
runChatCommand("clear");
clearChat();
}
}
50 changes: 50 additions & 0 deletions src/main/java/net/wurstclient/test/FreecamHackTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.wurstclient.mixinterface.IKeyBinding;

public enum FreecamHackTest
{
;

public static void testFreecamHack()
{
System.out.println("Testing Freecam hack");

// Enable Freecam with default settings
runWurstCommand("setcheckbox Freecam tracer off");
runWurstCommand("t Freecam on");
takeScreenshot("freecam_default", Duration.ofMillis(100));
clearChat();

// Press shift to fly down a bit
submitAndWait(
mc -> IKeyBinding.get(mc.options.sneakKey).simulatePress(true));
waitForWorldTicks(5);
submitAndWait(
mc -> IKeyBinding.get(mc.options.sneakKey).simulatePress(false));
takeScreenshot("freecam_down", Duration.ofMillis(300));
clearChat();

// Tracer
runWurstCommand("setcheckbox Freecam tracer on");
takeScreenshot("freecam_tracer", Duration.ofMillis(100));
clearChat();

// Clean up
runWurstCommand("setcheckbox Freecam tracer off");
runWurstCommand("t Freecam off");
waitForWorldTicks(5);
clearChat();
}
}
6 changes: 3 additions & 3 deletions src/main/java/net/wurstclient/test/NoFallHackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private static void assertOnGround()
private static void assertPlayerHealth(Predicate<Float> healthCheck)
{
float health = submitAndGet(mc -> mc.player.getHealth());
if(healthCheck.test(health))
System.out.println("Player's health is correct: " + health);
else
if(!healthCheck.test(health))
throw new RuntimeException("Player's health is wrong: " + health);

System.out.println("Player's health is correct: " + health);
}
}
42 changes: 42 additions & 0 deletions src/main/java/net/wurstclient/test/PistonTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 net.minecraft.block.Blocks;

public enum PistonTest
{
;

public static void testPistonDoesntCrash()
{
System.out.println(
"Testing that a piston can extend and retract without crashing the game");

// Place a redstone block and piston
runChatCommand("setblock ~ ~1 ~2 minecraft:piston[facing=up]");
waitForBlock(0, 1, 2, Blocks.PISTON);
runChatCommand("setblock ~ ~ ~2 minecraft:redstone_block");
waitForBlock(0, 0, 2, Blocks.REDSTONE_BLOCK);
takeScreenshot("piston_extending");
waitForWorldTicks(3);

// Destroy the redstone block
runChatCommand("setblock ~ ~ ~2 minecraft:air");
waitForBlock(0, 0, 2, Blocks.AIR);
takeScreenshot("piston_retracting");
waitForWorldTicks(3);

// Clean up
runChatCommand("setblock ~ ~1 ~2 minecraft:air");
waitForBlock(0, 1, 2, Blocks.AIR);
clearChat();
}
}
14 changes: 13 additions & 1 deletion src/main/java/net/wurstclient/test/WurstClientTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.mojang.brigadier.exceptions.CommandSyntaxException;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.GameMenuScreen;
Expand All @@ -37,6 +38,7 @@
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.wurstclient.WurstClient;

public enum WurstClientTestHelper
Expand Down Expand Up @@ -103,7 +105,7 @@ public static void waitUntil(String event,
break;
}

if(startTime.isAfter(timeout))
if(LocalDateTime.now().isAfter(timeout))
throw new RuntimeException(
"Waiting until " + event + " took too long");

Expand Down Expand Up @@ -169,6 +171,16 @@ public static void waitForWorldTicks(int ticks)
Duration.ofMillis(ticks * 100).plusMinutes(5));
}

public static void waitForBlock(int relX, int relY, int relZ, Block block)
{
BlockPos pos =
submitAndGet(mc -> mc.player.getBlockPos().add(relX, relY, relZ));
waitUntil(
"block at ~" + relX + " ~" + relY + " ~" + relZ + " ("
+ pos.toShortString() + ") is " + block,
mc -> mc.world.getBlockState(pos).getBlock() == block);
}

/**
* Waits for 50ms and then takes a screenshot with the given name.
*/
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/net/wurstclient/test/WurstE2ETestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,19 @@ private void runTests()
// TODO: Open ClickGUI and Navigator

// Build a test platform and clear out the space above it
runChatCommand("fill ~-5 ~-1 ~-5 ~5 ~-1 ~5 stone");
runChatCommand("fill ~-5 ~ ~-5 ~5 ~30 ~5 air");
runChatCommand("fill ~-7 ~-5 ~-7 ~7 ~-1 ~7 stone");
runChatCommand("fill ~-7 ~ ~-7 ~7 ~30 ~7 air");
runChatCommand("kill @e[type=!player,distance=..10]");

// Clear inventory and chat before running tests
runChatCommand("clear");
clearChat();

// Test Wurst hacks
AutoMineHackTest.testAutoMineHack();
FreecamHackTest.testFreecamHack();
NoFallHackTest.testNoFallHack();
XRayHackTest.testXRayHack();

// Test Wurst commands
CopyItemCmdTest.testCopyItemCmd();
Expand All @@ -127,6 +131,9 @@ private void runTests()

// TODO: Test more Wurst features

// Test special cases
PistonTest.testPistonDoesntCrash();

System.out.println("Opening game menu");
openGameMenu();
takeScreenshot("game_menu");
Expand Down
92 changes: 92 additions & 0 deletions src/main/java/net/wurstclient/test/XRayHackTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* 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;

public enum XRayHackTest
{
;

public static void testXRayHack()
{
System.out.println("Testing X-Ray hack");
buildTestRig();
clearChat();

// Enable X-Ray with default settings
runWurstCommand("setcheckbox X-Ray only_show_exposed off");
runWurstCommand("setslider X-Ray opacity 0");
runWurstCommand("t X-Ray on");
takeScreenshot("xray_default", Duration.ofMillis(300));
runWurstCommand("t X-Ray off");
clearChat();

// Exposed only
runWurstCommand("setcheckbox X-Ray only_show_exposed on");
runWurstCommand("setslider X-Ray opacity 0");
runWurstCommand("t X-Ray on");
takeScreenshot("xray_exposed_only", Duration.ofMillis(300));
runWurstCommand("t X-Ray off");
clearChat();

// Opacity mode
runWurstCommand("setcheckbox X-Ray only_show_exposed off");
runWurstCommand("setslider X-Ray opacity 0.5");
runWurstCommand("t X-Ray on");
takeScreenshot("xray_opacity", Duration.ofMillis(300));
runWurstCommand("t X-Ray off");
clearChat();

// Exposed only + opacity
runWurstCommand("setcheckbox X-Ray only_show_exposed on");
runWurstCommand("setslider X-Ray opacity 0.5");
runWurstCommand("t X-Ray on");
takeScreenshot("xray_exposed_only_opacity", Duration.ofMillis(300));
runWurstCommand("t X-Ray off");
clearChat();

// Clean up
runChatCommand("fill ~-7 ~ ~-7 ~7 ~30 ~7 air");
runWurstCommand("setcheckbox X-Ray only_show_exposed off");
runWurstCommand("setslider X-Ray opacity 0");
runWurstCommand("t X-Ray off");
clearChat();
}

private static void buildTestRig()
{
runChatCommand("fill ~-5 ~ ~5 ~5 ~5 ~7 stone");

// Hidden ores
runChatCommand("setblock ~-4 ~1 ~6 minecraft:coal_ore");
runChatCommand("setblock ~-2 ~1 ~6 minecraft:iron_ore");
runChatCommand("setblock ~0 ~1 ~6 minecraft:gold_ore");
runChatCommand("setblock ~2 ~1 ~6 minecraft:diamond_ore");
runChatCommand("setblock ~4 ~1 ~6 minecraft:emerald_ore");
runChatCommand("setblock ~-4 ~3 ~6 minecraft:lapis_ore");
runChatCommand("setblock ~-2 ~3 ~6 minecraft:redstone_ore");
runChatCommand("setblock ~0 ~3 ~6 minecraft:copper_ore");
runChatCommand("setblock ~2 ~3 ~6 minecraft:nether_gold_ore");
runChatCommand("setblock ~4 ~3 ~6 minecraft:nether_quartz_ore");

// Partially exposed ores (air block in front)
runChatCommand("setblock ~-4 ~1 ~5 minecraft:coal_ore");
runChatCommand("setblock ~-2 ~1 ~5 minecraft:iron_ore");
runChatCommand("setblock ~0 ~1 ~5 minecraft:gold_ore");
runChatCommand("setblock ~2 ~1 ~5 minecraft:diamond_ore");
runChatCommand("setblock ~4 ~1 ~5 minecraft:emerald_ore");
runChatCommand("setblock ~-4 ~3 ~5 minecraft:lapis_ore");
runChatCommand("setblock ~-2 ~3 ~5 minecraft:redstone_ore");
runChatCommand("setblock ~0 ~3 ~5 minecraft:copper_ore");
runChatCommand("setblock ~2 ~3 ~5 minecraft:nether_gold_ore");
runChatCommand("setblock ~4 ~3 ~5 minecraft:nether_quartz_ore");
}
}

0 comments on commit c2c0e8b

Please sign in to comment.