package wtf.levinov.modules.impl.combat;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import wtf.levinov.events.Event;
import wtf.levinov.events.impl.player.EventUpdate;
import wtf.levinov.modules.Function;
import wtf.levinov.modules.FunctionAnnotation;
import wtf.levinov.modules.Type;
import wtf.levinov.modules.settings.imp.SliderSetting;
import java.util.Comparator;
/**
* @author leva_pro && Not Offical broo
* @since 28.03.2024
*/
@FunctionAnnotation(name = "AimBot", type = Type.Combat)
public class AimBot extends Function {
private final SliderSetting range = new SliderSetting("Дистанция", 5.0f, 2.0f, 15.0f, 0.05f);
public AimBot() {
addSettings(range);
}
@Override
public void onEvent(Event event) {
if (event instanceof EventUpdate eventUpdate) {
}
PlayerEntity target = mc.world.getPlayers().stream().filter(entityPlayer -> entityPlayer != mc.player).min(Comparator.comparing(entityPlayer ->
entityPlayer.getDistance(mc.player))).filter(entityPlayer -> entityPlayer.getDistance(mc.player) <= range.getValue().doubleValue()).orElse(null);
if (target != null && mc.player.canEntityBeSeen(target)) {
mc.player.rotationYaw = rotations(target)[0];
mc.player.rotationPitch = rotations(target)[1];
}
}
public float[] rotations(LivingEntity entity) {
double x = entity.getPosX() - mc.player.getPosX();
double y = entity.getPosY() - (mc.player.getPosY() + mc.player.getEyeHeight()) + 1.5;
double z = entity.getPosZ() - mc.player.getPosZ();
double u = MathHelper.sqrt(x * x + z * z);
float u2 = (float) (MathHelper.atan2(z, x) * (180D / Math.PI) - 90.0F);
float u3 = (float) (-MathHelper.atan2(y, u) * (180D / Math.PI));
return new float[]{u2, u3};
}
}