From 7ab5a7c72ff6993b5514c8954b3dd6b1fef6355f Mon Sep 17 00:00:00 2001 From: moonleay Date: Sat, 27 Apr 2024 04:25:07 +0200 Subject: [PATCH] feat: added Bulldozer Modifier --- README.md | 2 +- .../moonleay/gimble/mixin/BulldozerMixin.java | 35 +++++++++++++++++++ .../gimble/mixin/BulldozerMixin2.java | 26 ++++++++++++++ src/main/resources/gimble.mixins.json | 2 ++ 4 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/moonleay/gimble/mixin/BulldozerMixin.java create mode 100644 src/main/java/net/moonleay/gimble/mixin/BulldozerMixin2.java diff --git a/README.md b/README.md index 50d61e3..2d8dd06 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This project aims to improve the experience of creating structures in Minecraft. - **Replace** Replace blocks in the world [x] ## Modifiers -- **Bulldozer** Basically an auto-clicker +- **Bulldozer** Basically an auto-clicker [x] - **Force Place** Ignore block placing restrictions [x] - **No Clip** Walk and fly through blocks [x] - **No Updates** Prevent block updates [x] diff --git a/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin.java b/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin.java new file mode 100644 index 0000000..461437e --- /dev/null +++ b/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin.java @@ -0,0 +1,35 @@ +package net.moonleay.gimble.mixin; + +import net.minecraft.client.MinecraftClient; +import net.moonleay.gimble.client.editor.ClientEditor; +import net.moonleay.gimble.editor.state.mode.ModeModifier; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(MinecraftClient.class) +public abstract class BulldozerMixin { + + @Shadow protected int attackCooldown; + + @Inject(method = "doAttack", at = @At(value = "HEAD")) + private void func(CallbackInfoReturnable cir) { + if (!ClientEditor.INSTANCE.containsModifier(ModeModifier.BULLDOZER)){ + return; + } + this.attackCooldown = 0; + } + + @Inject(method = "handleBlockBreaking", at = @At(value = "HEAD")) + private void func2(boolean breaking, CallbackInfo ci) { + if (!ClientEditor.INSTANCE.containsModifier(ModeModifier.BULLDOZER) || !breaking){ + return; + } + this.attackCooldown = 0; + } + + +} diff --git a/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin2.java b/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin2.java new file mode 100644 index 0000000..9539155 --- /dev/null +++ b/src/main/java/net/moonleay/gimble/mixin/BulldozerMixin2.java @@ -0,0 +1,26 @@ +package net.moonleay.gimble.mixin; + +import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.moonleay.gimble.client.editor.ClientEditor; +import net.moonleay.gimble.editor.state.mode.ModeModifier; +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ClientPlayerInteractionManager.class) +public class BulldozerMixin2 { + + @Shadow private int blockBreakingCooldown; + + @Inject(method = "updateBlockBreakingProgress", at = @At("HEAD")) + private void func(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { + if (!ClientEditor.INSTANCE.containsModifier(ModeModifier.BULLDOZER)) { + return; + } + this.blockBreakingCooldown = 0; + } +} diff --git a/src/main/resources/gimble.mixins.json b/src/main/resources/gimble.mixins.json index e01db58..c555448 100644 --- a/src/main/resources/gimble.mixins.json +++ b/src/main/resources/gimble.mixins.json @@ -9,6 +9,8 @@ "NoClipMixin" ], "client": [ + "BulldozerMixin", + "BulldozerMixin2", "HudMixin", "NoClipCameraFixMixin", "NormalModeMixin",