mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-20 01:12:13 +02:00
Add range sliders to AntiAfkHack
This commit is contained in:
parent
929b375b63
commit
e31f157dce
@ -36,6 +36,21 @@ import net.wurstclient.settings.SliderSetting.ValueDisplay;
|
|||||||
public final class AntiAfkHack extends Hack
|
public final class AntiAfkHack extends Hack
|
||||||
implements UpdateListener, RenderListener
|
implements UpdateListener, RenderListener
|
||||||
{
|
{
|
||||||
|
private final CheckboxSetting useAi = new CheckboxSetting("Use AI",
|
||||||
|
"Uses a pathfinding AI to move around naturally and avoid hazards.\n"
|
||||||
|
+ "Can sometimes get stuck.",
|
||||||
|
true);
|
||||||
|
|
||||||
|
private final SliderSetting aiRange = new SliderSetting("AI range",
|
||||||
|
"The area in which AntiAFK can move when Use AI is turned on.", 16, 1,
|
||||||
|
64, 1, ValueDisplay.AREA_FROM_RADIUS);
|
||||||
|
|
||||||
|
private final SliderSetting nonAiRange = new SliderSetting("Non-AI range",
|
||||||
|
"The area in which AntiAFK can move when Use AI is turned off.\n\n"
|
||||||
|
+ "\u00a7c\u00a7lWARNING:\u00a7r This area must be completely"
|
||||||
|
+ " unobstructed and free of hazards.",
|
||||||
|
1, 1, 64, 1, ValueDisplay.AREA_FROM_RADIUS);
|
||||||
|
|
||||||
private final SliderSetting waitTime =
|
private final SliderSetting waitTime =
|
||||||
new SliderSetting("Wait time", "Time between movements in seconds.",
|
new SliderSetting("Wait time", "Time between movements in seconds.",
|
||||||
2.5, 0, 60, 0.05, ValueDisplay.DECIMAL.withSuffix("s"));
|
2.5, 0, 60, 0.05, ValueDisplay.DECIMAL.withSuffix("s"));
|
||||||
@ -47,11 +62,6 @@ public final class AntiAfkHack extends Hack
|
|||||||
0.5, 0, 60, 0.05,
|
0.5, 0, 60, 0.05,
|
||||||
ValueDisplay.DECIMAL.withPrefix("\u00b1").withSuffix("s"));
|
ValueDisplay.DECIMAL.withPrefix("\u00b1").withSuffix("s"));
|
||||||
|
|
||||||
private final CheckboxSetting useAi = new CheckboxSetting("Use AI",
|
|
||||||
"Uses a pathfinding AI to move around naturally and avoid hazards.\n"
|
|
||||||
+ "Can sometimes get stuck.",
|
|
||||||
true);
|
|
||||||
|
|
||||||
private int timer;
|
private int timer;
|
||||||
private Random random = new Random();
|
private Random random = new Random();
|
||||||
private BlockPos start;
|
private BlockPos start;
|
||||||
@ -67,6 +77,8 @@ public final class AntiAfkHack extends Hack
|
|||||||
|
|
||||||
setCategory(Category.OTHER);
|
setCategory(Category.OTHER);
|
||||||
addSetting(useAi);
|
addSetting(useAi);
|
||||||
|
addSetting(aiRange);
|
||||||
|
addSetting(nonAiRange);
|
||||||
addSetting(waitTime);
|
addSetting(waitTime);
|
||||||
addSetting(waitTimeRand);
|
addSetting(waitTimeRand);
|
||||||
}
|
}
|
||||||
@ -76,7 +88,8 @@ public final class AntiAfkHack extends Hack
|
|||||||
{
|
{
|
||||||
start = BlockPos.ofFloored(MC.player.getPos());
|
start = BlockPos.ofFloored(MC.player.getPos());
|
||||||
nextBlock = null;
|
nextBlock = null;
|
||||||
pathFinder = new RandomPathFinder(start);
|
pathFinder =
|
||||||
|
new RandomPathFinder(randomize(start, aiRange.getValueI(), true));
|
||||||
creativeFlying = MC.player.getAbilities().flying;
|
creativeFlying = MC.player.getAbilities().flying;
|
||||||
|
|
||||||
WURST.getHax().autoFishHack.setEnabled(false);
|
WURST.getHax().autoFishHack.setEnabled(false);
|
||||||
@ -159,7 +172,8 @@ public final class AntiAfkHack extends Hack
|
|||||||
if(!processor.isDone())
|
if(!processor.isDone())
|
||||||
processor.process();
|
processor.process();
|
||||||
else
|
else
|
||||||
pathFinder = new RandomPathFinder(start);
|
pathFinder = new RandomPathFinder(
|
||||||
|
randomize(start, aiRange.getValueI(), true));
|
||||||
|
|
||||||
// wait 2 - 3 seconds (40 - 60 ticks)
|
// wait 2 - 3 seconds (40 - 60 ticks)
|
||||||
if(processor.isDone())
|
if(processor.isDone())
|
||||||
@ -172,8 +186,7 @@ public final class AntiAfkHack extends Hack
|
|||||||
// set next block
|
// set next block
|
||||||
if(timer <= 0 || nextBlock == null)
|
if(timer <= 0 || nextBlock == null)
|
||||||
{
|
{
|
||||||
nextBlock =
|
nextBlock = randomize(start, nonAiRange.getValueI(), false);
|
||||||
start.add(random.nextInt(3) - 1, 0, random.nextInt(3) - 1);
|
|
||||||
setTimer();
|
setTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,12 +221,19 @@ public final class AntiAfkHack extends Hack
|
|||||||
pathCmd.isDepthTest());
|
pathCmd.isDepthTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockPos randomize(BlockPos pos, int range, boolean includeY)
|
||||||
|
{
|
||||||
|
int x = random.nextInt(2 * range + 1) - range;
|
||||||
|
int y = includeY ? random.nextInt(2 * range + 1) - range : 0;
|
||||||
|
int z = random.nextInt(2 * range + 1) - range;
|
||||||
|
return pos.add(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
private class RandomPathFinder extends PathFinder
|
private class RandomPathFinder extends PathFinder
|
||||||
{
|
{
|
||||||
public RandomPathFinder(BlockPos goal)
|
public RandomPathFinder(BlockPos goal)
|
||||||
{
|
{
|
||||||
super(goal.add(random.nextInt(33) - 16, random.nextInt(33) - 16,
|
super(goal);
|
||||||
random.nextInt(33) - 16));
|
|
||||||
setThinkTime(10);
|
setThinkTime(10);
|
||||||
setFallingAllowed(false);
|
setFallingAllowed(false);
|
||||||
setDivingAllowed(false);
|
setDivingAllowed(false);
|
||||||
|
@ -326,6 +326,16 @@ public class SliderSetting extends Setting implements SliderLock
|
|||||||
public static final ValueDisplay ROUNDING_PRECISION =
|
public static final ValueDisplay ROUNDING_PRECISION =
|
||||||
v -> (int)v == 0 ? "1" : "0." + "0".repeat((int)v - 1) + "1";
|
v -> (int)v == 0 ? "1" : "0." + "0".repeat((int)v - 1) + "1";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Treats the stored value as a radius from the center block and
|
||||||
|
* displays the resulting area. For example, a value of 1 will display
|
||||||
|
* "3x3", 2 will display "5x5", and so on.
|
||||||
|
*/
|
||||||
|
public static final ValueDisplay AREA_FROM_RADIUS = v -> {
|
||||||
|
int d = 2 * (int)v + 1;
|
||||||
|
return d + "x" + d;
|
||||||
|
};
|
||||||
|
|
||||||
public static final ValueDisplay NONE = v -> "";
|
public static final ValueDisplay NONE = v -> "";
|
||||||
|
|
||||||
public String getValueString(double value);
|
public String getValueString(double value);
|
||||||
|
Loading…
Reference in New Issue
Block a user