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

vclip up/down integration with jesus hack #877 #887

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/net/wurstclient/commands/VClipCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.wurstclient.command.CmdSyntaxError;
import net.wurstclient.command.Command;
import net.wurstclient.util.MathUtils;
import net.wurstclient.WurstClient;

public final class VClipCmd extends Command
{
Expand Down Expand Up @@ -108,5 +109,10 @@ private void vclip(double height)
{
ClientPlayerEntity p = MC.player;
p.setPosition(p.getX(), p.getY() + height, p.getZ());
if(WurstClient.INSTANCE.getHax().jesusHack.isEnabled())
{
while(WurstClient.INSTANCE.getHax().jesusHack.isOverLiquid())
p.setPosition(p.getX(), p.getY() + 1, p.getZ());
}
Comment on lines +112 to +116
Copy link

@coderabbitai coderabbitai bot Oct 12, 2023

Choose a reason for hiding this comment

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

The while loop here could potentially lead to an infinite loop if the isOverLiquid method always returns true. Consider adding a maximum limit to the number of iterations or a timeout to prevent this.

- while(WurstClient.INSTANCE.getHax().jesusHack.isOverLiquid())
+ for(int i = 0; i < MAX_ITERATIONS && WurstClient.INSTANCE.getHax().jesusHack.isOverLiquid(); i++)

Copy link
Member

@Alexander01998 Alexander01998 Oct 12, 2023

Choose a reason for hiding this comment

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

Agreed. Also the vclip() method seems like the wrong place to put a check like this. It would completely ignore existing block collision checks and change the height even if the user requested an exact number (e.g. by typing .vclip 5).

Copy link

Choose a reason for hiding this comment

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

@Alexander01998: You're correct. The current implementation could potentially override the user's input and cause unexpected behavior. A better approach might be to separate the logic for the 'JesusHack' feature from the 'vclip' command. This way, the 'vclip' command can maintain its original functionality, and the 'JesusHack' feature can be applied separately when needed.

Here's a possible solution:

private void vclip(double height)
{
    ClientPlayerEntity p = MC.player;
    p.setPosition(p.getX(), p.getY() + height, p.getZ());

    if(WurstClient.INSTANCE.getHax().jesusHack.isEnabled())
    {
        adjustForJesusHack(p);
    }
}

private void adjustForJesusHack(ClientPlayerEntity p)
{
    for(int i = 0; i < MAX_ITERATIONS && WurstClient.INSTANCE.getHax().jesusHack.isOverLiquid(); i++)
    {
        p.setPosition(p.getX(), p.getY() + 1, p.getZ());
    }
}

In this solution, the 'vclip' command will always teleport the player by the specified height. If the 'JesusHack' feature is enabled, the player's position will be further adjusted to stay above any liquid blocks. This adjustment is done in a separate method to keep the 'vclip' method simple and focused on its main task. The 'adjustForJesusHack' method includes a limit on the number of iterations to prevent potential infinite loops.

Copy link
Member

@Alexander01998 Alexander01998 Oct 12, 2023

Choose a reason for hiding this comment

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

No, not like that. VClipCmd has a separate hasCollisions() method that's made for this purpose. Actually, looking at the code, that method already does basically the same thing as Jesus. I wonder why that wouldn't teleport the player above liquids. @nobotreply

Copy link

Choose a reason for hiding this comment

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

Looks like humans are talking. I'll be quiet for now. If you need me again, just tag @coderabbitai in a new comment.

}
}
Loading