Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Line of sight in Aim Assist #886

Merged
merged 11 commits into from
Oct 23, 2023
19 changes: 19 additions & 0 deletions src/main/java/net/wurstclient/hacks/AimAssistHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext;
import net.wurstclient.Category;
import net.wurstclient.events.RenderListener;
import net.wurstclient.events.UpdateListener;
import net.wurstclient.hack.Hack;
import net.wurstclient.settings.CheckboxSetting;
import net.wurstclient.settings.SliderSetting;
import net.wurstclient.settings.SliderSetting.ValueDisplay;
import net.wurstclient.settings.filterlists.EntityFilterList;
Expand All @@ -42,6 +46,9 @@ public final class AimAssistHack extends Hack
+ "360\u00b0 = aims at entities all around you.",
120, 30, 360, 10, ValueDisplay.DEGREES);

private final CheckboxSetting checkLOS = new CheckboxSetting(
"Check line of sight", "Won't aim at entities behind blocks.", true);

private final EntityFilterList entityFilters =
new EntityFilterList(FilterPlayersSetting.genericCombat(false),
FilterSleepingSetting.genericCombat(false),
Expand Down Expand Up @@ -72,6 +79,7 @@ public AimAssistHack()
addSetting(range);
addSetting(rotationSpeed);
addSetting(fov);
addSetting(checkLOS);

entityFilters.forEach(this::addSetting);
}
Expand Down Expand Up @@ -126,6 +134,17 @@ public void onUpdate()
if(target == null)
return;

Vec3d eyesPos = RotationUtils.getEyesPos();
Vec3d hitVec = target.getBoundingBox().getCenter();
if(checkLOS.isChecked() && MC.world
.raycast(new RaycastContext(eyesPos, hitVec,
RaycastContext.ShapeType.COLLIDER,
RaycastContext.FluidHandling.NONE, MC.player))
.getType() != HitResult.Type.MISS)
{
target = null;
return;
}
WURST.getHax().autoSwordHack.setSlot();
faceEntityClient(target);
}
Expand Down