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

Conversation

TejasLamba2006
Copy link
Contributor

@TejasLamba2006 TejasLamba2006 commented Oct 12, 2023

Added

  • Check Line of sight in Aim Assist

New Features:

  • AimAssistHack: Added a new option to enable line of sight checking. When enabled, the target will be set to null if there's an obstruction between the player and the target.

Summary by CodeRabbit

  • New Feature: Added a "Check Line of Sight" option in the Aim Assist feature. When enabled, it ensures that the aim assist only targets entities that are directly visible, improving the accuracy and effectiveness of the feature.
  • Improvement: Updated the Auto Sword feature to better identify attackable entities. This enhancement ensures that the feature only interacts with valid targets, increasing its efficiency and reliability.

@coderabbitai
Copy link

coderabbitai bot commented Oct 12, 2023

Walkthrough

The changes primarily focus on enhancing the functionality of the AimAssistHack and AutoSwordHack classes in the Wurst Client. The AimAssistHack now includes a line of sight check, preventing aim assistance on entities behind obstructions. The AutoSwordHack has been updated to include a check for attackable entities, ensuring the auto-sword is only activated for valid targets.

Changes

File Summary
.../hacks/AimAssistHack.java Introduced a "Check line of sight" checkbox setting. When enabled, the hack will not aim at entities behind blocks. The onUpdate() method has been updated to include a line of sight check using a raycast. If the raycast hits a block, the target is set to null and the aim assist is not applied.
.../hacks/AutoSwordHack.java Added a new private method isCorrectEntity(Entity entity) to check if the entity is attackable. The onUpdate() method has been modified to include this check before setting the slot.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@CLAassistant
Copy link

CLAassistant commented Oct 12, 2023

CLA assistant check
All committers have signed the CLA.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between c89f5e3 and f2890c2.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/AimAssistHack.java (5 hunks)
Additional comments (Suppressed): 5
src/main/java/net/wurstclient/hacks/AimAssistHack.java (5)
  • 13-21: New import statements have been added to support the line of sight checking feature. Ensure these classes are available in the project dependencies.

  • 49-53: A new checkbox setting checkLOS has been added to enable or disable line of sight checking. This is a good addition for user flexibility.

  • 85-85: The new checkLOS setting is added to the settings list. This is necessary for the setting to be visible and adjustable in the user interface.

  • 98-103: The triggerBotHack has been removed from the list of hacks that are disabled when AimAssistHack is enabled. Verify if this is intentional and won't cause any conflicts or undesired behavior.

  • 136-150: The line of sight checking logic has been added. If the checkLOS setting is enabled, it performs a raycast from the player's eyes to the target. If the raycast hits anything (i.e., there's an obstruction), it sets the target to null and returns. This is a good addition for preventing attacks through obstructions.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between f2890c2 and dba47c8.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/AutoSwordHack.java (4 hunks)
Additional comments (Suppressed): 3
src/main/java/net/wurstclient/hacks/AutoSwordHack.java (3)
  • 10-14: The import of java.util.stream.Stream is new and is used in the new method isCorrectEntity(Entity entity). Ensure that this import doesn't conflict with any other Stream imports in the project.

  • 29-29: The import of net.wurstclient.util.EntityUtils is new and is used in the new method isCorrectEntity(Entity entity). Ensure that this import doesn't conflict with any other EntityUtils imports in the project.

  • 82-83: The new isCorrectEntity(Entity entity) method is used to check if the targeted entity is attackable. This is a good addition as it prevents the sword from being pulled out when the entity is a friend.

src/main/java/net/wurstclient/hacks/AutoSwordHack.java Outdated Show resolved Hide resolved
Copy link
Member

@Alexander01998 Alexander01998 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TejasLamba2006, thanks for your contributions! However, could you please split these changes into separate pull requests? That way it's much easier to label, review and potentially merge each change. A combined pull request with unrelated changes can be hard to keep track of, as GitHub isn't really designed to work this way. Appreciate your understanding here!

@TejasLamba2006 TejasLamba2006 changed the title Check Line of sight in Aim Assist, Dont pull out sword in AutoSword if person is friend Check Line of sight in Aim Assist Oct 12, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between dba47c8 and e1b41a4.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/AutoSwordHack.java (4 hunks)
Additional comments (Suppressed): 2
src/main/java/net/wurstclient/hacks/AutoSwordHack.java (2)
  • 26-32: The import statement for net.wurstclient.util.EntityUtils has been added. This utility class is likely used for the new isCorrectEntity() method.

  • 78-87: The onUpdate() method now includes a check using isCorrectEntity() before calling setSlot(). This change prevents the sword from being pulled out if the entity is identified as a non-attackable entity.

src/main/java/net/wurstclient/hacks/AutoSwordHack.java Outdated Show resolved Hide resolved
@TejasLamba2006
Copy link
Contributor Author

✔️The build successfully compiles and works, checked personally

@TejasLamba2006
Copy link
Contributor Author

@Alexander01998, is the pull okay now?

@Alexander01998 Alexander01998 added type:enhancement New feature or request area:settings Improves the settings of existing features. category:combat labels Oct 13, 2023
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between e1b41a4 and 84bd382.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/AimAssistHack.java (5 hunks)
Additional comments (Suppressed): 5
src/main/java/net/wurstclient/hacks/AimAssistHack.java (5)
  • 13-28: The new imports net.minecraft.util.hit.HitResult, net.minecraft.util.math.Vec3d, net.minecraft.world.RaycastContext, and net.wurstclient.settings.CheckboxSetting are introduced to support the new line of sight checking feature and the checkbox setting.

  • 46-54: A new checkbox setting checkLOS is introduced. When enabled, the hack will not aim at entities that are obstructed by blocks. This is a good addition for user control and flexibility.

  • 79-85: The new checkbox setting checkLOS is added to the settings of the AimAssistHack class. This ensures that the setting is visible and adjustable in the user interface.

  • 95-100: The triggerBotHack is no longer being disabled in the onEnable method. If this is intentional and the triggerBotHack is compatible with the AimAssistHack, then this change is fine. If not, this could lead to conflicts between the hacks.

- WURST.getHax().triggerBotHack.setEnabled(false);
  • 133-149: The onUpdate method now includes a check for line of sight when the checkLOS setting is enabled. This is done using raycasting from the player's eyes to the target entity. If the raycast hits a block, the target entity is set to null and the method returns. This is a good implementation of the line of sight feature, but it might have performance implications due to the raycasting operation. Consider optimizing this if it becomes a performance issue.

@Alexander01998
Copy link
Member

  • 95-100: The triggerBotHack is no longer being disabled in the onEnable method. If this is intentional and the triggerBotHack is compatible with the AimAssistHack, then this change is fine. If not, this could lead to conflicts between the hacks.

Thanks @coderabbitai, I missed that one. Fix commit coming up.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Commits Files that changed from the base of the PR and between 84bd382 and b136da9.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/AimAssistHack.java (4 hunks)
Additional comments (Suppressed): 3
src/main/java/net/wurstclient/hacks/AimAssistHack.java (3)
  • 46-50: The new CheckboxSetting checkLOS is introduced to allow users to enable or disable the line of sight check. This is a good addition for user flexibility.

  • 79-82: The checkLOS setting is added to the settings list. This is necessary for the setting to be visible and adjustable in the user interface.

  • 134-147: The onUpdate() method is updated to include a line of sight check when the checkLOS setting is enabled. This is done by raycasting from the player's eyes to the target entity. If the raycast hits a block (i.e., the hit result type is not MISS), the target is set to null, preventing aim assist. This is a good implementation of the line of sight check.

However, there's a potential performance issue. Raycasting can be an expensive operation, especially if it's done every update. Consider adding a condition to perform the raycast less frequently, for example, every few ticks instead of every tick.

Here's a possible way to implement this:

private int tickCounter = 0;

...

if(tickCounter++ % 5 == 0 && checkLOS.isChecked() && MC.world
    .raycast(new RaycastContext(eyesPos, hitVec,
        RaycastContext.ShapeType.COLLIDER,
        RaycastContext.FluidHandling.NONE, MC.player))
    .getType() != HitResult.Type.MISS)
{
    target = null;
    return;
}

This code will perform the raycast every 5 ticks instead of every tick, reducing the performance impact.

@Alexander01998 Alexander01998 added this to the v7.38 milestone Oct 13, 2023
@Alexander01998
Copy link
Member

@TejasLamba2006 It's good now. I've adjusted the "Check line of sight" description, since AimAssist can't actually make you reach through blocks, and changed the setting to be enabled by default. Just so you know, I'm going to merge this pull request into the v7.38 branch, so GitHub won't mark it as merged until Wurst 7.38 is released.

@Alexander01998 Alexander01998 added the status:merged This pull request has been merged, even if GitHub says otherwise. label Oct 13, 2023
@TejasLamba2006
Copy link
Contributor Author

TejasLamba2006 commented Oct 13, 2023

Cool ! Looking forward to contribute more, If you have a discord I would love to talk

@Alexander01998 Alexander01998 merged commit 8eada5a into Wurst-Imperium:master Oct 23, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:settings Improves the settings of existing features. category:combat status:merged This pull request has been merged, even if GitHub says otherwise. type:enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants