diff --git a/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java b/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java new file mode 100644 index 0000000000..837a8b977b --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/events/entity/player/BlockBreakingCooldownEvent.java @@ -0,0 +1,17 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.events.entity.player; + +public class BlockBreakingCooldownEvent { + private static final BlockBreakingCooldownEvent INSTANCE = new BlockBreakingCooldownEvent(); + + public int cooldown; + + public static BlockBreakingCooldownEvent get(int cooldown) { + INSTANCE.cooldown = cooldown; + return INSTANCE; + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java index 062397fdb4..b49ddd0eb5 100644 --- a/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java +++ b/src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayerInteractionManagerMixin.java @@ -11,9 +11,7 @@ import meteordevelopment.meteorclient.mixininterface.IClientPlayerInteractionManager; import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.systems.modules.misc.InventoryTweaks; -import meteordevelopment.meteorclient.systems.modules.player.NoBreakDelay; import meteordevelopment.meteorclient.systems.modules.player.Reach; -import meteordevelopment.meteorclient.systems.modules.world.Nuker; import meteordevelopment.meteorclient.utils.player.Rotations; import meteordevelopment.meteorclient.utils.world.BlockUtils; import net.minecraft.client.network.ClientPlayerEntity; @@ -112,16 +110,22 @@ private void onGetReachDistance(CallbackInfoReturnable info) { info.setReturnValue(Modules.get().get(Reach.class).getReach()); } - @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD)) - private void onMethod_2902SetField_3716Proxy(ClientPlayerInteractionManager interactionManager, int value) { - if (Modules.get().isActive(NoBreakDelay.class) || Modules.get().isActive(Nuker.class)) value = 0; - blockBreakingCooldown = value; + @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", ordinal = 3)) + private void updateBlockBreakingProgress3(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; + } + + @Redirect(method = "updateBlockBreakingProgress", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", ordinal = 4)) + private void updateBlockBreakingProgress4(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; } @Redirect(method = "attackBlock", at = @At(value = "FIELD", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;blockBreakingCooldown:I", opcode = Opcodes.PUTFIELD)) - private void onAttackBlockSetField_3719Proxy(ClientPlayerInteractionManager interactionManager, int value) { - if (Modules.get().isActive(NoBreakDelay.class) || Modules.get().isActive(Nuker.class)) value = 0; - blockBreakingCooldown = value; + private void attackBlock(ClientPlayerInteractionManager interactionManager, int value) { + BlockBreakingCooldownEvent event = MeteorClient.EVENT_BUS.post(BlockBreakingCooldownEvent.get(value)); + blockBreakingCooldown = event.cooldown; } @Inject(method = "breakBlock", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java index e05e1b9551..7894c2b2c8 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/Modules.java @@ -427,7 +427,7 @@ private void initPlayer() { add(new GhostHand()); add(new LiquidInteract()); add(new MiddleClickExtra()); - add(new NoBreakDelay()); + add(new BreakDelay()); add(new NoInteract()); add(new NoMiningTrace()); add(new NoRotate()); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java new file mode 100644 index 0000000000..d5608a2797 --- /dev/null +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/BreakDelay.java @@ -0,0 +1,36 @@ +/* + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). + * Copyright (c) Meteor Development. + */ + +package meteordevelopment.meteorclient.systems.modules.player; + +import meteordevelopment.meteorclient.events.entity.player.BlockBreakingCooldownEvent; +import meteordevelopment.meteorclient.settings.IntSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Categories; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.orbit.EventHandler; + +public class BreakDelay extends Module { + SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting cooldown = sgGeneral.add(new IntSetting.Builder() + .name("cooldown") + .description("Block break cooldown in ticks.") + .defaultValue(0) + .min(0) + .sliderMax(5) + .build() + ); + + public BreakDelay() { + super(Categories.Player, "break-delay", "Changes the delay between breaking blocks."); + } + + @EventHandler() + private void onBlockBreakingCooldown(BlockBreakingCooldownEvent event) { + event.cooldown = cooldown.get(); + } +} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java deleted file mode 100644 index 089e77ac6f..0000000000 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/player/NoBreakDelay.java +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). - * Copyright (c) Meteor Development. - */ - -package meteordevelopment.meteorclient.systems.modules.player; - -import meteordevelopment.meteorclient.systems.modules.Categories; -import meteordevelopment.meteorclient.systems.modules.Module; - -public class NoBreakDelay extends Module { - public NoBreakDelay() { - super(Categories.Player, "no-break-delay", "Completely removes the delay between breaking blocks."); - } -} diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java index b4e6059e9f..ca691ea6cd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/world/Nuker.java @@ -5,6 +5,7 @@ package meteordevelopment.meteorclient.systems.modules.world; +import meteordevelopment.meteorclient.events.entity.player.BlockBreakingCooldownEvent; import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; @@ -18,6 +19,7 @@ import meteordevelopment.meteorclient.utils.world.BlockIterator; import meteordevelopment.meteorclient.utils.world.BlockUtils; import meteordevelopment.orbit.EventHandler; +import meteordevelopment.orbit.EventPriority; import net.minecraft.block.Block; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.util.Hand; @@ -419,6 +421,11 @@ else if (sortMode.get() != SortMode.None) blocks.clear(); }); } + + @EventHandler(priority = EventPriority.HIGHEST) + private void onBlockBreakingCooldown(BlockBreakingCooldownEvent event) { + event.cooldown = 0; + } public enum ListMode { Whitelist,