Implements #10 and an attempt to unspaghettify Confuse
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
package cloudburst.rejects.modules;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cloudburst.rejects.MeteorRejectsAddon;
|
||||
import meteordevelopment.meteorclient.events.render.Render3DEvent;
|
||||
import meteordevelopment.meteorclient.events.world.TickEvent;
|
||||
import meteordevelopment.meteorclient.settings.*;
|
||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||
import meteordevelopment.meteorclient.utils.Utils;
|
||||
import meteordevelopment.meteorclient.utils.entity.SortPriority;
|
||||
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
|
||||
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
|
||||
import meteordevelopment.meteorclient.utils.render.color.Color;
|
||||
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.RaycastContext;
|
||||
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import meteordevelopment.meteorclient.events.render.Render3DEvent;
|
||||
import meteordevelopment.meteorclient.events.world.TickEvent;
|
||||
import meteordevelopment.meteorclient.settings.BoolSetting;
|
||||
import meteordevelopment.meteorclient.settings.EnumSetting;
|
||||
import meteordevelopment.meteorclient.settings.IntSetting;
|
||||
import meteordevelopment.meteorclient.settings.Setting;
|
||||
import meteordevelopment.meteorclient.settings.SettingGroup;
|
||||
import meteordevelopment.meteorclient.systems.modules.Module;
|
||||
import meteordevelopment.meteorclient.utils.render.RenderUtils;
|
||||
import meteordevelopment.meteorclient.utils.render.color.Color;
|
||||
import java.util.Random;
|
||||
|
||||
// Too much much spaghetti!
|
||||
// -StormyBytes
|
||||
|
||||
public class Confuse extends Module {
|
||||
|
||||
@@ -39,6 +40,7 @@ public class Confuse extends Module {
|
||||
.description("Mode")
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("delay")
|
||||
.description("Delay")
|
||||
@@ -47,6 +49,22 @@ public class Confuse extends Module {
|
||||
.sliderMax(20)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("radius")
|
||||
.description("Range to confuse opponents")
|
||||
.defaultValue(6)
|
||||
.min(0).sliderMax(10)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<SortPriority> priority = sgGeneral.add(new EnumSetting.Builder<SortPriority>()
|
||||
.name("priority")
|
||||
.description("Targetting priority")
|
||||
.defaultValue(SortPriority.LowestHealth)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Integer> circleSpeed = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("circle-speed")
|
||||
.description("Circle mode speed")
|
||||
@@ -55,17 +73,28 @@ public class Confuse extends Module {
|
||||
.sliderMax(180)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> moveThroughBlocks = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("move-through-blocks")
|
||||
.defaultValue(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> budgetGraphics = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("budget-graphics")
|
||||
.defaultValue(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<SettingColor> circleColor = sgGeneral.add(new ColorSetting.Builder()
|
||||
.name("circle-color")
|
||||
.description("Color for circle rendering")
|
||||
.defaultValue(new SettingColor(0, 255, 0))
|
||||
.visible(budgetGraphics::get)
|
||||
.build()
|
||||
);
|
||||
|
||||
|
||||
int delayWaited = 0;
|
||||
double circleProgress = 0;
|
||||
double addition = 0.0;
|
||||
@@ -85,50 +114,45 @@ public class Confuse extends Module {
|
||||
|
||||
@EventHandler
|
||||
private void onTick(TickEvent.Pre event) {
|
||||
|
||||
// Delay
|
||||
delayWaited++;
|
||||
if (delayWaited < delay.get()) return;
|
||||
delayWaited = 0;
|
||||
assert mc.player != null;
|
||||
Vec3d sel1 = mc.player.getPos().add(-4, -4, -4);
|
||||
Vec3d sel2 = sel1.add(8, 8, 8);
|
||||
Box selector = new Box(sel1, sel2);
|
||||
assert mc.world != null;
|
||||
for (Entity e : mc.world.getEntities()) {
|
||||
if (e.getUuid() == mc.player.getUuid()) continue;
|
||||
if (!e.isAlive()
|
||||
|| !e.isAttackable()) continue;
|
||||
if (e.getBoundingBox().intersects(selector)) {
|
||||
target = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Targetting
|
||||
target = TargetUtils.get(entity -> {
|
||||
if (entity.getUuid() == mc.player.getUuid()) return false;
|
||||
if (!entity.isAlive() || !entity.isAttackable()) return false;
|
||||
return PlayerUtils.distanceTo(entity) <= range.get();
|
||||
}, priority.get());
|
||||
|
||||
if (target == null) return;
|
||||
if (!target.isAlive()) {
|
||||
target = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Vec3d entityPos = target.getPos();
|
||||
Vec3d playerPos = mc.player.getPos();
|
||||
if (playerPos.distanceTo(entityPos) > 6) {
|
||||
target = null;
|
||||
return;
|
||||
}
|
||||
Random r = new Random();
|
||||
BlockHitResult hit;
|
||||
int halfRange = range.get() / 2;
|
||||
|
||||
switch (mode.get()) {
|
||||
case RandomTP:
|
||||
double x = r.nextDouble() * 6 - 3;
|
||||
double x = r.nextDouble() * range.get() - halfRange;
|
||||
double y = 0;
|
||||
double z = r.nextDouble() * 6 - 3;
|
||||
double z = r.nextDouble() * range.get() - halfRange;
|
||||
Vec3d addend = new Vec3d(x, y, z);
|
||||
Vec3d goal = entityPos.add(addend);
|
||||
if (mc.world.getBlockState(new BlockPos(goal.x, goal.y, goal.z)).getBlock() != Blocks.AIR) {
|
||||
goal = new Vec3d(x, playerPos.y, z);
|
||||
}
|
||||
if (mc.world.getBlockState(new BlockPos(goal.x, goal.y, goal.z)).getBlock() == Blocks.AIR) {
|
||||
hit = mc.world.raycast(new RaycastContext(
|
||||
mc.player.getPos(),goal, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player
|
||||
));
|
||||
hit = mc.world.raycast(new RaycastContext(mc.player.getPos(),goal, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
|
||||
if (!moveThroughBlocks.get() && hit.isInsideBlock()) {
|
||||
delayWaited = (int) (delay.get() - 1);
|
||||
break;
|
||||
@@ -138,19 +162,19 @@ public class Confuse extends Module {
|
||||
delayWaited = (int) (delay.get() - 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Switch:
|
||||
Vec3d diff = entityPos.subtract(playerPos);
|
||||
Vec3d diff1 = new Vec3d(clamp(diff.x, -3, 3), clamp(diff.y, -3, 3), clamp(diff.z, -3, 3));
|
||||
Vec3d diff1 = new Vec3d(Utils.clamp(diff.x, -halfRange, halfRange), Utils.clamp(diff.y, -halfRange, halfRange), Utils.clamp(diff.z, -halfRange, halfRange));
|
||||
Vec3d goal2 = entityPos.add(diff1);
|
||||
hit = mc.world.raycast(new RaycastContext(
|
||||
mc.player.getPos(), goal2, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player
|
||||
));
|
||||
hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), goal2, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
|
||||
if (!moveThroughBlocks.get() && hit.isInsideBlock()) {
|
||||
delayWaited = (int) (delay.get() - 1);
|
||||
break;
|
||||
}
|
||||
mc.player.updatePosition(goal2.x, goal2.y, goal2.z);
|
||||
break;
|
||||
|
||||
case Circle:
|
||||
delay.set(0);
|
||||
circleProgress += circleSpeed.get();
|
||||
@@ -159,9 +183,7 @@ public class Confuse extends Module {
|
||||
double sin = Math.sin(rad) * 3;
|
||||
double cos = Math.cos(rad) * 3;
|
||||
Vec3d current = new Vec3d(entityPos.x + sin, playerPos.y, entityPos.z + cos);
|
||||
hit = mc.world.raycast(new RaycastContext(
|
||||
mc.player.getPos(), current, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player
|
||||
));
|
||||
hit = mc.world.raycast(new RaycastContext(mc.player.getPos(), current, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.ANY, mc.player));
|
||||
if (!moveThroughBlocks.get() && hit.isInsideBlock())
|
||||
break;
|
||||
mc.player.updatePosition(current.x, current.y, current.z);
|
||||
@@ -179,7 +201,7 @@ public class Confuse extends Module {
|
||||
if (addition > 360) addition = 0;
|
||||
for (int i = 0; i < 360; i += flag ? 7 : 1) {
|
||||
Color c1;
|
||||
if (flag) c1 = new Color(0, 255, 0);
|
||||
if (flag) c1 = circleColor.get();
|
||||
else {
|
||||
double rot = (255.0 * 3) * (((((double) i) + addition) % 360) / 360.0);
|
||||
int seed = (int) Math.floor(rot / 255.0);
|
||||
@@ -198,8 +220,4 @@ public class Confuse extends Module {
|
||||
last = c;
|
||||
}
|
||||
}
|
||||
|
||||
public static double clamp(double val, double min, double max) {
|
||||
return Math.max(min, Math.min(max, val));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user