Skip to content

Commit

Permalink
Refactor SwingHandSetting
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Apr 4, 2024
1 parent 208154c commit 583e57e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/java/net/wurstclient/hacks/AutoLibrarianHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ private void breakJobSite()
// damage block and swing hand
if(MC.interactionManager.updateBlockBreakingProgress(jobSite,
params.side()))
swingHand.getSelected().swing(Hand.MAIN_HAND);
swingHand.swing(Hand.MAIN_HAND);

// update progress
overlay.updateProgress();
Expand Down Expand Up @@ -359,7 +359,7 @@ private void placeJobSite()

// swing hand
if(result.isAccepted() && result.shouldSwingHand())
swingHand.getSelected().swing(hand);
swingHand.swing(hand);

// reset sneak
((IKeyBinding)MC.options.sneakKey).resetPressedState();
Expand Down Expand Up @@ -401,7 +401,7 @@ private void openTradeScreen()

// swing hand
if(actionResult.isAccepted() && actionResult.shouldSwingHand())
swingHand.getSelected().swing(hand);
swingHand.swing(hand);

// set cooldown
MC.itemUseCooldown = 4;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/wurstclient/hacks/TreeBotHack.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ private boolean breakBlock(BlockPos pos)
// damage block and swing hand
if(MC.interactionManager.updateBlockBreakingProgress(pos,
params.side()))
swingHand.getSelected().swing(Hand.MAIN_HAND);
swingHand.swing(Hand.MAIN_HAND);

// update progress
overlay.updateProgress();
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/net/wurstclient/settings/SwingHandSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public SwingHandSetting(String name, String description, SwingHand selected)
super(name, description, SwingHand.values(), selected);
}

public void swing(Hand hand)
{
getSelected().swing(hand);
}

public enum SwingHand
{
OFF("Off", hand -> {}),
Expand All @@ -44,8 +49,8 @@ public enum SwingHand

CLIENT("Client-side", hand -> MC.player.swingHand(hand));

private String name;
private Consumer<Hand> swing;
private final String name;
private final Consumer<Hand> swing;

private SwingHand(String name, Consumer<Hand> swing)
{
Expand Down

0 comments on commit 583e57e

Please sign in to comment.