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

Split NoSlowdown with checkboxes #800

Closed

Conversation

ThisTestUser
Copy link
Contributor

@ThisTestUser ThisTestUser commented Mar 17, 2023

Splits the various features of NoSlowdown (honey and soul sand slowdown, item slowdown) with settings. This is useful because some anticheats only block NoSlowdown when using shields.

Summary by CodeRabbit

  • New Features
    • Added settings to control and cancel slowness effects caused by blocks and items in the game.
    • Introduced new behaviors for item slowness management, allowing for more customized gameplay.

@github-actions
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

@ThisTestUser
Copy link
Contributor Author

Still relevant.

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

Copy link

coderabbitai bot commented Dec 27, 2023

Walkthrough

Walkthrough

Enhancements to the NoSlowdownHack in the Wurst Client provide users with more control over movement slowdown caused by blocks and items. These changes introduce settings for customizing block and item slowness effects, along with methods to manage these effects effectively.

Changes

File Path Change Summary
.../hacks/NoSlowdownHack.java Added settings for block and item slowness control; introduced new methods and an enum for item slowness behaviors.
.../mixin/BlockMixin.java Modified logic in onGetVelocityMultiplier to use noBlockSlowness property for control flow.
.../mixin/ClientPlayerEntityMixin.java Updated methods to incorporate new logic for item and movement slowdown based on various conditions.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

Note: Auto-reply has been disabled for this repository by the repository owner. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a764953 and b4e3733.
Files selected for processing (3)
  • src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/BlockMixin.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (1 hunks)
Additional comments: 11
src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (5)
  • 19-22: The addition of blocks and items settings is consistent with the PR's objective to allow users to selectively enable or disable slowdown prevention. Ensure that the naming and default values align with the project's standards and user expectations.

  • 32-34: The noBlockSlowness method correctly checks both if the hack is enabled and if the blocks setting is checked. This is a logical implementation for the intended functionality.

  • 37-39: The noItemSlowness method's logic is sound, checking for the ALL value in the items setting to determine if item slowness should be prevented.

  • 42-44: The noNonBlockingItemSlowness method is implemented correctly, checking for the EXCEPT_BLOCKING value in the items setting. This allows for the specific use case where blocking item slowness is not prevented.

  • 47-64: The ItemSlowness enum is well-defined with clear naming for each value, and the toString method is overridden to return the human-readable name. This is a good practice for readability and maintainability.

src/main/java/net/wurstclient/mixin/BlockMixin.java (1)
  • 47-57: The change to use noBlockSlowness instead of isEnabled in the onGetVelocityMultiplier method aligns with the new settings introduced in the NoSlowdownHack class. This ensures that the velocity multiplier is only adjusted when block slowness prevention is enabled.
src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (5)
  • 73-81: The additional conditional checks in the onTickMovementItemUse method correctly implement the new item slowness settings. It ensures that the slowdown is prevented based on the user's configuration.

  • 103-109: The afterIsUsingItem method correctly resets the hideNextItemUse flag. This is important to ensure that the flag is only active for the duration it's needed and does not affect subsequent logic.

  • 144-154: The handling of the current screen in beforeUpdateNausea to prevent it from closing when PortalGUI is enabled seems correct. However, ensure that this does not cause any issues with other parts of the game that might expect the current screen to be non-null.

  • 178-182: The onCanSprint method modification to allow sprinting when the player is too hungry aligns with the functionality of an AutoSprint hack. Ensure that this behavior is clearly documented and communicated to users, as it deviates from the game's default behavior.

  • 274-289: The hasStatusEffect method's additional conditional checks for specific status effects are implemented correctly. They allow the associated hacks to override the default status effect behavior, which is the intended functionality.

@Alexander01998
Copy link
Member

Hi @ThisTestUser, thanks for the pull request! It seems there are some format violations that need to be fixed.

If you're using Eclipse, please make sure to use the cleanup and format settings located in the codestyle folder. This will help ensure consistency with the existing codebase.

Alternatively, if you're not using Eclipse, you can also fix these violations by running the following command from the command line:

./gradlew spotlessApply

Once you've done this, please commit the changes and push them to your branch. This should cause the check to pass and allow your pull request to be merged.

(The github-actions bot was supposed to post this comment automatically, but something is wrong with its permissions.)

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b4e3733 and f3acf76.
Files selected for processing (3)
  • src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/BlockMixin.java (1 hunks)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (2 hunks)
Additional comments: 9
src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (6)
  • 19-21: The addition of the blocks CheckboxSetting is clear and well-documented, providing a description for the user interface.

  • 23-24: The items EnumSetting is introduced correctly with a clear description and default value. It's important to ensure that the enum values are used consistently throughout the codebase.

Verification successful

I will generate a new script to search for references to the ItemSlowness enum throughout the codebase to ensure that it is being used consistently.


The search for references to the ItemSlowness enum in the codebase has produced several results, indicating that the enum is indeed used in various parts of the code. Here are the findings:

  • The ItemSlowness enum is declared in NoSlowdownHack.java and is used to initialize the items EnumSetting with a default value of ItemSlowness.ALL.
  • Methods noItemSlowness() and noItemSlownessExceptShields() in NoSlowdownHack.java use the ItemSlowness enum to check the selected item slowness setting.
  • ClientPlayerEntityMixin.java references methods from NoSlowdownHack that utilize the ItemSlowness enum.

Based on the output, the ItemSlowness enum values are being used consistently within the NoSlowdownHack class and are referenced in the ClientPlayerEntityMixin class. There are no indications of inconsistent usage or undefined references to the enum values.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the enum values are used consistently in the codebase.
ast-grep --lang java --pattern $'ItemSlowness.$_'

Length of output: 50



Script:

#!/bin/bash
# Search for references to the ItemSlowness enum throughout the codebase.
rg --type java 'ItemSlowness'

Length of output: 1117

* 34-36: The `noBlockSlowness` method correctly checks both if the hack is enabled and if the blocks setting is checked. This is a simple and effective way to handle the conditional logic.
  • 39-41: The noItemSlowness method is implemented correctly, checking for the ALL enum value. It's important to ensure that the method is used correctly wherever item slowness should be considered.
Verification successful

To verify the usage of the noItemSlowness() method more thoroughly, I will generate a new shell script using rg (ripgrep), which is a line-oriented search tool that recursively searches the current directory for a regex pattern. This will help us to find any instance of the method being used, even if it's part of a more complex expression.


The rg command has successfully identified two occurrences of the noItemSlowness() method:

  1. Within its own declaration in the NoSlowdownHack.java file.
  2. In the ClientPlayerEntityMixin.java file, where it is being called.

This confirms that the method is indeed being used in the codebase, specifically within the ClientPlayerEntityMixin.java file. The usage in ClientPlayerEntityMixin.java suggests that the method is being used to determine behavior based on the noItemSlowness setting.

Given this information, the method's implementation and usage have been verified as correct based on the provided context and the search results.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the noItemSlowness method is used correctly in the codebase.
ast-grep --lang java --pattern $'noItemSlowness()'

Length of output: 51



Script:

#!/bin/bash
# Search for the usage of noItemSlowness method in the codebase.
rg "noItemSlowness\(\)"

Length of output: 246

* 44-47: The `noItemSlownessExceptShields` method is implemented correctly, checking for the `EXCEPT_SHIELDS` enum value. This method should be used in contexts where shields are an exception to the no slowness rule.
Verification successful

The rg command has found two occurrences of the noItemSlownessExceptShields method:

  1. Within the NoSlowdownHack.java file, which is the declaration of the method itself.
  2. Within the ClientPlayerEntityMixin.java file, which indicates that the method is indeed being used in the codebase.

Based on this information, we can confirm that the noItemSlownessExceptShields method is implemented and used within the codebase, specifically in the ClientPlayerEntityMixin.java file. This aligns with the review comment that the method should be used in contexts where shields are an exception to the no slowness rule.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the noItemSlownessExceptShields method is used correctly in the codebase.
ast-grep --lang java --pattern $'noItemSlownessExceptShields()'

Length of output: 64



Script:

#!/bin/bash
# Search for the usage of noItemSlownessExceptShields method in the codebase.
rg "noItemSlownessExceptShields"

Length of output: 234

* 50-67: The `ItemSlowness` enum is well-defined with clear names and a proper `toString` method. It's important to ensure that the enum is not used in a way that could cause unexpected behavior.
Verification successful

The search for occurrences of the ItemSlowness enum in the codebase has produced several results:

  • Usage in ClientPlayerEntityMixin.java for methods noItemSlowness() and noItemSlownessExceptShields().
  • Declaration and usage within NoSlowdownHack.java for managing item slowness settings and conditional logic.

Based on the output, the ItemSlowness enum is used in the expected manner to control the behavior of the NoSlowdown feature, with methods checking the selected enum value to determine the appropriate behavior. There are no indications from this output that the enum is used in a way that could cause unexpected behavior.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the ItemSlowness enum is not used in a way that could cause unexpected behavior.
ast-grep --lang java --pattern $'ItemSlowness.$_'

Length of output: 50



Script:

#!/bin/bash
# Search for usages of the ItemSlowness enum throughout the codebase.
ast-grep --lang java --pattern $'enum $_ { $$$ }' --exec rg 'ItemSlowness'

Length of output: 267



Script:

#!/bin/bash
# Search for occurrences of the ItemSlowness enum in the codebase.
rg 'ItemSlowness' -tjava

Length of output: 1112

src/main/java/net/wurstclient/mixin/BlockMixin.java (1)
  • 53-54: The change in the onGetVelocityMultiplier method to check noBlockSlowness instead of isEnabled is consistent with the new settings introduced in the NoSlowdownHack class. This ensures that the velocity multiplier is only adjusted when block slowness cancellation is specifically enabled.
src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (2)
  • 29-29: The import of UseAction is necessary for the new logic added to the onTickMovementItemUse method. It's important to ensure that this import is used correctly in the context of the changes.

  • 79-84: The addition of boolean variables noSlowdown and noSlowdownShield in the onTickMovementItemUse method is correct. They are used to determine whether to apply item use slowdown based on the new settings. The logic appears sound, but it's important to verify that the conditions are correctly applied in the game's context.

Verification successful


The new context from the shell scripts provides the necessary information to verify the implementation of the noSlowdown and noSlowdownShield conditions within the onTickMovementItemUse method:

  • The noSlowdown boolean is set based on the noItemSlowness() method from the noSlowdownHack.
  • The noSlowdownShield boolean is set based on the noItemSlownessExceptShields() method from the noSlowdownHack and checks if the current active item's use action is not BLOCK.
  • The conditional if(noSlowdown || noSlowdownShield) then sets hideNextItemUse to true if either condition is met.

This logic aligns with the PR's objective to allow separate toggling of slowdown prevention for items and shields. The conditions are applied correctly in the context of the game, as they check the specific settings before applying the slowdown effect.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the conditions for noSlowdown and noSlowdownShield are correctly applied in the game's context.
ast-grep --lang java --pattern $'onTickMovementItemUse($_)'

Length of output: 60



Script:

#!/bin/bash
# Search for the onTickMovementItemUse method within the ClientPlayerEntityMixin class to verify the conditions.
ast-grep --lang java --pattern $'class ClientPlayerEntityMixin {
  $$$
  void onTickMovementItemUse($_) {
    $$$
  }
  $$$
}'

Length of output: 127



Script:

#!/bin/bash
# Use ripgrep to search for the onTickMovementItemUse method in the codebase.
rg 'void onTickMovementItemUse' -C 3

Length of output: 802



Script:

#!/bin/bash
# Display more lines of the onTickMovementItemUse method to verify the conditions for noSlowdown and noSlowdownShield.
rg 'void onTickMovementItemUse' -C 10 -A 10 src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java

Length of output: 537

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between f3acf76 and 58da731.
Files selected for processing (1)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (2 hunks)
Additional comments: 2
src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (2)
  • 29-29: The addition of the UseAction import is necessary for the new condition in the onTickMovementItemUse method.

  • 79-83: The new condition in the onTickMovementItemUse method correctly implements the feature to prevent slowdown when using items, except for shields. This aligns with the PR objectives to allow more granular control over the NoSlowdown feature.

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

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

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 58da731 and 9afb47c.
Files selected for processing (1)
  • src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (1 hunks)
Additional comments: 3
src/main/java/net/wurstclient/hacks/NoSlowdownHack.java (3)
  • 19-31: The addition of CheckboxSetting for blocks and EnumSetting for items introduces more granular control over the NoSlowdown feature, allowing users to customize their experience based on the type of slowness they wish to cancel. This is a positive change that enhances the hack's functionality and user control. However, ensure that the UI elements for these settings are properly integrated and tested within the client's settings menu.
  • 34-48: The methods noBlockSlowness, noItemSlowness, and noItemSlownessExceptShields provide a clear and concise way to check the conditions for cancelling slowness effects. It's good to see that these methods are leveraging the settings introduced earlier. However, it's important to ensure that these methods are called in the appropriate places within the codebase to effectively apply the NoSlowdown settings. Additionally, consider adding a method comment explaining the purpose and usage of each method for better maintainability.
  • 50-67: The ItemSlowness enum is well-defined, with clear options for different item slowness behaviors. Using an enum for this purpose is a good choice as it makes the code more readable and maintainable. However, ensure that all relevant items are considered when implementing the logic for EXCEPT_SHIELDS. It might be beneficial to document which items are affected by each ItemSlowness option, either in the code comments or in the user documentation, to provide clarity to the users.

Copy link

github-actions bot commented May 1, 2024

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

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.

Actionable comments posted: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9afb47c and 9d93305.
Files selected for processing (1)
  • src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (2 hunks)
Additional Context Used
Learnings (1)
src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (1)
User: Alexander01998
PR: Wurst-Imperium/Wurst7#772
File: src/main/java/net/wurstclient/mixin/PlayerEntityMixin.java:22-22
Timestamp: 2023-12-15T11:22:20.950Z
Learning: Preference for using `@Inject` over `@Redirect` mixins in Minecraft modding to avoid compatibility issues has been noted. This will influence future code reviews where Mixin libraries are used.
Additional comments not posted (1)
src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java (1)

33-33: Import of net.minecraft.util.UseAction added.

This import is necessary for the new logic in onTickMovementItemUse to function correctly, as it checks the UseAction of the item being used.

Comment on lines +100 to +104
if(WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness()
|| (WurstClient.INSTANCE.getHax().noSlowdownHack
.noItemSlownessExceptShields()
&& ((ClientPlayerEntity)(Object)this).getActiveItem()
.getUseAction() != UseAction.BLOCK))
Copy link

@coderabbitai coderabbitai bot May 6, 2024

Choose a reason for hiding this comment

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

Logic to selectively prevent item slowness based on new settings.

Consider breaking this complex conditional into multiple lines or extracting it into a method for better readability and maintainability.

- if(WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness()
-	|| (WurstClient.INSTANCE.getHax().noSlowdownHack
-		.noItemSlownessExceptShields()
-		&& ((ClientPlayerEntity)(Object)this).getActiveItem()
-			.getUseAction() != UseAction.BLOCK))
-	hideNextItemUse = true;
+ boolean shouldHideItemUse = WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness()
+	|| (WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlownessExceptShields()
+		&& getActiveItemUseAction() != UseAction.BLOCK);
+ hideNextItemUse = shouldHideItemUse;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if(WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness()
|| (WurstClient.INSTANCE.getHax().noSlowdownHack
.noItemSlownessExceptShields()
&& ((ClientPlayerEntity)(Object)this).getActiveItem()
.getUseAction() != UseAction.BLOCK))
boolean shouldHideItemUse = WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness()
|| (WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlownessExceptShields()
&& getActiveItemUseAction() != UseAction.BLOCK);
hideNextItemUse = shouldHideItemUse;

Copy link
Member

Choose a reason for hiding this comment

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

@coderabbitai Good idea, bad example. Creating a local variable for WurstClient.INSTANCE.getHax().noSlowdownHack would improve readability in this case.

But also, it seems odd that there are two separate methods noItemSlowness() and noItemSlownessExceptShields() here that both need to be called together like that. A better solution might be to have a single noItemSlowness(boolean shield) method, which would handle the special case for shields internally.

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 absolutely right on both counts.

Creating a local variable for WurstClient.INSTANCE.getHax().noSlowdownHack does indeed make the code cleaner and more readable by reducing redundancy. Additionally, your suggestion to combine noItemSlowness() and noItemSlownessExceptShields() into a single method that internally handles the shield case is an excellent idea. It not only simplifies the calling code but also encapsulates the logic related to item slowness in a more maintainable way.

Here's how the revised code might look:

NoSlowdownHack noSlowdownHack = WurstClient.INSTANCE.getHax().noSlowdownHack;
boolean shouldHideItemUse = noSlowdownHack.noItemSlowness(getActiveItemUseAction() != UseAction.BLOCK);
hideNextItemUse = shouldHideItemUse;

In this version, noItemSlowness(boolean shield) would internally decide the logic based on whether the active item's use action is BLOCK, simplifying the external checks.

Thank you for your insightful suggestions!


New Learnings Added
User: Alexander01998
PR: Wurst-Imperium/Wurst7#800
File: src/main/java/net/wurstclient/mixin/ClientPlayerEntityMixin.java:100-104
Timestamp: 2024-05-07T00:00:25.901Z
Learning: Alexander01998 suggested improving readability by creating a local variable for `WurstClient.INSTANCE.getHax().noSlowdownHack` and combining `noItemSlowness()` and `noItemSlownessExceptShields()` into a single method `noItemSlowness(boolean shield)`.

Note: Learnings are effective only in the context of specific code segments. To apply general coding guidelines, please configure review instructions.

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking more like this:

// The cast to Object and back is necessary because this code is inside of a mixin.
boolean shield = ((ClientPlayerEntity)(Object)this).getActiveItem().getUseAction() == UseAction.BLOCK;
if(WurstClient.INSTANCE.getHax().noSlowdownHack.noItemSlowness(shield))
	hideNextItemUse = true;

Or, if keeping the two methods:

NoSlowdownHack noSlowdown = WurstClient.INSTANCE.getHax().noSlowdownHack;
boolean shield = ((ClientPlayerEntity)(Object)this).getActiveItem().getUseAction() == UseAction.BLOCK;
if(noSlowdown.noItemSlowness() || (noSlowdown.noItemSlownessExceptShields() && shield)
	hideNextItemUse = true;

But the first solution is much cleaner.

Copy link

github-actions bot commented Jul 8, 2024

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.

2 participants