auto-anvil module

auto-anvil: Minecraft 26.3 cheat module, full source for every implementation (1 client: Meteor Client).

1 implementationCombat

Clients with this module

Full module source: 1 implementation

Every implementation below is the complete module file, verbatim. Expand a client to read its code.

Meteor ClientCombatsrc/main/java/meteordevelopment/meteorclient/systems/modules/combat/AutoAnvil.javaJava · 161 lines · 5.6 KB

Automatically places anvils above players to destroy helmets.

Settingstarget-rangetarget-priorityheightdelayplace-at-feetmulti-placetoggle-on-breakrotate
AutoAnvil.javaJava · Minecraft 26.2 · 161 lines · 5.6 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
3
 * Copyright (c) Meteor Development.
4
 */
5
6
package meteordevelopment.meteorclient.systems.modules.combat;
7
8
import meteordevelopment.meteorclient.events.game.OpenScreenEvent;
9
import meteordevelopment.meteorclient.events.world.TickEvent;
10
import meteordevelopment.meteorclient.settings.*;
11
import meteordevelopment.meteorclient.systems.modules.Categories;
12
import meteordevelopment.meteorclient.systems.modules.Module;
13
import meteordevelopment.meteorclient.utils.entity.EntityUtils;
14
import meteordevelopment.meteorclient.utils.entity.SortPriority;
15
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
16
import meteordevelopment.meteorclient.utils.player.FindItemResult;
17
import meteordevelopment.meteorclient.utils.player.InvUtils;
18
import meteordevelopment.meteorclient.utils.world.BlockUtils;
19
import meteordevelopment.orbit.EventHandler;
20
import net.minecraft.client.gui.screens.inventory.AnvilScreen;
21
import net.minecraft.core.BlockPos;
22
import net.minecraft.world.entity.EquipmentSlot;
23
import net.minecraft.world.entity.player.Player;
24
import net.minecraft.world.level.block.AnvilBlock;
25
import net.minecraft.world.level.block.BasePressurePlateBlock;
26
import net.minecraft.world.level.block.Block;
27
import net.minecraft.world.level.block.ButtonBlock;
28
29
public class AutoAnvil extends Module {
30
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
31
32
    // General
33
34
    private final Setting<Double> range = sgGeneral.add(new DoubleSetting.Builder()
35
        .name("target-range")
36
        .description("The radius in which players get targeted.")
37
        .defaultValue(4)
38
        .min(0)
39
        .sliderMax(5)
40
        .build()
41
    );
42
43
    private final Setting<SortPriority> priority = sgGeneral.add(new EnumSetting.Builder<SortPriority>()
44
        .name("target-priority")
45
        .description("How to select the player to target.")
46
        .defaultValue(SortPriority.LowestHealth)
47
        .build()
48
    );
49
50
    private final Setting<Integer> height = sgGeneral.add(new IntSetting.Builder()
51
        .name("height")
52
        .description("The height to place anvils at.")
53
        .defaultValue(2)
54
        .range(0, 5)
55
        .sliderMax(5)
56
        .build()
57
    );
58
59
    private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
60
        .name("delay")
61
        .description("The delay in between anvil placements.")
62
        .defaultValue(10)
63
        .min(0)
64
        .sliderMax(50)
65
        .build()
66
    );
67
68
    private final Setting<Boolean> placeButton = sgGeneral.add(new BoolSetting.Builder()
69
        .name("place-at-feet")
70
        .description("Automatically places a button or pressure plate at the targets feet to break the anvils.")
71
        .defaultValue(true)
72
        .build()
73
    );
74
75
    private final Setting<Boolean> multiPlace = sgGeneral.add(new BoolSetting.Builder()
76
        .name("multi-place")
77
        .description("Places multiple anvils at once.")
78
        .defaultValue(true)
79
        .build()
80
    );
81
82
    private final Setting<Boolean> toggleOnBreak = sgGeneral.add(new BoolSetting.Builder()
83
        .name("toggle-on-break")
84
        .description("Toggles when the target's helmet slot is empty.")
85
        .defaultValue(false)
86
        .build()
87
    );
88
89
    private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
90
        .name("rotate")
91
        .description("Automatically rotates towards the position anvils/pressure plates/buttons are placed.")
92
        .defaultValue(true)
93
        .build()
94
    );
95
96
    private Player target;
97
    private int timer;
98
99
    public AutoAnvil() {
100
        super(Categories.Combat, "auto-anvil", "Automatically places anvils above players to destroy helmets.");
101
    }
102
103
    @Override
104
    public void onActivate() {
105
        timer = 0;
106
        target = null;
107
    }
108
109
    @EventHandler
110
    private void onOpenScreen(OpenScreenEvent event) {
111
        if (event.screen instanceof AnvilScreen) event.cancel();
112
    }
113
114
    @EventHandler
115
    private void onTick(TickEvent.Pre event) {
116
        // Head check
117
        if (toggleOnBreak.get() && target != null && target.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
118
            error("Target head slot is empty... disabling.");
119
            toggle();
120
            return;
121
        }
122
123
        // Check distance + alive
124
        if (TargetUtils.isBadTarget(target, range.get())) {
125
            target = TargetUtils.getPlayerTarget(range.get(), priority.get());
126
            if (TargetUtils.isBadTarget(target, range.get())) return;
127
        }
128
129
        if (placeButton.get()) {
130
            FindItemResult floorBlock = InvUtils.findInHotbar(itemStack -> Block.byItem(itemStack.getItem()) instanceof BasePressurePlateBlock || Block.byItem(itemStack.getItem()) instanceof ButtonBlock);
131
            BlockUtils.place(target.blockPosition(), floorBlock, rotate.get(), 0, false);
132
        }
133
134
        if (timer >= delay.get()) {
135
            timer = 0;
136
137
            FindItemResult anvil = InvUtils.findInHotbar(itemStack -> Block.byItem(itemStack.getItem()) instanceof AnvilBlock);
138
            if (!anvil.found()) return;
139
140
            for (int i = height.get(); i > 1; i--) {
141
                BlockPos blockPos = target.blockPosition().above().offset(0, i, 0);
142
143
                for (int j = 0; j < i; j++) {
144
                    if (!mc.level.getBlockState(target.blockPosition().above(j + 1)).canBeReplaced()) {
145
                        break;
146
                    }
147
                }
148
149
                if (BlockUtils.place(blockPos, anvil, rotate.get(), 0) && !multiPlace.get()) break;
150
            }
151
        } else {
152
            timer++;
153
        }
154
    }
155
156
    @Override
157
    public String getInfoString() {
158
        return EntityUtils.getName(target);
159
    }
160
}
161