AutoBow module

AutoBow: Minecraft 26.3 cheat module, full source for every implementation (2 clients: Combatant, LiquidBounce (Kotlin)).

2 implementationsCOMBAT

Full module source: 2 implementations

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

CombatantCOMBATsrc/main/java/combatant/client/features/module/modules/combat/AutoBow.javaJava · 1,195 lines · 42.9 KB
SettingsautobowRangeautobowPriorityautobowModeautobowMovementCorrectionautobowRotationResetTicksautobowRotationResetThresholdautobowHudRadiusautobowHudThicknessautobowPriorityDistanceLeewayautobowAimThresholdautobowBowRapidFireautobowChargedTicksautobowChargedRandomautobowDelayBetweenShotsautobow_toggles
AutoBow.javaJava · Minecraft 26.2 · 1,195 lines · 42.9 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of the Combatant Client distribution.
3
 * Copyright (c) 2026 pivosos2007.
4
 *
5
 * Licensed under the GNU General Public License v3.0.
6
 */
7
8
package combatant.client.features.module.modules.combat;
9
10
import combatant.client.render.engine.text.BuiltinFontCatalog;
11
import net.minecraft.client.Minecraft;
12
import net.minecraft.client.gui.GuiGraphicsExtractor;
13
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
14
import net.minecraft.client.player.LocalPlayer;
15
import net.minecraft.core.registries.BuiltInRegistries;
16
import net.minecraft.util.Mth;
17
import net.minecraft.world.InteractionHand;
18
import net.minecraft.world.InteractionResult;
19
import net.minecraft.world.entity.LivingEntity;
20
import net.minecraft.world.entity.player.Player;
21
import net.minecraft.world.item.CrossbowItem;
22
import net.minecraft.world.item.ItemStack;
23
import net.minecraft.world.item.Items;
24
import net.minecraft.world.phys.AABB;
25
import net.minecraft.world.phys.Vec2;
26
import net.minecraft.world.phys.Vec3;
27
import combatant.client.config.common.CommonSettingSchemas;
28
import combatant.client.config.common.impl.TargetFilters;
29
import combatant.client.config.values.BooleanMapValue;
30
import combatant.client.config.values.BooleanValue;
31
import combatant.client.config.values.EnumValue;
32
import combatant.client.config.values.NumberValue;
33
import combatant.client.events.EventHandler;
34
import combatant.client.events.impl.EventSync;
35
import combatant.client.events.impl.KeybindIsPressedEvent;
36
import combatant.client.events.impl.RotationUpdateEvent;
37
import combatant.client.features.module.HudPhase;
38
import combatant.client.features.module.Module;
39
import combatant.client.features.module.ModuleCategory;
40
import combatant.client.features.module.ModuleInfo;
41
import combatant.client.features.relations.CategoryRules;
42
import combatant.client.features.relations.CategoryType;
43
import combatant.client.features.relations.EntityFilters;
44
import combatant.client.render.engine.color.RenderColor;
45
import combatant.client.render.engine.core.ViewportContext;
46
import combatant.client.render.engine.math.HudScale;
47
import combatant.client.render.engine.renderer.Renderer2D;
48
import combatant.client.render.engine.text.TextRenderer;
49
import combatant.client.render.helpers.ScreenProjection;
50
import combatant.client.render.helpers.TickDelta;
51
import combatant.client.util.aiming.RotationManager;
52
import combatant.client.util.aiming.RotationTarget;
53
import combatant.client.util.aiming.data.Rotation;
54
import combatant.client.util.aiming.features.MovementCorrection;
55
import combatant.client.util.aiming.raytrace.RotationRaytrace;
56
import combatant.client.util.projectile.ProjectilePredictionUtil;
57
import combatant.client.util.target.TargetManager;
58
import combatant.client.util.target.TargetingUtil;
59
60
import java.util.ArrayList;
61
import java.util.List;
62
import java.util.concurrent.ThreadLocalRandom;
63
64
//todo Description
65
@ModuleInfo(
66
        id = "autobow",
67
        displayName = "AutoBow",
68
        category = ModuleCategory.COMBAT
69
)
70
public class AutoBow extends Module {
71
72
    private static final int COLOR_IDLE = 0x66FFFFFF;
73
    private static final int COLOR_WAIT = 0xFFFFD45A;
74
    private static final int COLOR_LOCK = 0xFF59C9FF;
75
    private static final int COLOR_SHOOT = 0xFF69FF9C;
76
    private static final int TEXT_SHADOW = 0xAA000000;
77
    private static final float RING_SOFTNESS = 1.15f;
78
    private static final float TEXT_SCALE = 1.0f;
79
    private static final float TEXT_OFFSET = 20.0f;
80
    private static final int ROTATION_PRIORITY = 50;
81
    private static final int TRIDENT_THROW_THRESHOLD_TICKS = 10;
82
    private static final int BOW_FULL_PULL_RELEASE_TICKS = 21;
83
    private static final int CROSSBOW_RELEASE_EXTRA_TICKS = 1;
84
    private static final int TRIDENT_RELEASE_EXTRA_TICKS = 1;
85
    private static final float LOCK_RETAIN_MARGIN = 6.0f;
86
    private static final double CLOSE_DIRECT_AIM_RANGE = 6.0;
87
    private static final double TARGET_BOX_INFLATE = 0.08;
88
    private final Minecraft mc = Minecraft.getInstance();
89
90
    private final NumberValue<Double> range = num("autobowRange", 48.0, 4.0, 160.0);
91
    private final EnumValue<TargetingUtil.TargetPriority> priority =
92
            enumCommon(
93
                    "autobowPriority",
94
                    "priority",
95
                    CommonSettingSchemas.COMBAT_PRIORITY,
96
                    TargetingUtil.TargetPriority.DISTANCE,
97
                    TargetingUtil.TargetPriority.values()
98
            );
99
    private final EnumValue<AutomationMode> mode =
100
            enumMode("autobowMode", AutomationMode.FULL_AUTO, AutomationMode.values());
101
    private final EnumValue<MovementCorrection> movementCorrection =
102
            enumCommon(
103
                    "autobowMovementCorrection",
104
                    "movement_correction",
105
                    CommonSettingSchemas.ROTATION_MOVEMENT_CORRECTION,
106
                    MovementCorrection.SILENT,
107
                    MovementCorrection.values()
108
            );
109
    private final NumberValue<Integer> rotationResetTicks =
110
            numCommon(
111
                    "autobowRotationResetTicks",
112
                    "rotation_reset_ticks",
113
                    CommonSettingSchemas.ROTATION_RESET_TICKS,
114
                    1,
115
                    1,
116
                    20
117
            );
118
    private final NumberValue<Float> rotationResetThreshold =
119
            numCommon(
120
                    "autobowRotationResetThreshold",
121
                    "rotation_reset_threshold",
122
                    CommonSettingSchemas.ROTATION_RESET_THRESHOLD,
123
                    2.0f,
124
                    0.1f,
125
                    15.0f
126
            );
127
    private final NumberValue<Double> hudRadius = num("autobowHudRadius", 64.0, 12.0, 240.0);
128
    private final NumberValue<Double> hudThickness = num("autobowHudThickness", 2.5, 1.0, 8.0);
129
    private final NumberValue<Double> priorityDistanceLeeway =
130
            num("autobowPriorityDistanceLeeway", 6.0, 0.0, 24.0);
131
    private final NumberValue<Float> aimThreshold = num("autobowAimThreshold", 1.5f, 0.25f, 6.0f);
132
    private final BooleanValue bowRapidFire = bool("autobowBowRapidFire", false);
133
    private final NumberValue<Integer> chargedTicks = num("autobowChargedTicks", 15, 3, 20);
134
    private final NumberValue<Integer> chargedRandom = num("autobowChargedRandom", 0, 0, 10);
135
    private final NumberValue<Double> delayBetweenShots =
136
            num("autobowDelayBetweenShots", 0.0, 0.0, 5.0);
137
    private final BooleanMapValue toggles = groupCommon(
138
            "autobow_toggles",
139
            "toggles",
140
            CommonSettingSchemas.TARGET_FILTERS
141
    );
142
143
    private Snapshot lastSnapshot = Snapshot.hidden();
144
    private long lastShotAtMs;
145
    private boolean forceReleaseUse;
146
    private boolean forceHoldUse;
147
    private Integer currentChargeRandom;
148
    private int snapshotTick = Integer.MIN_VALUE;
149
    private LivingEntity preferredTarget;
150
    private PendingUse pendingUse;
151
    private boolean rotationRequested;
152
153
    @Override
154
    public HudPhase getHudPhase() {
155
        return HudPhase.LAST;
156
    }
157
158
    @Override
159
    public void onEnable() {
160
        lastShotAtMs = 0L;
161
        lastSnapshot = Snapshot.hidden();
162
        forceReleaseUse = false;
163
        forceHoldUse = false;
164
        currentChargeRandom = null;
165
        snapshotTick = Integer.MIN_VALUE;
166
        preferredTarget = null;
167
        pendingUse = null;
168
        rotationRequested = false;
169
    }
170
171
    @Override
172
    public void onDisable() {
173
        lastSnapshot = Snapshot.hidden();
174
        forceReleaseUse = false;
175
        forceHoldUse = false;
176
        currentChargeRandom = null;
177
        snapshotTick = Integer.MIN_VALUE;
178
        preferredTarget = null;
179
        pendingUse = null;
180
        releaseRotationIfRequested();
181
        TargetManager.setModuleTarget(null);
182
    }
183
184
    @EventHandler(priority = 100)
185
    private void onKeybindIsPressed(KeybindIsPressedEvent event) {
186
        if (!isEnabled() || mc.options == null) {
187
            return;
188
        }
189
        if (event.getKeyBinding() != mc.options.keyUse) {
190
            return;
191
        }
192
        if (!forceReleaseUse) {
193
            if (forceHoldUse) {
194
                event.setPressed(true);
195
            }
196
            return;
197
        }
198
199
        event.setPressed(false);
200
    }
201
202
    @Override
203
    public void onTick() {
204
        if (!isEnabled()) return;
205
206
        Snapshot snapshot = getSnapshot(TickDelta.get());
207
        boolean canRotate = canRotateForWeaponState(mc.player, snapshot.weapon());
208
        boolean inside = snapshot.insideRadius();
209
        forceHoldUse = shouldHoldUseForFullAuto(snapshot);
210
        TargetManager.setModuleTarget(inside ? snapshot.target() : null);
211
212
        if (mode.get() == AutomationMode.FULL_AUTO && inside) {
213
            tryAutoDraw(snapshot);
214
        }
215
216
        if (mode.get() != AutomationMode.FULL_AUTO) {
217
            return;
218
        }
219
220
        if (!inside || snapshot.state() != HudState.SHOOT) {
221
            return;
222
        }
223
224
        tryAutoShoot(snapshot);
225
    }
226
227
    public void onInputCycleHandled() {
228
        forceReleaseUse = false;
229
    }
230
231
    public boolean shouldCancelVanillaDoItemUse() {
232
        if (!isEnabled() || mc.player == null) {
233
            return false;
234
        }
235
236
        if (pendingUse != null) {
237
            return true;
238
        }
239
240
        Snapshot snapshot = getSnapshot(TickDelta.get());
241
        ActiveWeapon weapon = snapshot.weapon();
242
        return weapon != null
243
                && weapon.type() == WeaponType.CROSSBOW
244
                && snapshot.target() != null
245
                && snapshot.insideRadius();
246
    }
247
248
    @EventHandler(priority = -1000)
249
    private void onSync(EventSync event) {
250
        if (!isEnabled()) {
251
            return;
252
        }
253
254
        LocalPlayer player = mc.player;
255
        MultiPlayerGameMode manager = mc.gameMode;
256
        PendingUse use = pendingUse;
257
        if (player == null || manager == null || use == null) {
258
            return;
259
        }
260
261
        if (player.tickCount > use.expireAge()) {
262
            pendingUse = null;
263
            return;
264
        }
265
266
        ItemStack stack = player.getItemInHand(use.hand());
267
        if (!canUseStackForAction(player, stack, use.action())) {
268
            pendingUse = null;
269
            return;
270
        }
271
272
        Rotation rotation = use.rotation();
273
        if (rotation == null) {
274
            pendingUse = null;
275
            return;
276
        }
277
278
        pendingUse = null;
279
        event.setRotation(rotation.yaw(), rotation.pitch(), true);
280
281
        float prevYaw = player.getYRot();
282
        float prevPitch = player.getXRot();
283
        player.setYRot(rotation.yaw());
284
        player.setXRot(rotation.pitch());
285
        event.addPostAction(() -> {
286
            player.setYRot(prevYaw);
287
            player.setXRot(prevPitch);
288
        });
289
290
        InteractionResult result = manager.useItem(player, use.hand());
291
        if (result.consumesAction()) {
292
            if (use.action() == UseAction.FIRE_CROSSBOW) {
293
                lastShotAtMs = System.currentTimeMillis();
294
            }
295
        }
296
    }
297
298
    @Override
299
    public void onRenderHudEngine(Renderer2D renderer, TextRenderer textRenderer, GuiGraphicsExtractor ctx, float tickDelta) {
300
        if (!isEnabled() || ctx == null) return;
301
        if (mc.player == null || mc.level == null) return;
302
        if (!mc.options.getCameraType().isFirstPerson()) return;
303
304
        Snapshot snapshot = getSnapshot(tickDelta);
305
        if (!snapshot.showHud()) {
306
            return;
307
        }
308
309
        int fbw = mc.getWindow().getWidth();
310
        int fbh = mc.getWindow().getHeight();
311
        float logicalWidth = HudScale.virtualWidth(fbw, fbh);
312
        float logicalHeight = HudScale.virtualHeight(fbw, fbh);
313
        float centerX = logicalWidth * 0.5f;
314
        float centerY = logicalHeight * 0.5f;
315
        float radiusValue = hudRadius.get().floatValue();
316
        float thicknessValue = hudThickness.get().floatValue();
317
        int color = snapshot.state().color;
318
319
        ViewportContext.beginUnscaledLogical(ctx);
320
        try {
321
            renderer.circleStroke(centerX, centerY, radiusValue, thicknessValue, RING_SOFTNESS, color);
322
            if (snapshot.state().cross) {
323
                float halfLength = radiusValue * 0.64f;
324
                drawCross(renderer, centerX, centerY, halfLength, Math.max(1.0f, thicknessValue * 0.8f), color);
325
            }
326
            renderStateText(textRenderer, centerX, centerY - radiusValue - TEXT_OFFSET, snapshot.state());
327
        } finally {
328
            ViewportContext.beginUnscaled(ctx);
329
        }
330
    }
331
332
    @EventHandler(priority = 15)
333
    private void onRotationUpdate(RotationUpdateEvent event) {
334
        if (event.getType() != RotationUpdateEvent.Type.PRE) {
335
            return;
336
        }
337
338
        if (!isEnabled()) return;
339
340
        Snapshot snapshot = getSnapshot(TickDelta.get());
341
        boolean canRotate = canRotateForWeaponState(mc.player, snapshot.weapon());
342
        boolean inside = snapshot.insideRadius();
343
        TargetManager.setModuleTarget(inside ? snapshot.target() : null);
344
345
        if (!snapshot.shouldRotate() || !canRotate) {
346
            releaseRotationIfRequested();
347
            return;
348
        }
349
350
        RotationTarget target = new RotationTarget(
351
                snapshot.solution(),
352
                snapshot.target(),
353
                List.of(),
354
                rotationResetTicks.get(),
355
                rotationResetThreshold.get(),
356
                true,
357
                movementCorrection.get(),
358
                null
359
        );
360
        RotationManager.INSTANCE.setRotationTarget(target, ROTATION_PRIORITY, this);
361
        rotationRequested = true;
362
    }
363
364
    private void releaseRotationIfRequested() {
365
        if (!rotationRequested) {
366
            return;
367
        }
368
369
        RotationManager.INSTANCE.release(this);
370
        rotationRequested = false;
371
    }
372
373
    private Snapshot evaluateSnapshot(float tickDelta) {
374
        LocalPlayer player = mc.player;
375
        if (player == null || mc.level == null) {
376
            return Snapshot.hidden();
377
        }
378
379
        ActiveWeapon weapon = findActiveWeapon(player);
380
        if (weapon == null) {
381
            return Snapshot.hidden();
382
        }
383
384
        int fbw = mc.getWindow().getWidth();
385
        int fbh = mc.getWindow().getHeight();
386
        float logicalWidth = HudScale.virtualWidth(fbw, fbh);
387
        float logicalHeight = HudScale.virtualHeight(fbw, fbh);
388
        float baseRadius = hudRadius.get().floatValue();
389
        TargetingUtil.TargetingSettings settings = buildTargetingSettings();
390
        if (player.isUsingItem() && preferredTarget != null) {
391
            Snapshot lockedSnapshot = evaluateTargetCandidate(
392
                    player,
393
                    weapon,
394
                    preferredTarget,
395
                    logicalWidth,
396
                    logicalHeight,
397
                    tickDelta,
398
                    baseRadius + LOCK_RETAIN_MARGIN,
399
                    false
400
            );
401
            if (lockedSnapshot != null) {
402
                return lockedSnapshot;
403
            }
404
            preferredTarget = null;
405
            return Snapshot.idle(weapon);
406
        }
407
408
        if (preferredTarget != null) {
409
            Snapshot stickySnapshot = evaluateTargetCandidate(
410
                    player,
411
                    weapon,
412
                    preferredTarget,
413
                    logicalWidth,
414
                    logicalHeight,
415
                    tickDelta,
416
                    baseRadius + LOCK_RETAIN_MARGIN,
417
                    true
418
            );
419
            if (stickySnapshot != null) {
420
                return stickySnapshot;
421
            }
422
            preferredTarget = null;
423
        }
424
425
        for (LivingEntity target : getPrioritizedCandidates(settings)) {
426
            Snapshot candidate = evaluateTargetCandidate(
427
                    player,
428
                    weapon,
429
                    target,
430
                    logicalWidth,
431
                    logicalHeight,
432
                    tickDelta,
433
                    baseRadius,
434
                    true
435
            );
436
            if (candidate == null) {
437
                continue;
438
            }
439
440
            preferredTarget = candidate.target();
441
            return candidate;
442
        }
443
444
        preferredTarget = null;
445
446
        if (mode.get() == AutomationMode.FULL_AUTO && player.isUsingItem()) {
447
            return Snapshot.idle(weapon);
448
        }
449
450
        return Snapshot.idle(weapon);
451
    }
452
453
    private List<LivingEntity> getPrioritizedCandidates(TargetingUtil.TargetingSettings settings) {
454
        List<LivingEntity> sortedByPriority = TargetingUtil.findTargets(mc, settings);
455
        if (sortedByPriority.isEmpty() || mc.player == null) {
456
            return sortedByPriority;
457
        }
458
459
        TargetingUtil.TargetPriority selectedPriority = settings.priority();
460
        if (selectedPriority == null || selectedPriority == TargetingUtil.TargetPriority.DISTANCE) {
461
            return sortedByPriority;
462
        }
463
464
        TargetingUtil.TargetingSettings distanceSettings = new TargetingUtil.TargetingSettings(
465
                settings.range(),
466
                settings.fov(),
467
                settings.playersOnly(),
468
                settings.ignoreFriends(),
469
                settings.ignoreStaff(),
470
                settings.ignoreEnemies(),
471
                settings.ignoreNaked(),
472
                settings.ignoreEntities(),
473
                settings.visibleOnly(),
474
                TargetingUtil.TargetPriority.DISTANCE
475
        );
476
477
        List<LivingEntity> byDistance = TargetingUtil.findTargets(mc, distanceSettings);
478
        if (byDistance.isEmpty()) {
479
            return sortedByPriority;
480
        }
481
482
        LivingEntity distanceAnchor = byDistance.get(0);
483
        if (!settings.playersOnly()) {
484
            for (LivingEntity candidate : byDistance) {
485
                if (candidate instanceof Player) {
486
                    distanceAnchor = candidate;
487
                    break;
488
                }
489
            }
490
        }
491
492
        double nearestDistance = Math.sqrt(TargetingUtil.distanceToEntityBoxSq(mc.player.getEyePosition(), distanceAnchor));
493
        double maxAllowedDistance = nearestDistance + priorityDistanceLeeway.get();
494
495
        List<LivingEntity> closePool = new ArrayList<>();
496
        for (LivingEntity target : sortedByPriority) {
497
            double distance = Math.sqrt(TargetingUtil.distanceToEntityBoxSq(mc.player.getEyePosition(), target));
498
            if (distance <= maxAllowedDistance) {
499
                closePool.add(target);
500
            }
501
        }
502
503
        return closePool.isEmpty() ? sortedByPriority : closePool;
504
    }
505
506
    private Snapshot refreshSnapshot(float tickDelta) {
507
        if (mc.player == null) {
508
            snapshotTick = Integer.MIN_VALUE;
509
            return lastSnapshot = Snapshot.hidden();
510
        }
511
512
        snapshotTick = mc.player.tickCount;
513
        lastSnapshot = evaluateSnapshot(tickDelta);
514
        return lastSnapshot;
515
    }
516
517
    private Snapshot getSnapshot(float tickDelta) {
518
        if (mc.player == null) {
519
            snapshotTick = Integer.MIN_VALUE;
520
            return Snapshot.hidden();
521
        }
522
523
        if (snapshotTick != mc.player.tickCount) {
524
            return refreshSnapshot(tickDelta);
525
        }
526
        return lastSnapshot;
527
    }
528
529
    private Snapshot evaluateTargetCandidate(LocalPlayer player,
530
                                             ActiveWeapon weapon,
531
                                             LivingEntity target,
532
                                             float logicalWidth,
533
                                             float logicalHeight,
534
                                             float tickDelta,
535
                                             float radius,
536
                                             boolean requireReachableTrajectory) {
537
        if (target == null || !target.isAlive() || target.isRemoved()) {
538
            return null;
539
        }
540
541
        Vec2 point = projectTargetToLogical(target, logicalWidth, logicalHeight, tickDelta);
542
        if (!isInsideCircle(point, logicalWidth, logicalHeight, radius)) {
543
            return null;
544
        }
545
546
        boolean directlyVisible = hasDirectSightToTarget(player, target);
547
        if (toggles.get(TargetFilters.VISIBLE_ONLY) && !directlyVisible) {
548
            return null;
549
        }
550
551
        Rotation solution = ProjectilePredictionUtil.calculateForItem(
552
                player,
553
                weapon.stack(),
554
                target,
555
                shouldUseFullPowerAim(weapon)
556
        );
557
        if (solution == null && directlyVisible
558
                && TargetingUtil.distanceToEntityBoxSq(player.getEyePosition(), target)
559
                <= CLOSE_DIRECT_AIM_RANGE * CLOSE_DIRECT_AIM_RANGE) {
560
            var direct = RotationRaytrace.raytraceBox(
561
                    player.getEyePosition(),
562
                    target.getBoundingBox().inflate(TARGET_BOX_INFLATE),
563
                    CLOSE_DIRECT_AIM_RANGE,
564
                    0.0
565
            );
566
            solution = direct != null ? direct.rotation() : null;
567
        }
568
        if (solution == null) {
569
            return null;
570
        }
571
572
        Rotation normalized = solution.normalize();
573
        boolean trajectoryReady = ProjectilePredictionUtil.getHypotheticalHit(
574
                player,
575
                weapon.stack(),
576
                normalized,
577
                living -> living == target,
578
                shouldUseFullPowerAim(weapon)
579
        ) == target;
580
        if (requireReachableTrajectory && !trajectoryReady && !directlyVisible) {
581
            return null;
582
        }
583
584
        boolean chargeReady = isChargeReady(player, weapon);
585
        boolean aimReady = RotationManager.INSTANCE.getServerRotation().approximatelyEquals(normalized, aimThreshold.get());
586
        boolean shootReady = mode.get() == AutomationMode.FULL_AUTO
587
                && chargeReady
588
                && aimReady
589
                && (trajectoryReady || directlyVisible)
590
                && canAutoShoot(player, weapon, target);
591
        HudState state;
592
        if (shootReady) {
593
            state = HudState.SHOOT;
594
        } else if (!chargeReady) {
595
            state = HudState.WAIT;
596
        } else if (mode.get() == AutomationMode.AIM_ONLY) {
597
            state = HudState.SHOOT;
598
        } else {
599
            state = HudState.LOCK;
600
        }
601
        return Snapshot.withState(weapon, target, normalized, point, true, chargeReady, aimReady, state);
602
    }
603
604
    private TargetingUtil.TargetingSettings buildTargetingSettings() {
605
        return new TargetingUtil.TargetingSettings(
606
                range.get(),
607
                180.0f,
608
                toggles.get(TargetFilters.PLAYERS_ONLY),
609
                toggles.get(TargetFilters.IGNORE_FRIENDS),
610
                toggles.get(TargetFilters.IGNORE_STAFF),
611
                toggles.get(TargetFilters.IGNORE_ENEMIES),
612
                toggles.get(TargetFilters.IGNORE_NAKED),
613
                toggles.get(TargetFilters.IGNORE_ENTITIES),
614
                false,
615
                priority.get()
616
        );
617
    }
618
619
    private ActiveWeapon findActiveWeapon(LocalPlayer player) {
620
        if (player.isUsingItem()) {
621
            InteractionHand activeHand = player.getUsedItemHand();
622
            ItemStack activeStack = player.getUseItem();
623
            if (activeStack.is(Items.BOW)) {
624
                return new ActiveWeapon(activeHand, activeStack, WeaponType.BOW);
625
            }
626
            if (activeStack.is(Items.CROSSBOW)) {
627
                return new ActiveWeapon(activeHand, activeStack, WeaponType.CROSSBOW);
628
            }
629
            if (activeStack.is(Items.TRIDENT)) {
630
                return new ActiveWeapon(activeHand, activeStack, WeaponType.TRIDENT);
631
            }
632
        }
633
634
        for (InteractionHand hand : InteractionHand.values()) {
635
            ItemStack stack = player.getItemInHand(hand);
636
            if (stack.isEmpty()) {
637
                continue;
638
            }
639
            if (stack.is(Items.CROSSBOW) && CrossbowItem.isCharged(stack)) {
640
                return new ActiveWeapon(hand, stack, WeaponType.CROSSBOW);
641
            }
642
            if (stack.is(Items.BOW)) {
643
                return new ActiveWeapon(hand, stack, WeaponType.BOW);
644
            }
645
            if (stack.is(Items.CROSSBOW)) {
646
                return new ActiveWeapon(hand, stack, WeaponType.CROSSBOW);
647
            }
648
            if (stack.is(Items.TRIDENT)) {
649
                return new ActiveWeapon(hand, stack, WeaponType.TRIDENT);
650
            }
651
        }
652
653
        return null;
654
    }
655
656
    private boolean shouldAlwaysShowBow(LocalPlayer player, ActiveWeapon weapon) {
657
        return weapon.type() == WeaponType.BOW
658
                && (!player.isUsingItem() || player.getUsedItemHand() != weapon.hand());
659
    }
660
661
    private boolean canRotateForWeaponState(LocalPlayer player, ActiveWeapon weapon) {
662
        if (player == null || weapon == null) {
663
            return false;
664
        }
665
666
        return switch (weapon.type()) {
667
            case BOW, TRIDENT -> player.isUsingItem() && player.getUsedItemHand() == weapon.hand();
668
            case CROSSBOW -> isCrossbowReadyForRotation(player, weapon);
669
        };
670
    }
671
672
    private boolean isCrossbowReadyForRotation(LocalPlayer player, ActiveWeapon weapon) {
673
        if (CrossbowItem.isCharged(weapon.stack())) {
674
            return true;
675
        }
676
677
        // Crossbow should keep tracking throughout the whole charge window,
678
        // otherwise it feels inconsistent compared to bow and may never settle in time.
679
        return player.isUsingItem() && player.getUsedItemHand() == weapon.hand();
680
    }
681
682
    private boolean shouldHoldUseForFullAuto(Snapshot snapshot) {
683
        if (mode.get() != AutomationMode.FULL_AUTO || snapshot == null) {
684
            return false;
685
        }
686
687
        if (!snapshot.insideRadius() || snapshot.target() == null) {
688
            return false;
689
        }
690
691
        ActiveWeapon weapon = snapshot.weapon();
692
        if (weapon == null) {
693
            return false;
694
        }
695
696
        return switch (weapon.type()) {
697
            case BOW, TRIDENT -> false;
698
            case CROSSBOW -> !CrossbowItem.isCharged(weapon.stack());
699
        };
700
    }
701
702
    private boolean shouldUseFullPowerAim(ActiveWeapon weapon) {
703
        return weapon != null && weapon.type() == WeaponType.BOW;
704
    }
705
706
    private boolean isChargeReady(LocalPlayer player, ActiveWeapon weapon) {
707
        return switch (weapon.type()) {
708
            case BOW -> isBowChargeReady(player, weapon);
709
            case CROSSBOW -> CrossbowItem.isCharged(weapon.stack())
710
                    || (player.isUsingItem()
711
                    && player.getUsedItemHand() == weapon.hand()
712
                    && player.getTicksUsingItem() >= CrossbowItem.getChargeDuration(weapon.stack(), player) + CROSSBOW_RELEASE_EXTRA_TICKS);
713
            case TRIDENT -> player.isUsingItem()
714
                    && player.getUsedItemHand() == weapon.hand()
715
                    && player.getTicksUsingItem() > TRIDENT_THROW_THRESHOLD_TICKS + TRIDENT_RELEASE_EXTRA_TICKS;
716
        };
717
    }
718
719
    private int getBowChargeThreshold() {
720
        return chargedTicks.get() + getChargedRandom();
721
    }
722
723
    private boolean isBowChargeReady(LocalPlayer player, ActiveWeapon weapon) {
724
        if (!player.isUsingItem() || player.getUsedItemHand() != weapon.hand()) {
725
            return false;
726
        }
727
728
        if (bowRapidFire.get()) {
729
            return player.getTicksUsingItem() > getBowChargeThreshold();
730
        }
731
732
        return player.getTicksUsingItem() >= BOW_FULL_PULL_RELEASE_TICKS;
733
    }
734
735
    private int getChargedRandom() {
736
        if (currentChargeRandom == null) {
737
            updateChargeRandom();
738
        }
739
        return currentChargeRandom;
740
    }
741
742
    private void updateChargeRandom() {
743
        int random = chargedRandom.get();
744
        if (random <= 0) {
745
            currentChargeRandom = 0;
746
            return;
747
        }
748
749
        int offset = (int) Math.round(ThreadLocalRandom.current().nextGaussian() * (random / 2.0));
750
        currentChargeRandom = Mth.clamp(offset, -random, random);
751
    }
752
753
    private Vec2 projectTargetToLogical(LivingEntity target, float logicalWidth, float logicalHeight, float tickDelta) {
754
        if (target == null || mc.gameRenderer == null || mc.player == null) {
755
            return null;
756
        }
757
758
        AABB box = target.getBoundingBox().inflate(TARGET_BOX_INFLATE);
759
        float centerX = logicalWidth * 0.5f;
760
        float centerY = logicalHeight * 0.5f;
761
762
        Vec3 eye = mc.gameRenderer.mainCamera().position();
763
        Vec3 look = mc.player.getViewVector(tickDelta).normalize();
764
        if (box.contains(eye)
765
                || box.clip(eye, eye.add(look.scale(range.get()))).isPresent()) {
766
            return new Vec2(centerX, centerY);
767
        }
768
769
        double[] xs = {box.minX, box.maxX};
770
        double[] ys = {box.minY, box.maxY};
771
        double[] zs = {box.minZ, box.maxZ};
772
773
        float minX = Float.POSITIVE_INFINITY;
774
        float minY = Float.POSITIVE_INFINITY;
775
        float maxX = Float.NEGATIVE_INFINITY;
776
        float maxY = Float.NEGATIVE_INFINITY;
777
        int projectedCount = 0;
778
779
        for (double x : xs) {
780
            for (double y : ys) {
781
                for (double z : zs) {
782
                    Vec2 projected = projectWorldToLogical(
783
                            new Vec3(x, y, z),
784
                            logicalWidth,
785
                            logicalHeight,
786
                            tickDelta
787
                    );
788
                    if (projected == null) {
789
                        continue;
790
                    }
791
792
                    minX = Math.min(minX, projected.x);
793
                    minY = Math.min(minY, projected.y);
794
                    maxX = Math.max(maxX, projected.x);
795
                    maxY = Math.max(maxY, projected.y);
796
                    projectedCount++;
797
                }
798
            }
799
        }
800
801
        Vec2 projectedCenter = projectWorldToLogical(box.getCenter(), logicalWidth, logicalHeight, tickDelta);
802
        if (projectedCenter != null) {
803
            minX = Math.min(minX, projectedCenter.x);
804
            minY = Math.min(minY, projectedCenter.y);
805
            maxX = Math.max(maxX, projectedCenter.x);
806
            maxY = Math.max(maxY, projectedCenter.y);
807
            projectedCount++;
808
        }
809
810
        if (projectedCount == 0) {
811
            return null;
812
        }
813
814
        return new Vec2(
815
                Mth.clamp(centerX, minX, maxX),
816
                Mth.clamp(centerY, minY, maxY)
817
        );
818
    }
819
820
    private Vec2 projectWorldToLogical(Vec3 worldPos, float logicalWidth, float logicalHeight, float tickDelta) {
821
        int framebufferWidth = mc.getWindow().getWidth();
822
        int framebufferHeight = mc.getWindow().getHeight();
823
        if (framebufferWidth <= 0 || framebufferHeight <= 0) {
824
            return null;
825
        }
826
827
        Vec3 screen = ScreenProjection.worldToScreen(worldPos, tickDelta);
828
        if (screen == null) {
829
            return null;
830
        }
831
832
        float x = (float) (screen.x / framebufferWidth * logicalWidth);
833
        float y = (float) (screen.y / framebufferHeight * logicalHeight);
834
        return new Vec2(x, y);
835
    }
836
837
    private Vec2 projectRotationToLogical(LocalPlayer player, Rotation solution, float logicalWidth, float logicalHeight, float tickDelta) {
838
        if (player == null || mc.gameRenderer == null) {
839
            return null;
840
        }
841
        int framebufferWidth = mc.getWindow().getWidth();
842
        int framebufferHeight = mc.getWindow().getHeight();
843
        if (framebufferWidth <= 0 || framebufferHeight <= 0) {
844
            return null;
845
        }
846
847
        Vec3 origin = mc.gameRenderer.mainCamera().position();
848
        Vec3 probe = origin.add(solution.directionVector().normalize().scale(96.0));
849
        Vec3 screen = ScreenProjection.worldToScreen(probe, tickDelta);
850
        if (screen == null) {
851
            return null;
852
        }
853
854
        float x = (float) (screen.x / framebufferWidth * logicalWidth);
855
        float y = (float) (screen.y / framebufferHeight * logicalHeight);
856
        return new Vec2(x, y);
857
    }
858
859
    private boolean isInsideCircle(Vec2 point, float logicalWidth, float logicalHeight) {
860
        return isInsideCircle(point, logicalWidth, logicalHeight, hudRadius.get().floatValue());
861
    }
862
863
    private boolean isInsideCircle(Vec2 point, float logicalWidth, float logicalHeight, float radiusValue) {
864
        if (point == null) {
865
            return false;
866
        }
867
868
        float centerX = logicalWidth * 0.5f;
869
        float centerY = logicalHeight * 0.5f;
870
        float dx = point.x - centerX;
871
        float dy = point.y - centerY;
872
        return dx * dx + dy * dy <= radiusValue * radiusValue;
873
    }
874
875
    private void renderStateText(TextRenderer textRenderer, float centerX, float y, HudState state) {
876
        if (state.label.isEmpty()) {
877
            return;
878
        }
879
880
        TextRenderer renderer = BuiltinFontCatalog.ONEST_MEDIUM.renderer(textRenderer);
881
        float width = (float) renderer.getWidth(state.label, false) * TEXT_SCALE;
882
        float height = (float) renderer.getHeight(false) * TEXT_SCALE;
883
        float x = centerX - width * 0.5f;
884
        float baseY = y - height * 0.5f;
885
886
        renderer.begin(TEXT_SCALE);
887
        renderer.render(state.label, x + 1.0f, baseY + 1.0f, new RenderColor(TEXT_SHADOW), false);
888
        renderer.render(state.label, x, baseY, new RenderColor(state.color), false);
889
        renderer.end();
890
    }
891
892
    private void drawCross(Renderer2D renderer, float centerX, float centerY, float halfLength, float thickness, int color) {
893
        drawThickLine(renderer, centerX - halfLength, centerY - halfLength, centerX + halfLength, centerY + halfLength, thickness, color);
894
        drawThickLine(renderer, centerX - halfLength, centerY + halfLength, centerX + halfLength, centerY - halfLength, thickness, color);
895
    }
896
897
    private void drawThickLine(Renderer2D renderer, float x1, float y1, float x2, float y2, float thickness, int color) {
898
        float dx = x2 - x1;
899
        float dy = y2 - y1;
900
        float length = Mth.sqrt(dx * dx + dy * dy);
901
        if (length <= 0.0f) {
902
            return;
903
        }
904
905
        float nx = -dy / length;
906
        float ny = dx / length;
907
        int layers = Math.max(1, Math.round(thickness));
908
        float start = -(layers - 1) * 0.5f;
909
        for (int i = 0; i < layers; i++) {
910
            float offset = start + i;
911
            float ox = nx * offset;
912
            float oy = ny * offset;
913
            renderer.line(x1 + ox, y1 + oy, x2 + ox, y2 + oy, color);
914
        }
915
    }
916
917
    private void tryAutoShoot(Snapshot snapshot) {
918
        LocalPlayer player = mc.player;
919
        MultiPlayerGameMode manager = mc.gameMode;
920
        if (player == null || manager == null) {
921
            return;
922
        }
923
924
        ActiveWeapon weapon = snapshot.weapon();
925
        if (weapon == null) {
926
            return;
927
        }
928
929
        long now = System.currentTimeMillis();
930
        long delayMs = (long) (delayBetweenShots.get() * 1000.0);
931
        if (!canAutoShoot(player, weapon, snapshot.target())) {
932
            return;
933
        }
934
935
        switch (weapon.type()) {
936
            case BOW, TRIDENT -> {
937
                if (now - lastShotAtMs < delayMs) {
938
                    return;
939
                }
940
                if (player.isUsingItem() && player.getUsedItemHand() == weapon.hand()) {
941
                    forceReleaseUse = true;
942
                    if (weapon.type() == WeaponType.BOW) {
943
                        updateChargeRandom();
944
                    }
945
                    lastShotAtMs = now;
946
                }
947
            }
948
            case CROSSBOW -> {
949
                if (player.isUsingItem() && player.getUsedItemHand() == weapon.hand()) {
950
                    if (player.getTicksUsingItem() >= CrossbowItem.getChargeDuration(weapon.stack(), player)) {
951
                        forceReleaseUse = true;
952
                    }
953
                    return;
954
                }
955
                if (now - lastShotAtMs < delayMs) {
956
                    return;
957
                }
958
                if (CrossbowItem.isCharged(weapon.stack())) {
959
                    Rotation shotRotation = snapshot.solution();
960
                    if (shotRotation != null && pendingUse == null) {
961
                        pendingUse = new PendingUse(
962
                                weapon.hand(),
963
                                shotRotation,
964
                                player.tickCount + 1,
965
                                UseAction.FIRE_CROSSBOW
966
                        );
967
                    }
968
                }
969
            }
970
        }
971
    }
972
973
    private void tryAutoDraw(Snapshot snapshot) {
974
        LocalPlayer player = mc.player;
975
        if (player == null || mc.gameMode == null) {
976
            return;
977
        }
978
979
        ActiveWeapon weapon = snapshot.weapon();
980
        if (weapon == null) {
981
            return;
982
        }
983
984
        if (player.isUsingItem()) {
985
            return;
986
        }
987
988
        if (snapshot.target() == null || !snapshot.insideRadius()) {
989
            return;
990
        }
991
992
        switch (weapon.type()) {
993
            case BOW, TRIDENT -> {
994
            }
995
            case CROSSBOW -> {
996
                if (!CrossbowItem.isCharged(weapon.stack()) && pendingUse == null) {
997
                    pendingUse = new PendingUse(
998
                            weapon.hand(),
999
                            snapshot.solution(),
1000
                            player.tickCount + 1,
1001
                            UseAction.CHARGE_CROSSBOW
1002
                    );
1003
                }
1004
            }
1005
        }
1006
    }
1007
1008
    private boolean canUseStackForAction(LocalPlayer player, ItemStack stack, UseAction action) {
1009
        if (stack == null || stack.isEmpty()) {
1010
            return false;
1011
        }
1012
1013
        return switch (action) {
1014
            case CHARGE_CROSSBOW -> !player.isUsingItem()
1015
                    && stack.is(Items.CROSSBOW)
1016
                    && !CrossbowItem.isCharged(stack);
1017
            case FIRE_CROSSBOW -> stack.is(Items.CROSSBOW) && CrossbowItem.isCharged(stack);
1018
        };
1019
    }
1020
1021
    private boolean canAutoShoot(LocalPlayer player, ActiveWeapon weapon, LivingEntity target) {
1022
        if (player == null || weapon == null || target == null) {
1023
            return false;
1024
        }
1025
1026
        long now = System.currentTimeMillis();
1027
        long delayMs = (long) (delayBetweenShots.get() * 1000.0);
1028
        if (weapon.type() != WeaponType.CROSSBOW && now - lastShotAtMs < delayMs) {
1029
            return false;
1030
        }
1031
1032
        Rotation serverRotation = RotationManager.INSTANCE.getServerRotation();
1033
        if (serverRotation == null) {
1034
            return false;
1035
        }
1036
1037
        LivingEntity hypotheticalHit = ProjectilePredictionUtil.getHypotheticalHit(
1038
                player,
1039
                weapon.stack(),
1040
                serverRotation,
1041
                this::matchesHypotheticalTarget
1042
        );
1043
        if (hypotheticalHit == null && !hasDirectSightToTarget(player, target)) {
1044
            return false;
1045
        }
1046
1047
        return weapon.type() != WeaponType.CROSSBOW || player.isUsingItem() || now - lastShotAtMs >= delayMs;
1048
    }
1049
1050
    private boolean hasDirectSightToTarget(LocalPlayer player, LivingEntity target) {
1051
        if (player == null || target == null) {
1052
            return false;
1053
        }
1054
1055
        return RotationRaytrace.canSeeBox(
1056
                player.getEyePosition(),
1057
                target.getBoundingBox(),
1058
                range.get(),
1059
                0.0
1060
        );
1061
    }
1062
1063
    private boolean matchesHypotheticalTarget(LivingEntity living) {
1064
        if (living == null || mc.player == null || mc.level == null) {
1065
            return false;
1066
        }
1067
        if (!living.isAlive() || living.isRemoved()) {
1068
            return false;
1069
        }
1070
        if (toggles.get(TargetFilters.PLAYERS_ONLY) && !(living instanceof net.minecraft.world.entity.player.Player)) {
1071
            return false;
1072
        }
1073
        if (toggles.get(TargetFilters.VISIBLE_ONLY) && !mc.player.hasLineOfSight(living)) {
1074
            return false;
1075
        }
1076
        if (TargetingUtil.distanceToEntityBoxSq(mc.player.getEyePosition(), living) > range.get() * range.get()) {
1077
            return false;
1078
        }
1079
        if (toggles.get(TargetFilters.IGNORE_ENTITIES) && !(living instanceof net.minecraft.world.entity.player.Player)) {
1080
            var id = BuiltInRegistries.ENTITY_TYPE.getKey(living.getType());
1081
            if (id != null && EntityFilters.get().isIgnoredEntity(id.toString())) {
1082
                return false;
1083
            }
1084
        }
1085
1086
        if (living instanceof net.minecraft.world.entity.player.Player player) {
1087
            CategoryType type = CategoryRules.determine(player.getGameProfile().name());
1088
            if (type == CategoryType.BEDWARS_SELF) {
1089
                return false;
1090
            }
1091
            if (toggles.get(TargetFilters.IGNORE_FRIENDS) && type == CategoryType.FRIEND) {
1092
                return false;
1093
            }
1094
            if (toggles.get(TargetFilters.IGNORE_STAFF) && type == CategoryType.STAFF) {
1095
                return false;
1096
            }
1097
            if (toggles.get(TargetFilters.IGNORE_ENEMIES) && (type == CategoryType.ENEMY || type == CategoryType.BEDWARS_ENEMY)) {
1098
                return false;
1099
            }
1100
            return !toggles.get(TargetFilters.IGNORE_NAKED) || !TargetingUtil.isNaked(player);
1101
        }
1102
1103
        return true;
1104
    }
1105
1106
    private enum WeaponType {
1107
        BOW,
1108
        CROSSBOW,
1109
        TRIDENT
1110
    }
1111
1112
    private enum AutomationMode implements EnumValue.IdProvider {
1113
        FULL_AUTO("full_auto"),
1114
        AIM_ONLY("aim_only");
1115
1116
        private final String id;
1117
1118
        AutomationMode(String id) {
1119
            this.id = id;
1120
        }
1121
1122
        @Override
1123
        public String id() {
1124
            return id;
1125
        }
1126
    }
1127
1128
    private enum HudState {
1129
        IDLE("", COLOR_IDLE, false),
1130
        WAIT("WAIT", COLOR_WAIT, false),
1131
        LOCK("LOCK", COLOR_LOCK, false),
1132
        SHOOT("SHOOT", COLOR_SHOOT, false);
1133
1134
        private final String label;
1135
        private final int color;
1136
        private final boolean cross;
1137
1138
        HudState(String label, int color, boolean cross) {
1139
            this.label = label;
1140
            this.color = color;
1141
            this.cross = cross;
1142
        }
1143
    }
1144
1145
    private enum UseAction {
1146
        CHARGE_CROSSBOW,
1147
        FIRE_CROSSBOW
1148
    }
1149
1150
    private record ActiveWeapon(InteractionHand hand, ItemStack stack, WeaponType type) {
1151
    }
1152
1153
    private record PendingUse(InteractionHand hand, Rotation rotation, int expireAge, UseAction action) {
1154
    }
1155
1156
    private record Snapshot(
1157
            boolean showHud,
1158
            ActiveWeapon weapon,
1159
            LivingEntity target,
1160
            Rotation solution,
1161
            Vec2 logicalPoint,
1162
            boolean insideRadius,
1163
            boolean chargeReady,
1164
            boolean aimReady,
1165
            HudState state
1166
    ) {
1167
        private static Snapshot hidden() {
1168
            return new Snapshot(false, null, null, null, null, false, false, false, HudState.IDLE);
1169
        }
1170
1171
        private static Snapshot idle(ActiveWeapon weapon) {
1172
            return new Snapshot(true, weapon, null, null, null, false, false, false, HudState.IDLE);
1173
        }
1174
1175
        private static Snapshot waiting(ActiveWeapon weapon) {
1176
            return new Snapshot(true, weapon, null, null, null, false, false, false, HudState.WAIT);
1177
        }
1178
1179
        private static Snapshot withState(ActiveWeapon weapon,
1180
                                          LivingEntity target,
1181
                                          Rotation solution,
1182
                                          Vec2 logicalPoint,
1183
                                          boolean insideRadius,
1184
                                          boolean chargeReady,
1185
                                          boolean aimReady,
1186
                                          HudState state) {
1187
            return new Snapshot(true, weapon, target, solution, logicalPoint, insideRadius, chargeReady, aimReady, state);
1188
        }
1189
1190
        private boolean shouldRotate() {
1191
            return weapon != null && target != null && solution != null && insideRadius;
1192
        }
1193
    }
1194
}
1195
LiquidBounce (Kotlin)COMBATsrc/main/kotlin/net/ccbluex/liquidbounce/features/module/modules/combat/aimbot/ModuleAutoBow.ktKotlin · 61 lines · 2.1 KB

Automates many bow-related actions like aiming and shooting.

ModuleAutoBow.ktKotlin · Minecraft 26.2 · 61 lines · 2.1 KB · complete file, verbatimOriginal ↗
1
/*
2
 * This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce)
3
 *
4
 * Copyright (c) 2015 - 2026 CCBlueX
5
 *
6
 * LiquidBounce is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * LiquidBounce is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>.
18
 */
19
package net.ccbluex.liquidbounce.features.module.modules.combat.aimbot
20
21
import net.ccbluex.liquidbounce.features.module.ClientModule
22
import net.ccbluex.liquidbounce.features.module.ModuleCategories
23
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.autobow.AutoBowAimbotFeature
24
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.autobow.AutoBowAutoShootFeature
25
import net.ccbluex.liquidbounce.features.module.modules.combat.aimbot.autobow.AutoBowFastChargeFeature
26
import net.ccbluex.liquidbounce.utils.client.Chronometer
27
import net.minecraft.world.item.BowItem
28
import java.util.Random
29
30
/**
31
 * AutoBow module
32
 *
33
 * Automatically shoots with your bow when it's fully charged
34
 *  + and make it possible to shoot faster
35
 */
36
object ModuleAutoBow : ClientModule("AutoBow", ModuleCategories.COMBAT, aliases = listOf("BowAssist", "BowAimbot")) {
37
    val random = Random()
38
39
    /**
40
     * Keeps track of the last bow shot that has taken place
41
     */
42
    val lastShotTimer = Chronometer()
43
44
    @JvmStatic
45
    fun onStopUsingItem() {
46
        if (player.useItem.item is BowItem) {
47
            lastShotTimer.reset()
48
        }
49
    }
50
51
    override fun onDisabled() {
52
        AutoBowAimbotFeature.targetTracker.reset()
53
    }
54
55
    init {
56
        tree(AutoBowAutoShootFeature)
57
        tree(AutoBowAimbotFeature)
58
        tree(AutoBowFastChargeFeature)
59
    }
60
}
61