From 138faa47445c8bc1bac5b6ee8824bda6f3ef1c4b Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Mon, 20 May 2024 12:59:12 +0200 Subject: [PATCH] Update AutoLeave --- .../net/wurstclient/hacks/AutoLeaveHack.java | 64 +++++++------------ 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/src/main/java/net/wurstclient/hacks/AutoLeaveHack.java b/src/main/java/net/wurstclient/hacks/AutoLeaveHack.java index a94837aa..8d9d896a 100644 --- a/src/main/java/net/wurstclient/hacks/AutoLeaveHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoLeaveHack.java @@ -11,7 +11,6 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.Items; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.events.UpdateListener; @@ -32,11 +31,12 @@ public final class AutoLeaveHack extends Hack implements UpdateListener public final EnumSetting mode = new EnumSetting<>("Mode", "\u00a7lQuit\u00a7r mode just quits the game normally.\n" + "Bypasses NoCheat+ but not CombatLog.\n\n" - + "\u00a7lChars\u00a7r mode sends a special chat message that causes the server to kick you.\n" + + "\u00a7lChars\u00a7r mode sends a special chat message that" + + " causes the server to kick you.\n" + "Bypasses NoCheat+ and some versions of CombatLog.\n\n" - + "\u00a7lTP\u00a7r mode teleports you to an invalid location, causing the server to kick you.\n" - + "Bypasses CombatLog, but not NoCheat+.\n\n" - + "\u00a7lSelfHurt\u00a7r mode sends the packet for attacking another player, but with yourself as both the attacker and the target. This causes the server to kick you.\n" + + "\u00a7lSelfHurt\u00a7r mode sends the packet for attacking" + + " another player, but with yourself as both the attacker and the" + + " target, causing the server to kick you.\n" + "Bypasses both CombatLog and NoCheat+.", Mode.values(), Mode.QUIT); @@ -46,10 +46,11 @@ public final class AutoLeaveHack extends Hack implements UpdateListener true); private final SliderSetting totems = new SliderSetting("Totems", - "Effectively disables AutoLeave until the number of totems you have is at or below this value.\n" - + "Drag the slider to the right to turn off this feature.", - 11, 0, 11, 1, - ValueDisplay.INTEGER.withSuffix(" totems").withLabel(11, "unlimited")); + "Won't leave the server until the number of totems you have reaches" + + " this value or falls below it.\n\n" + + "11 = always able to leave", + 11, 0, 11, 1, ValueDisplay.INTEGER.withSuffix(" totems") + .withLabel(1, "1 totem").withLabel(11, "ignore")); public AutoLeaveHack() { @@ -64,6 +65,9 @@ public final class AutoLeaveHack extends Hack implements UpdateListener @Override public String getRenderName() { + if(MC.player.getAbilities().creativeMode) + return getName() + " (paused)"; + return getName() + " [" + mode.getSelected() + "]"; } @@ -86,11 +90,6 @@ public final class AutoLeaveHack extends Hack implements UpdateListener if(MC.player.getAbilities().creativeMode) return; - // check for other players - if(MC.isInSingleplayer() - && MC.player.networkHandler.getPlayerList().size() == 1) - return; - // check health float currentHealth = MC.player.getHealth(); if(currentHealth <= 0F || currentHealth > health.getValueF() * 2F) @@ -101,27 +100,7 @@ public final class AutoLeaveHack extends Hack implements UpdateListener return; // leave server - switch(mode.getSelected()) - { - case QUIT: - MC.world.disconnect(); - break; - - case CHARS: - MC.getNetworkHandler().sendChatMessage("\u00a7"); - break; - - case TELEPORT: - MC.player.networkHandler - .sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(3.1e7, - 100, 3.1e7, false)); - break; - - case SELFHURT: - MC.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket - .attack(MC.player, MC.player.isSneaking())); - break; - } + mode.getSelected().leave.run(); // disable setEnabled(false); @@ -148,19 +127,22 @@ public final class AutoLeaveHack extends Hack implements UpdateListener public static enum Mode { - QUIT("Quit"), + QUIT("Quit", () -> MC.world.disconnect()), - CHARS("Chars"), + CHARS("Chars", () -> MC.getNetworkHandler().sendChatMessage("\u00a7")), - TELEPORT("TP"), - - SELFHURT("SelfHurt"); + SELFHURT("SelfHurt", + () -> MC.getNetworkHandler() + .sendPacket(PlayerInteractEntityC2SPacket.attack(MC.player, + MC.player.isSneaking()))); private final String name; + private final Runnable leave; - private Mode(String name) + private Mode(String name, Runnable leave) { this.name = name; + this.leave = leave; } @Override