From ed5bd7bf1d24557bfd92827576b5b93e412cd6c4 Mon Sep 17 00:00:00 2001 From: AutumnVN Date: Wed, 25 Dec 2024 14:33:37 +0700 Subject: [PATCH] keep mining when swap --- src/client/java/autumnvn/autumn/Options.java | 3 +++ src/client/java/autumnvn/autumn/SettingsScreen.java | 1 + .../client/ClientPlayerInteractionManagerMixin.java | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/src/client/java/autumnvn/autumn/Options.java b/src/client/java/autumnvn/autumn/Options.java index 030d79a..339de00 100644 --- a/src/client/java/autumnvn/autumn/Options.java +++ b/src/client/java/autumnvn/autumn/Options.java @@ -26,6 +26,7 @@ public class Options { public SimpleOption horseSwim; public SimpleOption infoHud; public SimpleOption instantSneak; + public SimpleOption keepMiningWhenSwap; public SimpleOption noFade; public SimpleOption noFishingBobber; public SimpleOption noFog; @@ -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); diff --git a/src/client/java/autumnvn/autumn/SettingsScreen.java b/src/client/java/autumnvn/autumn/SettingsScreen.java index 64522b5..cc46c72 100644 --- a/src/client/java/autumnvn/autumn/SettingsScreen.java +++ b/src/client/java/autumnvn/autumn/SettingsScreen.java @@ -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, diff --git a/src/client/java/autumnvn/autumn/mixin/client/ClientPlayerInteractionManagerMixin.java b/src/client/java/autumnvn/autumn/mixin/client/ClientPlayerInteractionManagerMixin.java index f1150ec..e75ecc9 100644 --- a/src/client/java/autumnvn/autumn/mixin/client/ClientPlayerInteractionManagerMixin.java +++ b/src/client/java/autumnvn/autumn/mixin/client/ClientPlayerInteractionManagerMixin.java @@ -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 { @@ -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; + } }