mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-19 17:02:13 +02:00
parent
a7b0d718f1
commit
c331277210
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.wurstclient.event.Event;
|
||||
import net.wurstclient.event.Listener;
|
||||
|
||||
/**
|
||||
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
|
||||
* This is the ideal time to simulate mouse and keyboard input.
|
||||
*/
|
||||
public interface HandleInputListener extends Listener
|
||||
{
|
||||
/**
|
||||
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
|
||||
* This is the ideal time to simulate mouse and keyboard input.
|
||||
*/
|
||||
public void onHandleInput();
|
||||
|
||||
/**
|
||||
* Fired at the beginning of {@link MinecraftClient#handleInputEvents()}.
|
||||
* This is the ideal time to simulate mouse and keyboard input.
|
||||
*/
|
||||
public static class HandleInputEvent extends Event<HandleInputListener>
|
||||
{
|
||||
public static final HandleInputEvent INSTANCE = new HandleInputEvent();
|
||||
|
||||
@Override
|
||||
public void fire(ArrayList<HandleInputListener> listeners)
|
||||
{
|
||||
for(HandleInputListener listener : listeners)
|
||||
listener.onHandleInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<HandleInputListener> getListenerType()
|
||||
{
|
||||
return HandleInputListener.class;
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.wurstclient.Category;
|
||||
import net.wurstclient.SearchTags;
|
||||
import net.wurstclient.events.PostMotionListener;
|
||||
import net.wurstclient.events.HandleInputListener;
|
||||
import net.wurstclient.events.PreMotionListener;
|
||||
import net.wurstclient.hack.Hack;
|
||||
import net.wurstclient.mixinterface.IKeyBinding;
|
||||
@ -30,7 +30,7 @@ import net.wurstclient.util.EntityUtils;
|
||||
@SearchTags({"trigger bot", "AutoAttack", "auto attack", "AutoClicker",
|
||||
"auto clicker"})
|
||||
public final class TriggerBotHack extends Hack
|
||||
implements PreMotionListener, PostMotionListener
|
||||
implements PreMotionListener, HandleInputListener
|
||||
{
|
||||
private final SliderSetting range =
|
||||
new SliderSetting("Range", 4.25, 1, 6, 0.05, ValueDisplay.DECIMAL);
|
||||
@ -38,6 +38,15 @@ public final class TriggerBotHack extends Hack
|
||||
private final AttackSpeedSliderSetting speed =
|
||||
new AttackSpeedSliderSetting();
|
||||
|
||||
private final SliderSetting speedRandMS =
|
||||
new SliderSetting("Speed randomization",
|
||||
"Helps you bypass anti-cheat plugins by varying the delay between"
|
||||
+ " attacks.\n\n" + "\u00b1100ms is recommended for Vulcan.\n\n"
|
||||
+ "0 (off) is fine for NoCheat+, AAC, Grim, Verus, Spartan, and"
|
||||
+ " vanilla servers.",
|
||||
100, 0, 1000, 50, ValueDisplay.INTEGER.withPrefix("\u00b1")
|
||||
.withSuffix("ms").withLabel(0, "off"));
|
||||
|
||||
private final SwingHandSetting swingHand = new SwingHandSetting(
|
||||
"How TriggerBot should swing your hand when attacking.\n\n"
|
||||
+ "This setting will be ignored if \"Simulate mouse click\" is"
|
||||
@ -75,6 +84,7 @@ public final class TriggerBotHack extends Hack
|
||||
|
||||
addSetting(range);
|
||||
addSetting(speed);
|
||||
addSetting(speedRandMS);
|
||||
addSetting(swingHand);
|
||||
addSetting(attackWhileBlocking);
|
||||
addSetting(simulateMouseClick);
|
||||
@ -95,9 +105,9 @@ public final class TriggerBotHack extends Hack
|
||||
WURST.getHax().protectHack.setEnabled(false);
|
||||
WURST.getHax().tpAuraHack.setEnabled(false);
|
||||
|
||||
speed.resetTimer();
|
||||
speed.resetTimer(speedRandMS.getValue());
|
||||
EVENTS.add(PreMotionListener.class, this);
|
||||
EVENTS.add(PostMotionListener.class, this);
|
||||
EVENTS.add(HandleInputListener.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,7 +120,7 @@ public final class TriggerBotHack extends Hack
|
||||
}
|
||||
|
||||
EVENTS.remove(PreMotionListener.class, this);
|
||||
EVENTS.remove(PostMotionListener.class, this);
|
||||
EVENTS.remove(HandleInputListener.class, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,7 +134,7 @@ public final class TriggerBotHack extends Hack
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostMotion()
|
||||
public void onHandleInput()
|
||||
{
|
||||
speed.updateTimer();
|
||||
if(!speed.isTimeToAttack())
|
||||
@ -160,7 +170,7 @@ public final class TriggerBotHack extends Hack
|
||||
swingHand.swing(Hand.MAIN_HAND);
|
||||
}
|
||||
|
||||
speed.resetTimer();
|
||||
speed.resetTimer(speedRandMS.getValue());
|
||||
}
|
||||
|
||||
private boolean isCorrectEntity(Entity entity)
|
||||
|
@ -34,6 +34,7 @@ import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
import net.wurstclient.WurstClient;
|
||||
import net.wurstclient.event.EventManager;
|
||||
import net.wurstclient.events.HandleInputListener.HandleInputEvent;
|
||||
import net.wurstclient.events.LeftClickListener.LeftClickEvent;
|
||||
import net.wurstclient.events.RightClickListener.RightClickEvent;
|
||||
import net.wurstclient.mixinterface.IClientPlayerEntity;
|
||||
@ -64,6 +65,12 @@ public abstract class MinecraftClientMixin
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "handleInputEvents()V")
|
||||
private void onHandleInputEvents(CallbackInfo ci)
|
||||
{
|
||||
EventManager.fire(HandleInputEvent.INSTANCE);
|
||||
}
|
||||
|
||||
@Inject(at = @At(value = "FIELD",
|
||||
target = "Lnet/minecraft/client/MinecraftClient;crosshairTarget:Lnet/minecraft/util/hit/HitResult;",
|
||||
ordinal = 0), method = "doAttack()Z", cancellable = true)
|
||||
|
@ -7,10 +7,12 @@
|
||||
*/
|
||||
package net.wurstclient.settings;
|
||||
|
||||
import net.minecraft.util.math.random.Random;
|
||||
import net.wurstclient.WurstClient;
|
||||
|
||||
public final class AttackSpeedSliderSetting extends SliderSetting
|
||||
{
|
||||
private final Random random = Random.createLocal();
|
||||
private int tickTimer;
|
||||
|
||||
public AttackSpeedSliderSetting()
|
||||
@ -35,19 +37,43 @@ public final class AttackSpeedSliderSetting extends SliderSetting
|
||||
|
||||
public void resetTimer()
|
||||
{
|
||||
tickTimer = 0;
|
||||
double value = getValue();
|
||||
if(value <= 0)
|
||||
tickTimer = -1;
|
||||
else
|
||||
tickTimer = (int)(1000 / value);
|
||||
}
|
||||
|
||||
public void resetTimer(double maxRandMS)
|
||||
{
|
||||
if(maxRandMS <= 0)
|
||||
{
|
||||
resetTimer();
|
||||
return;
|
||||
}
|
||||
|
||||
double value = getValue();
|
||||
double rand = random.nextGaussian();
|
||||
int randOffset = (int)(rand * maxRandMS);
|
||||
|
||||
if(value <= 0)
|
||||
tickTimer = randOffset;
|
||||
else
|
||||
tickTimer = (int)(1000 / value) + randOffset;
|
||||
}
|
||||
|
||||
public void updateTimer()
|
||||
{
|
||||
tickTimer += 50;
|
||||
if(tickTimer >= 0)
|
||||
tickTimer -= 50;
|
||||
}
|
||||
|
||||
public boolean isTimeToAttack()
|
||||
{
|
||||
if(getValue() > 0)
|
||||
return tickTimer >= 1000 / getValue();
|
||||
double value = getValue();
|
||||
if(value <= 0 && WurstClient.MC.player.getAttackCooldownProgress(0) < 1)
|
||||
return false;
|
||||
|
||||
return WurstClient.MC.player.getAttackCooldownProgress(0) >= 1;
|
||||
return tickTimer <= 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user