Skip to content

Commit

Permalink
keep mining when swap
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Dec 25, 2024
1 parent 3ca6cda commit ed5bd7b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client/java/autumnvn/autumn/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Options {
public SimpleOption<Boolean> horseSwim;
public SimpleOption<Boolean> infoHud;
public SimpleOption<Boolean> instantSneak;
public SimpleOption<Boolean> keepMiningWhenSwap;
public SimpleOption<Boolean> noFade;
public SimpleOption<Boolean> noFishingBobber;
public SimpleOption<Boolean> noFog;
Expand Down Expand Up @@ -60,6 +61,8 @@ public Options() {
options.put("infoHud", infoHud);
instantSneak = SimpleOption.ofBoolean("Instant Sneak", value -> Tooltip.of(Text.of("Instantly sneak when holding shift, no animation")), true);
options.put("instantSneak", instantSneak);
keepMiningWhenSwap = SimpleOption.ofBoolean("Keep Mining When Swap", value -> Tooltip.of(Text.of("Keep mining block when swapping item")), true);
options.put("keepMiningWhenSwap", keepMiningWhenSwap);
noFade = SimpleOption.ofBoolean("No Fade", value -> Tooltip.of(Text.of("Remove fade animation on splash & title screen")), true);
options.put("noFade", noFade);
noFishingBobber = SimpleOption.ofBoolean("No Fishing Bobber", value -> Tooltip.of(Text.of("Remove fishing bobber when it hooked on your face")), true);
Expand Down
1 change: 1 addition & 0 deletions src/client/java/autumnvn/autumn/SettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class SettingsScreen extends Screen {
AutumnClient.options.horseSwim,
AutumnClient.options.infoHud,
AutumnClient.options.instantSneak,
AutumnClient.options.keepMiningWhenSwap,
AutumnClient.options.noFade,
AutumnClient.options.noFishingBobber,
AutumnClient.options.noFog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import autumnvn.autumn.AutumnClient;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(ClientPlayerInteractionManager.class)
public class ClientPlayerInteractionManagerMixin {
Expand All @@ -14,4 +18,13 @@ public class ClientPlayerInteractionManagerMixin {
private int blockBreakingCooldown(int original) {
return AutumnClient.options.noMineDelay.getValue() ? 0 : original;
}

@Shadow
private ItemStack selectedStack;

// KeepMiningWhenSwap
@ModifyVariable(method = "isCurrentlyBreaking", at = @At("STORE"))
private ItemStack itemStack(ItemStack original) {
return AutumnClient.options.keepMiningWhenSwap.getValue() ? this.selectedStack : original;
}
}

0 comments on commit ed5bd7b

Please sign in to comment.