@Getter
@Module.registerModule(name = "Aim Assist", alias = "aimassist", category = Category.Combat)
public class AimAssist extends Module {
private final NumberSetting fov = new NumberSetting("Угол поиска цели", 25, 1, 90, 1, 30);
private final NumberSetting pitchSpeed = new NumberSetting("Скорость по pitch", 5, 1, 20, 1, 10);
private final NumberSetting yawSpeed = new NumberSetting("Скорость по yaw", 25, 1, 40, 1, 25);
private PlayerEntity target;
public AimAssist() {
register(fov, yawSpeed, pitchSpeed);
}
@Subscribe
public void onTick(TickEvent event) {
target = getEntity(mc.player, 4, fov.getNumberValue());
}
@Subscribe
public void onGui(GuiEvent event) {
if (target != null) {
setRotation(target, yawSpeed.getNumberValue(), pitchSpeed.getNumberValue());
}
}
private void setRotation(PlayerEntity target, float rotationYawSpeed, float rotationPitchSpeed) {
float rawYaw = (float) Math.toDegrees(Math.atan2(-PlayerUtility.getTargetPos(target, 3).x, PlayerUtility.getTargetPos(target, 3).z));
float rawPitch = (float) MathHelper.clamp(Math.toDegrees(Math.asin(-PlayerUtility.getTargetPos(target, 3).y)), -89, 89);
float yawDelta = (int) wrapDegrees(rawYaw - mc.player.rotationYaw);
float pitchDelta = rawPitch - mc.player.rotationPitch;
float clampedYaw = MathHelper.clamp(yawDelta, -rotationYawSpeed, rotationYawSpeed);
float clampedPitch = MathHelper.clamp(pitchDelta, -rotationPitchSpeed, rotationPitchSpeed);
float currentYaw = mc.player.rotationYaw + (mc.objectMouseOver.getType() == RayTraceResult.Type.ENTITY ? 0 : clampedYaw);
float currentPitch = mc.player.rotationPitch + (mc.objectMouseOver.getType() == RayTraceResult.Type.ENTITY ? 0 : clampedPitch);
float interpolatedYaw = (float) MathUtility.interpolate(currentYaw, mc.player.prevRotationYaw, mc.getRenderPartialTicks());
float interpolatedPitch = (float) MathUtility.interpolate(currentPitch, mc.player.prevRotationPitch, mc.getRenderPartialTicks());
RotationHandler.update(new Rotation(interpolatedYaw, interpolatedPitch), 360, 1, 5, false);
}
private PlayerEntity getEntity(PlayerEntity player, double distance, double fov) {
for (PlayerEntity entity : player.world.getEntitiesWithinAABB(PlayerEntity.class, player.getBoundingBox().expand(player.getLook(1.0F).scale(distance)).grow(1.0D, 1.0D, 1.0D), e -> e != mc.player && !e.isSpectator() && e.isAlive())) {
double angle = Math.acos(player.getLook(1.0F).dotProduct(entity.getPositionVec().subtract(player.getEyePosition(1.0F)).normalize())) * (180D / Math.PI);
double distanceToEntity = player.getEyePosition(1.0F).distanceTo(entity.getPositionVec());
if (angle <= fov && distanceToEntity < distance) {
return entity;
}
}
return null;
}
@Override
public void toggle() {
target = null;
super.toggle();
}
}