Skip to content

Commit

Permalink
NoBreakDelay -> BreakDelay, now you can modify the break cooldown (#2865
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hexadecimal233 authored Dec 16, 2022
1 parent f1ca61b commit e0a12e4
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -112,16 +110,22 @@ private void onGetReachDistance(CallbackInfoReturnable<Float> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Integer> 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();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e0a12e4

Please sign in to comment.