AutoCrystalBase module

AutoCrystalBase: Minecraft 26.3 cheat module, full source for every implementation (1 client: MelaHack (ThunderHack fork)).

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.

MelaHack (ThunderHack fork)COMBATsrc/main/java/thunder/hack/features/modules/combat/AutoCrystalBase.javaJava · 237 lines · 11.1 KB

Automatically places obsidian blocks for the end crystals.

SettingsTargetLogicRangeMinDamageDeltaPlaceDelayCalcDelayInteractRotateNotificationDisableNoObbyRenderRenderModeAnimationModeRenderFillColorRenderLineColorRenderLineWidth
AutoCrystalBase.javaJava · Minecraft 26.2 · 237 lines · 11.1 KB · complete file, verbatimOriginal ↗
1
package thunder.hack.features.modules.combat;
2
3
import com.google.common.collect.Lists;
4
import meteordevelopment.orbit.EventHandler;
5
import net.minecraft.ChatFormatting;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.network.protocol.game.ServerboundSwingPacket;
8
import net.minecraft.world.InteractionHand;
9
import net.minecraft.world.entity.player.Player;
10
import net.minecraft.world.level.block.Blocks;
11
import net.minecraft.world.phys.BlockHitResult;
12
import net.minecraft.world.phys.Vec3;
13
import org.jetbrains.annotations.NotNull;
14
import org.jetbrains.annotations.Nullable;
15
import thunder.hack.core.Managers;
16
import thunder.hack.core.manager.client.ModuleManager;
17
import thunder.hack.events.impl.EventPostSync;
18
import thunder.hack.events.impl.EventSync;
19
import thunder.hack.events.impl.EventTick;
20
import thunder.hack.gui.notification.Notification;
21
import thunder.hack.features.modules.Module;
22
import thunder.hack.features.modules.client.HudEditor;
23
import thunder.hack.setting.Setting;
24
import thunder.hack.setting.impl.BooleanSettingGroup;
25
import thunder.hack.setting.impl.ColorSetting;
26
import thunder.hack.utility.Timer;
27
import thunder.hack.utility.world.ExplosionUtility;
28
import thunder.hack.utility.math.MathUtility;
29
import thunder.hack.utility.player.InteractionUtility;
30
import thunder.hack.utility.player.InventoryUtility;
31
import thunder.hack.utility.player.SearchInvResult;
32
import thunder.hack.utility.render.BlockAnimationUtility;
33
34
import java.util.ArrayList;
35
import java.util.List;
36
37
import static thunder.hack.features.modules.client.ClientSettings.isRu;
38
39
public class AutoCrystalBase extends Module {
40
    private final Setting<TargetLogic> targetLogic = new Setting<>("TargetLogic", TargetLogic.Distance);
41
    private final Setting<Integer> range = new Setting<>("Range", 5, 1, 7);
42
    private final Setting<Float> minDamageDelta = new Setting<>("MinDamageDelta", 5f, 1f, 20f);
43
    private final Setting<Integer> placeDelay = new Setting<>("PlaceDelay", 300, 0, 3000);
44
    private final Setting<Integer> calcDelay = new Setting<>("CalcDelay", 150, 0, 3000);
45
    private final Setting<InteractionUtility.Interact> interact = new Setting<>("Interact", InteractionUtility.Interact.Strict);
46
    private final Setting<Boolean> rotate = new Setting<>("Rotate", true);
47
    private final Setting<Boolean> notification = new Setting<>("Notification", true);
48
    private final Setting<Boolean> disableNoObby = new Setting<>("DisableNoObby", false);
49
50
    private final Setting<BooleanSettingGroup> render = new Setting<>("Render", new BooleanSettingGroup(true));
51
    private final Setting<BlockAnimationUtility.BlockRenderMode> renderMode = new Setting<>("RenderMode", BlockAnimationUtility.BlockRenderMode.All).addToGroup(render);
52
    private final Setting<BlockAnimationUtility.BlockAnimationMode> animationMode = new Setting<>("AnimationMode", BlockAnimationUtility.BlockAnimationMode.Fade).addToGroup(render);
53
    private final Setting<ColorSetting> renderFillColor = new Setting<>("RenderFillColor", new ColorSetting(HudEditor.getColor(0))).addToGroup(render);
54
    private final Setting<ColorSetting> renderLineColor = new Setting<>("RenderLineColor", new ColorSetting(HudEditor.getColor(0))).addToGroup(render);
55
    private final Setting<Integer> renderLineWidth = new Setting<>("RenderLineWidth", 2, 1, 5).addToGroup(render);
56
57
    private Player target;
58
    private ObbyData bestData;
59
    private final Timer placeTimer = new Timer();
60
    private final Timer calcTimer = new Timer();
61
62
    public AutoCrystalBase() {
63
        super("AutoCrystalBase", Category.COMBAT);
64
    }
65
66
    @EventHandler
67
    public void onTick(EventTick e) {
68
        if (mc.player == null || mc.level == null) return;
69
70
        if (!InventoryUtility.findBlockInHotBar(Blocks.OBSIDIAN).found() && disableNoObby.getValue()) {
71
            disable(isRu() ? "Нет обсидиана!" : "No obsidian!");
72
            return;
73
        }
74
75
        switch (targetLogic.getValue()) {
76
            case HP -> target = Managers.COMBAT.getTargetByHealth(15);
77
            case Distance -> target = Managers.COMBAT.getNearestTarget(15);
78
            case FOV -> target = Managers.COMBAT.getTargetByFOV(15);
79
        }
80
81
        if (target != null && (target.isDeadOrDying() || target.getHealth() < 0)) {
82
            target = null;
83
            return;
84
        }
85
86
        if (calcTimer.every(calcDelay.getValue()))
87
            Managers.ASYNC.run(() -> calcPosition(range.getValue(), mc.player.position()));
88
    }
89
90
    @EventHandler
91
    public void onSync(EventSync e) {
92
        if (rotate.getValue() && bestData != null && isWorth()) {
93
            float[] angle = InteractionUtility.calculateAngle(bestData.bhr().getLocation());
94
            mc.player.setYRot(angle[0]);
95
            mc.player.setXRot(angle[1]);
96
        }
97
    }
98
99
    @EventHandler
100
    public void onPostSync(EventPostSync e) {
101
        SearchInvResult obbyResult = InventoryUtility.findBlockInHotBar(Blocks.OBSIDIAN);
102
        if (placeTimer.every(placeDelay.getValue()) && bestData != null && obbyResult.found() && isWorth()) {
103
            InventoryUtility.saveSlot();
104
            obbyResult.switchTo();
105
            mc.gameMode.useItemOn(mc.player, InteractionHand.MAIN_HAND, bestData.bhr());
106
            sendPacket(new ServerboundSwingPacket(InteractionHand.MAIN_HAND));
107
            if (render.getValue().isEnabled())
108
                BlockAnimationUtility.renderBlock(bestData.position(),
109
                        renderLineColor.getValue().getColorObject(),
110
                        renderLineWidth.getValue(),
111
                        renderFillColor.getValue().getColorObject(),
112
                        animationMode.getValue(),
113
                        renderMode.getValue()
114
                );
115
116
            if (notification.getValue()) {
117
                String content;
118
                if (isRu())
119
                    content = "Ставлю на" + ChatFormatting.GRAY + " X:" + bestData.position().getX() + " Y:" + bestData.position().getY() + " Z:" + bestData.position().getZ() + ChatFormatting.WHITE + " урон возрастет на " + ChatFormatting.RED + MathUtility.round2(bestData.damage - ModuleManager.autoCrystal.renderDamage);
120
                else
121
                    content = "Placing obby on" + ChatFormatting.GRAY + " X:" + bestData.position().getX() + " Y:" + bestData.position().getY() + " Z:" + bestData.position().getZ() + ChatFormatting.WHITE + " damage will increase by " + ChatFormatting.RED + MathUtility.round2(bestData.damage - ModuleManager.autoCrystal.renderDamage);
122
                Managers.NOTIFICATION.publicity("AutoCrystalBase", content, 2, Notification.Type.INFO);
123
            }
124
125
            InventoryUtility.returnSlot();
126
        }
127
    }
128
129
    public boolean isWorth() {
130
        return ModuleManager.autoCrystal.isEnabled()
131
                && bestData != null
132
                && (ModuleManager.autoCrystal.renderDamage + minDamageDelta.getValue()) < bestData.damage;
133
    }
134
135
    public void calcPosition(float range, Vec3 center) {
136
        if (mc.player == null || mc.level == null) return;
137
138
        if (target == null) {
139
            bestData = null;
140
            return;
141
        }
142
143
        List<ObbyData> list = getPossibleBlocks(target, center, range).stream().filter(data -> ModuleManager.autoCrystal.isSafe(data.damage, data.selfDamage, data.overrideDamage)).toList();
144
145
        if (list.isEmpty()) {
146
            bestData = null;
147
        } else {
148
            bestData = filterPositions(list);
149
        }
150
    }
151
152
    private @NotNull List<ObbyData> getPossibleBlocks(Player target, Vec3 center, float range) {
153
        List<ObbyData> blocks = new ArrayList<>();
154
        BlockPos playerPos = BlockPos.containing(center);
155
        for (int x = (int) Math.floor(playerPos.getX() - range); x <= Math.ceil(playerPos.getX() + range); x++) {
156
            for (int y = (int) Math.floor(playerPos.getY() - range); y <= Math.ceil(playerPos.getY() + range); y++) {
157
                for (int z = (int) Math.floor(playerPos.getZ() - range); z <= Math.ceil(playerPos.getZ() + range); z++) {
158
                    BlockPos bp = new BlockPos(x, y, z);
159
                    if (!mc.level.isEmptyBlock(bp)) continue;
160
                    BlockHitResult placeResult = InteractionUtility.getPlaceResult(bp, interact.getValue(), false);
161
                    if (placeResult != null) {
162
                        AutoCrystal.PlaceData data = getPlaceData(bp, target);
163
                        if (data != null)
164
                            blocks.add(new ObbyData(bp, placeResult, data.damage(), data.selfDamage(), data.overrideDamage()));
165
                    }
166
                }
167
            }
168
        }
169
        return blocks;
170
    }
171
172
    private ObbyData filterPositions(@NotNull List<ObbyData> clearedList) {
173
        ObbyData bestData = null;
174
        float bestVal = 0f;
175
176
        for (ObbyData data : clearedList) {
177
            if ((ModuleManager.autoCrystal.shouldOverrideMinDmg(data.damage) || data.damage > ModuleManager.autoCrystal.minDamage.getValue())) {
178
                if (bestData != null && Math.abs(bestData.damage - data.damage) < 1f) {
179
                    if (bestData.selfDamage >= data.selfDamage) {
180
                        bestData = data;
181
                        bestVal = data.damage;
182
                    }
183
                } else {
184
                    if (bestVal < data.damage) {
185
                        bestData = data;
186
                        bestVal = data.damage;
187
                    }
188
                }
189
            }
190
        }
191
192
        return bestData;
193
    }
194
195
    public @Nullable AutoCrystal.PlaceData getPlaceData(BlockPos bp, Player target) {
196
        if (mc.player == null || mc.level == null) return null;
197
198
        if (!mc.level.isEmptyBlock(bp.above()))
199
            return null;
200
201
        if (ModuleManager.autoCrystal.isPositionBlockedByEntity(bp, true)) return null;
202
203
        Vec3 crystalVec = new Vec3(0.5f + bp.getX(), 1f + bp.getY(), 0.5f + bp.getZ());
204
205
        float damage = target == null ? 10f : ExplosionUtility.getDamageOfGhostBlock(crystalVec, target, bp);
206
        float selfDamage = ExplosionUtility.getDamageOfGhostBlock(crystalVec, mc.player, bp);
207
        boolean overrideDamage = ModuleManager.autoCrystal.shouldOverrideMaxSelfDmg(damage, selfDamage);
208
209
        if (ModuleManager.autoCrystal.protectFriends.getValue()) {
210
            List<Player> players = Lists.newArrayList(mc.level.players());
211
            for (Player pl : players) {
212
                if (!Managers.FRIEND.isFriend(pl)) continue;
213
                float fdamage = ExplosionUtility.getDamageOfGhostBlock(crystalVec, target, bp);
214
                if (fdamage > selfDamage) {
215
                    selfDamage = fdamage;
216
                }
217
            }
218
        }
219
220
        if (damage < 1.5f) return null;
221
        if (selfDamage > ModuleManager.autoCrystal.maxSelfDamage.getValue() && !overrideDamage) return null;
222
223
        BlockHitResult interactResult = ModuleManager.autoCrystal.getInteractResult(bp, crystalVec);
224
        if (interactResult == null) return null;
225
226
        return new AutoCrystal.PlaceData(interactResult, damage, selfDamage, overrideDamage);
227
    }
228
229
    private record ObbyData(BlockPos position, BlockHitResult bhr, float damage, float selfDamage,
230
                            boolean overrideDamage) {
231
    }
232
233
    private enum TargetLogic {
234
        Distance, HP, FOV
235
    }
236
}
237