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

new hack: AutoMLGHack #557

Closed
wants to merge 1 commit into from

Conversation

isjerryxiao
Copy link
Contributor

Description

It does auto mlg water bucket and powder snow.

@CLAassistant
Copy link

CLAassistant commented Jan 26, 2022

CLA assistant check
All committers have signed the CLA.

Copy link

@theavgeekbee theavgeekbee left a comment

Choose a reason for hiding this comment

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

So far, a short fall distance fails to reduce/negate damage. Also, the player drops straight down whether or not the player has a MLG-able item in their inventory, and items in the offhand are not detected. Otherwise works.

@isjerryxiao
Copy link
Contributor Author

@InfinitePower563 Placing water bucket in your offhand is generally not a good idea since you're likely to interact with the item in your main hand instead of placing water down, making the whole thing much more unreliable.

@isjerryxiao
Copy link
Contributor Author

Now the hack can make use of offhand or inventory. Also the short fall distance issue is fixed.

@buiawpkgew1
Copy link

buiawpkgew1 commented Jan 27, 2022

@isjerryxiao #559#558#557#556 为啥不放在一起?

@isjerryxiao
Copy link
Contributor Author

isjerryxiao commented Jan 27, 2022

@buiawpkgew1 https://github.com/Wurst-Imperium/Wurst7#note-about-pull-requests
Maintaining 4 branches and manually cherry-picking isn't fun. I would not do that if possible.

@buiawpkgew1
Copy link

好的

Copy link

@theavgeekbee theavgeekbee left a comment

Choose a reason for hiding this comment

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

Now it activates when elytra is activated. Kind of glitches out when gliding downward.

@isjerryxiao
Copy link
Contributor Author

You can't use elytra with NoFall either, but adding a check is better.

@isjerryxiao
Copy link
Contributor Author

@wb1016
Copy link

wb1016 commented May 23, 2022

C:\Users\wb\minecraft\Wurst7\src\main\java\net\wurstclient\hacks\AutoMLGHack.java:134: error: cannot find symbol
                    WURST.getHax().autoEatHack.pauseEat = 20;
                                              ^
  symbol:   variable pauseEat
  location: variable autoEatHack of type AutoEatHack

cant build anymore

Copy link

coderabbitai bot commented Nov 14, 2023

Walkthrough

Walkthrough

The changes involve the addition of a new feature to the Wurst Client, a Minecraft hack client. A new hack called AutoMLGHack has been implemented, which automates the process of performing a water bucket clutch, a technique used to avoid fall damage. The hack includes various settings to customize its behavior. Additionally, a minor interface update has been made to support this new feature, while another file received insignificant formatting adjustments.

Changes

File Path Change Summary
.../hack/HackList.java Added AutoMLGHack to the list of hacks.
.../hacks/AutoMLGHack.java Introduced new AutoMLGHack class for automated water bucket clutches in Minecraft.
.../mixin/ClientPlayerInteractionManagerMixin.java Minor formatting or whitespace adjustments, no functional changes.
.../mixinterface/IClientPlayerInteractionManager.java Added new method windowClick_THROW.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between e55d2b6 and 8fad868.
Files ignored due to filter (2)
  • src/main/resources/assets/wurst/lang/en_us.json
  • src/main/resources/assets/wurst/lang/zh_cn.json
Files selected for processing (4)
  • src/main/java/net/wurstclient/hack/HackList.java (1 hunks)
  • src/main/java/net/wurstclient/hacks/AutoMLGHack.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java (1 hunks)
  • src/main/java/net/wurstclient/mixinterface/IClientPlayerInteractionManager.java (1 hunks)
Files skipped from review due to trivial changes (2)
  • src/main/java/net/wurstclient/hack/HackList.java
  • src/main/java/net/wurstclient/mixin/ClientPlayerInteractionManagerMixin.java
Additional comments: 1
src/main/java/net/wurstclient/mixinterface/IClientPlayerInteractionManager.java (1)
  • 19-25: The addition of the windowClick_THROW method to the IClientPlayerInteractionManager interface will require all implementing classes to provide an implementation for this method. Ensure that all necessary implementations are updated accordingly to avoid compilation errors.

Comment on lines +1 to +227
if (!placedWater) {
float minfallDistance = minFall.getValueF();
if (MC.player.fallDistance > minfallDistance - 2.0f && !MC.player.hasStatusEffect(StatusEffects.SLOW_FALLING)
&& !(checkElytra.isChecked() && MC.player.isFallFlying())) {
Vec3d playerPos = MC.player.getPos();
if (lastPlayerPos == null) lastPlayerPos = playerPos;
if (playerPos.y - lastPlayerPos.y < 0.0D) {
BlockHitResult result = MC.world.raycast(new RaycastContext(MC.player.getPos(), playerPos.subtract(0, 5, 0), RaycastContext.ShapeType.OUTLINE, RaycastContext.FluidHandling.NONE, MC.player));
BlockPos bp = result.getBlockPos();
if (result != null && result.getType() == HitResult.Type.BLOCK
&& Math.max(0.0, (float)playerPos.y - (float)(bp.getY())) - 1.3f + MC.player.fallDistance > minfallDistance
&& causeFallDamage(BlockUtils.getState(result.getBlockPos()))
&& causeFallDamage(BlockUtils.getState(result.getBlockPos().up()))
) {
for (ItemStack bucket : (snowFirst.isChecked() ? Lists.reverse(BUCKETS) : BUCKETS)) {
if (MC.world.getDimension().ultrawarm() && bucket.getItem().equals(Items.WATER_BUCKET))
continue;
int location = takeStackOut(bucket);
if (location == 0) continue;
offHand = location < 0;
waterBucket = bucket.getItem().equals(Items.WATER_BUCKET);
if (anchor.isChecked()) {
double x = MathHelper.floor(MC.player.getX()) + 0.5;
double z = MathHelper.floor(MC.player.getZ()) + 0.5;
if ((Math.abs(MC.player.getX() - x) > 1e-5) || (Math.abs(MC.player.getZ() - z) > 1e-5)) {
MC.player.setPosition(x, MC.player.getY(), z);
MC.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(MC.player.getX(), MC.player.getY(), MC.player.getZ(), MC.player.isOnGround()));
}
MC.player.setVelocity(0, MC.player.getVelocity().y, 0);
}
if (lastRot == null) lastRot = MC.player.getRotationClient();
if (rightClickBlock(bp)) {
placedWater = true;
targetBlock = bp;
pickupRetry = 0;
}
break;
}
}
}
lastPlayerPos = playerPos;
}
else {
lastRot = null;
}
} else {
if (MC.player.isOnGround() || MC.player.isTouchingWater() && MC.itemUseCooldown < 1) {
int location = takeStackOut(new ItemStack(Items.BUCKET));
if (location != 0) {
offHand = location < 0;
rightClickBlock(targetBlock);
if ((offHand ? MC.player.getOffHandStack() : MC.player.getInventory().getMainHandStack()).getItem().equals(Items.BUCKET)) {
pickupRetry++;
if (pickupRetry <= 10) {
return;
}
}
}
if (doSneak.isChecked()) {
IKeyBinding sneakKey = (IKeyBinding) MC.options.sneakKey;
((KeyBinding) sneakKey).setPressed(sneakKey.isActallyPressed());
}
restoreRotation();
lastPlayerPos = null;
placedWater = false;
}
}
}
private boolean causeFallDamage(BlockState bs) {
if (bs.isAir()) return true;
Block block = bs.getBlock();
if (block instanceof FluidBlock || block instanceof SeaPickleBlock || block instanceof SeagrassBlock) return false;
// todo slabs and more?
return true;
}

private int takeStackOut(ItemStack stack) {
PlayerInventory inv = MC.player.getInventory();
int slot = inv.getSlotWithStack(stack);
if (slot >= 0 && slot <= 8) {
// bucket in hotbar
inv.selectedSlot = slot;
return 1;
}
else if (slot >= 9 && slot <= 35) {
// bucket in inventory
if (allowInv.isChecked()) {
IMC.getInteractionManager().windowClick_SWAP(slot, inv.selectedSlot);
return 1;
}
}
else {
// no bucket in inventory
if (ItemStack.areItemsEqual(MC.player.getOffHandStack(), stack)) {
// use bucket in offhand
return -1;
}
}
return 0;
}
Copy link

Choose a reason for hiding this comment

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

The AutoMLGHack class is well-structured and follows Java conventions. However, there are a few areas that could be improved for better performance and maintainability:

  • The onUpdate method (lines 126-195) is quite long and handles multiple responsibilities. Consider breaking it down into smaller methods for better readability and maintainability.
  • The causeFallDamage method (lines 196-201) could be expanded to include more block types that prevent fall damage, as indicated by the todo comment.
  • The takeStackOut method (lines 204-227) could be optimized by returning early to reduce nesting and improve readability.
  • The use of magic numbers (e.g., 18.0625 on line 105) should be replaced with named constants for better clarity.
  • The rightClickBlock method (lines 92-116) sends a packet to the server to update the player's rotation. This could potentially be exploited or cause desync issues if not handled correctly. Ensure that the server's anti-cheat mechanisms are considered.
  • The restoreRotation method (lines 118-123) directly sets the player's pitch and yaw. This could lead to abrupt changes in the player's view. Consider smoothing out the rotation change to avoid a jarring experience.

Here's a proposed change for the takeStackOut method to reduce nesting:

private int takeStackOut(ItemStack stack) {
    PlayerInventory inv = MC.player.getInventory();
    int slot = inv.getSlotWithStack(stack);
    if (slot < 0 || slot > 35) {
        // no bucket in inventory
        if (ItemStack.areItemsEqual(MC.player.getOffHandStack(), stack)) {
            // use bucket in offhand
            return -1;
        }
        return 0;
    }
    if (slot >= 0 && slot <= 8) {
        // bucket in hotbar
        inv.selectedSlot = slot;
        return 1;
    }
    if (slot >= 9 && allowInv.isChecked()) {
        // bucket in inventory
        IMC.getInteractionManager().windowClick_SWAP(slot, inv.selectedSlot);
        return 1;
    }
    return 0;
}

Copy link

This pull request has been open for a while with no recent activity. If you're still working on this or waiting for a review, please add a comment or commit within the next 7 days to keep it open. Otherwise, the pull request will be automatically closed to free up time for other tasks.

Pull requests should be closed if:

  • They have been superseded by another pull request
  • They are out of scope or don't align with the project
  • They have become obsolete due to other changes
  • They have bugs or conflicts that won't be resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants