attribute-swap module

attribute-swap: 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/AttributeSwap.javaJava · 643 lines · 24.7 KB

Swaps to a target slot when you attack.

Settingsmodetarget-slotswap-on-missswap-backswap-back-delayshield-breakerdurability-saversword-swappingmace-swappingspear-swappingother-swappingfire-aspectlootingsharpnesssmitebane-of-arthropodssweeping-edgeregular-macedensitybreachwind-burstimpalinglungehitboxexclude-lunge-from-hitboxonly-on-weaponswordaxepickaxeshovelhoemacetrident
AttributeSwap.javaJava · Minecraft 26.2 · 643 lines · 24.7 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.entity.player.AttackEntityEvent;
9
import meteordevelopment.meteorclient.events.entity.player.DoAttackEvent;
10
import meteordevelopment.meteorclient.events.world.TickEvent;
11
import meteordevelopment.meteorclient.settings.*;
12
import meteordevelopment.meteorclient.systems.modules.Categories;
13
import meteordevelopment.meteorclient.systems.modules.Module;
14
import meteordevelopment.meteorclient.utils.Utils;
15
import meteordevelopment.meteorclient.utils.player.InvUtils;
16
import meteordevelopment.orbit.EventHandler;
17
import net.minecraft.tags.EntityTypeTags;
18
import net.minecraft.tags.ItemTags;
19
import net.minecraft.world.effect.MobEffects;
20
import net.minecraft.world.entity.Entity;
21
import net.minecraft.world.entity.EquipmentSlot;
22
import net.minecraft.world.entity.EquipmentSlotGroup;
23
import net.minecraft.world.entity.LivingEntity;
24
import net.minecraft.world.entity.ai.attributes.Attributes;
25
import net.minecraft.world.entity.player.Player;
26
import net.minecraft.world.item.AxeItem;
27
import net.minecraft.world.item.ItemStack;
28
import net.minecraft.world.item.MaceItem;
29
import net.minecraft.world.item.TridentItem;
30
import net.minecraft.world.item.enchantment.Enchantments;
31
import net.minecraft.world.phys.AABB;
32
import net.minecraft.world.phys.HitResult;
33
import net.minecraft.world.phys.Vec3;
34
35
public class AttributeSwap extends Module {
36
    private final SettingGroup sgGeneral = settings.getDefaultGroup();
37
    private final SettingGroup sgSwappingOptions = settings.createGroup("Swapping Options");
38
    private final SettingGroup sgSwordEnchants = settings.createGroup("Sword Enchants");
39
    private final SettingGroup sgMaceEnchants = settings.createGroup("Mace Enchants");
40
    private final SettingGroup sgSpearEnchants = settings.createGroup("Spear Enchants");
41
    private final SettingGroup sgOtherEnchants = settings.createGroup("Other Enchants");
42
    private final SettingGroup sgWeapon = settings.createGroup("Weapon Options");
43
44
    private final Setting<Mode> mode = sgGeneral.add(new EnumSetting.Builder<Mode>()
45
        .name("mode")
46
        .description("The mode to use.")
47
        .defaultValue(Mode.Simple)
48
        .build()
49
    );
50
51
    private final Setting<Integer> targetSlot = sgGeneral.add(new IntSetting.Builder()
52
        .name("target-slot")
53
        .description("Hotbar slot to swap to (1-9).")
54
        .defaultValue(1)
55
        .range(1, 9)
56
        .visible(() -> mode.get() == Mode.Simple)
57
        .build()
58
    );
59
60
    private final Setting<Boolean> swapOnMiss = sgGeneral.add(new BoolSetting.Builder()
61
        .name("swap-on-miss")
62
        .description("Whether to swap on a missed attack. Useful for quickly lunging with spears.")
63
        .defaultValue(false)
64
        .visible(() -> mode.get() == Mode.Simple)
65
        .build()
66
    );
67
68
    private final Setting<Boolean> swapBack = sgGeneral.add(new BoolSetting.Builder()
69
        .name("swap-back")
70
        .description("Swap back to the original slot after a delay.")
71
        .defaultValue(true)
72
        .build()
73
    );
74
75
    private final Setting<Integer> swapBackDelay = sgGeneral.add(new IntSetting.Builder()
76
        .name("swap-back-delay")
77
        .description("Delay in ticks before swapping back.")
78
        .defaultValue(2)
79
        .min(0)
80
        .max(100)
81
        .sliderRange(0, 20)
82
        .visible(swapBack::get)
83
        .build()
84
    );
85
86
    private final Setting<Boolean> smartShieldBreak = sgSwappingOptions.add(new BoolSetting.Builder()
87
        .name("shield-breaker")
88
        .description("Automatically swaps to an axe if the target is blocking.")
89
        .defaultValue(true)
90
        .visible(() -> mode.get() == Mode.Smart)
91
        .build()
92
    );
93
94
    private final Setting<Boolean> smartDurability = sgSwappingOptions.add(new BoolSetting.Builder()
95
        .name("durability-saver")
96
        .description("Swaps to a non-damageable item to save durability on the main weapon.")
97
        .defaultValue(true)
98
        .visible(() -> mode.get() == Mode.Smart)
99
        .build()
100
    );
101
102
    private final Setting<Boolean> swordSwapping = sgSwappingOptions.add(new BoolSetting.Builder()
103
        .name("sword-swapping")
104
        .description("Enables smart swapping for sword enchantments.")
105
        .defaultValue(true)
106
        .visible(() -> mode.get() == Mode.Smart)
107
        .build()
108
    );
109
110
    private final Setting<Boolean> maceSwapping = sgSwappingOptions.add(new BoolSetting.Builder()
111
        .name("mace-swapping")
112
        .description("Enables smart swapping for mace enchantments.")
113
        .defaultValue(true)
114
        .visible(() -> mode.get() == Mode.Smart)
115
        .build()
116
    );
117
118
    private final Setting<Boolean> spearSwapping = sgSwappingOptions.add(new BoolSetting.Builder()
119
        .name("spear-swapping")
120
        .description("Enables smart swapping for spear enchantments.")
121
        .defaultValue(true)
122
        .visible(() -> mode.get() == Mode.Smart)
123
        .build()
124
    );
125
126
    private final Setting<Boolean> otherSwapping = sgSwappingOptions.add(new BoolSetting.Builder()
127
        .name("other-swapping")
128
        .description("Enables smart swapping for other enchantments like Impaling.")
129
        .defaultValue(true)
130
        .visible(() -> mode.get() == Mode.Smart)
131
        .build()
132
    );
133
134
    private final Setting<Boolean> enchantFireAspect = sgSwordEnchants.add(new BoolSetting.Builder()
135
        .name("fire-aspect")
136
        .description("Swaps to an item with Fire Aspect to set the target on fire, if target isn't already on fire")
137
        .defaultValue(true)
138
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
139
        .build()
140
    );
141
142
    private final Setting<Boolean> enchantLooting = sgSwordEnchants.add(new BoolSetting.Builder()
143
        .name("looting")
144
        .description("Swaps to an item with Looting for better drops or more experience. Only prefers for mobs (but fire aspect is priority)")
145
        .defaultValue(true)
146
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
147
        .build()
148
    );
149
150
    private final Setting<Boolean> enchantSharpness = sgSwordEnchants.add(new BoolSetting.Builder()
151
        .name("sharpness")
152
        .description("Swaps to an item with Sharpness for increased damage against all entities.")
153
        .defaultValue(true)
154
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
155
        .build()
156
    );
157
158
    private final Setting<Boolean> enchantSmite = sgSwordEnchants.add(new BoolSetting.Builder()
159
        .name("smite")
160
        .description("Swaps to an item with Smite for increased damage against undead mobs.")
161
        .defaultValue(true)
162
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
163
        .build()
164
    );
165
166
    private final Setting<Boolean> enchantBaneOfArthropods = sgSwordEnchants.add(new BoolSetting.Builder()
167
        .name("bane-of-arthropods")
168
        .description("Swaps to an item with Bane of Arthropods for increased damage against arthropods.")
169
        .defaultValue(true)
170
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
171
        .build()
172
    );
173
174
    private final Setting<Boolean> enchantSweepingEdge = sgSwordEnchants.add(new BoolSetting.Builder()
175
        .name("sweeping-edge")
176
        .description("Swaps to an item with Sweeping Edge for increased sweeping attack damage.")
177
        .defaultValue(true)
178
        .visible(() -> mode.get() == Mode.Smart && swordSwapping.get())
179
        .build()
180
    );
181
182
    private final Setting<Boolean> regularMace = sgMaceEnchants.add(new BoolSetting.Builder()
183
        .name("regular-mace")
184
        .description("Swaps to a regular Mace when falling if no better option is available.")
185
        .defaultValue(true)
186
        .visible(() -> mode.get() == Mode.Smart && maceSwapping.get())
187
        .build()
188
    );
189
190
    private final Setting<Boolean> enchantDensity = sgMaceEnchants.add(new BoolSetting.Builder()
191
        .name("density")
192
        .description("Swaps to a Mace with Density to deal increased damage when falling.")
193
        .defaultValue(true)
194
        .visible(() -> mode.get() == Mode.Smart && maceSwapping.get())
195
        .build()
196
    );
197
198
    private final Setting<Boolean> enchantBreach = sgMaceEnchants.add(new BoolSetting.Builder()
199
        .name("breach")
200
        .description("Swaps to a Mace with Breach to reduce the target's armor effectiveness.")
201
        .defaultValue(true)
202
        .visible(() -> mode.get() == Mode.Smart && maceSwapping.get())
203
        .build()
204
    );
205
206
    private final Setting<Boolean> enchantWindBurst = sgMaceEnchants.add(new BoolSetting.Builder()
207
        .name("wind-burst")
208
        .description("Swaps to a Mace with Wind Burst to launch up when hitting while falling.")
209
        .defaultValue(true)
210
        .visible(() -> mode.get() == Mode.Smart && maceSwapping.get())
211
        .build()
212
    );
213
214
    private final Setting<Boolean> enchantImpaling = sgOtherEnchants.add(new BoolSetting.Builder()
215
        .name("impaling")
216
        .description("Swaps to an item with Impaling for increased damage against aquatic mobs.")
217
        .defaultValue(true)
218
        .visible(() -> mode.get() == Mode.Smart && otherSwapping.get())
219
        .build()
220
    );
221
222
    private final Setting<Boolean> enchantLunge = sgSpearEnchants.add(new BoolSetting.Builder()
223
        .name("lunge")
224
        .description("Swaps to a spear with Lunge for traveling.")
225
        .defaultValue(true)
226
        .visible(() -> mode.get() == Mode.Smart && spearSwapping.get())
227
        .build()
228
    );
229
230
    private final Setting<Boolean> spearHitbox = sgSpearEnchants.add(new BoolSetting.Builder()
231
        .name("hitbox")
232
        .description("Swaps to a spear for extended reach when target is far.")
233
        .defaultValue(true)
234
        .visible(() -> mode.get() == Mode.Smart && spearSwapping.get())
235
        .build()
236
    );
237
238
    private final Setting<Boolean> excludeLungeFromHitbox = sgSpearEnchants.add(new BoolSetting.Builder()
239
        .name("exclude-lunge-from-hitbox")
240
        .description("Don't use lunge-enchanted spears for hitbox extension.")
241
        .defaultValue(true)
242
        .visible(() -> mode.get() == Mode.Smart && spearSwapping.get() && spearHitbox.get())
243
        .build()
244
    );
245
246
    private final Setting<Boolean> onlyOnWeapon = sgWeapon.add(new BoolSetting.Builder()
247
        .name("only-on-weapon")
248
        .description("Only swaps when holding a selected weapon in hand.")
249
        .defaultValue(false)
250
        .build()
251
    );
252
253
    private final Setting<Boolean> sword = sgWeapon.add(new BoolSetting.Builder()
254
        .name("sword")
255
        .description("Works while holding a sword.")
256
        .defaultValue(true)
257
        .visible(onlyOnWeapon::get)
258
        .build()
259
    );
260
261
    private final Setting<Boolean> axe = sgWeapon.add(new BoolSetting.Builder()
262
        .name("axe")
263
        .description("Works while holding an axe.")
264
        .defaultValue(true)
265
        .visible(onlyOnWeapon::get)
266
        .build()
267
    );
268
269
    private final Setting<Boolean> pickaxe = sgWeapon.add(new BoolSetting.Builder()
270
        .name("pickaxe")
271
        .description("Works while holding a pickaxe.")
272
        .defaultValue(true)
273
        .visible(onlyOnWeapon::get)
274
        .build()
275
    );
276
277
    private final Setting<Boolean> shovel = sgWeapon.add(new BoolSetting.Builder()
278
        .name("shovel")
279
        .description("Works while holding a shovel.")
280
        .defaultValue(true)
281
        .visible(onlyOnWeapon::get)
282
        .build()
283
    );
284
285
    private final Setting<Boolean> hoe = sgWeapon.add(new BoolSetting.Builder()
286
        .name("hoe")
287
        .description("Works while holding a hoe.")
288
        .defaultValue(true)
289
        .visible(onlyOnWeapon::get)
290
        .build()
291
    );
292
293
    private final Setting<Boolean> mace = sgWeapon.add(new BoolSetting.Builder()
294
        .name("mace")
295
        .description("Works while holding a mace.")
296
        .defaultValue(true)
297
        .visible(onlyOnWeapon::get)
298
        .build()
299
    );
300
301
    private final Setting<Boolean> trident = sgWeapon.add(new BoolSetting.Builder()
302
        .name("trident")
303
        .description("Works while holding a trident.")
304
        .defaultValue(true)
305
        .visible(onlyOnWeapon::get)
306
        .build()
307
    );
308
309
    private int backTimer;
310
    private boolean awaitingBack;
311
312
    public AttributeSwap() {
313
        super(Categories.Combat, "attribute-swap", "Swaps to a target slot when you attack.");
314
    }
315
316
    @Override
317
    public void onDeactivate() {
318
        backTimer = 0;
319
        awaitingBack = false;
320
    }
321
322
    @EventHandler
323
    private void onAttack(DoAttackEvent event) {
324
        if (mc.hitResult.getType() == HitResult.Type.BLOCK || !canSwapByWeapon()) return;
325
326
        if (mode.get() == Mode.Smart && spearSwapping.get()) {
327
            if (spearHitbox.get()) {
328
                Entity target = getTargetEntity();
329
                if (target != null) {
330
                    if (mc.player.distanceTo(target) <= mc.player.entityInteractionRange() + 0.5) return;
331
                    int spearSlot = getSmartSpearSlot(false);
332
                    if (spearSlot != -1) {
333
                        doSwap(spearSlot);
334
                        return;
335
                    }
336
                }
337
            }
338
339
            // lunge spear for travelling (or when enemy isn't in spear range)
340
            if (enchantLunge.get()) {
341
                int lungeSlot = getSmartSpearSlot(true);
342
                if (lungeSlot != -1) {
343
                    doSwap(lungeSlot);
344
                    return;
345
                }
346
            }
347
        }
348
349
        if (mode.get() == Mode.Smart || !swapOnMiss.get()) return;
350
        doSwap(targetSlot.get() - 1);
351
    }
352
353
    @EventHandler
354
    private void onAttackEntity(AttackEntityEvent event) {
355
        if (!canSwapByWeapon() || (mode.get() == Mode.Simple && swapOnMiss.get())) return;
356
        performSwap(event.entity);
357
    }
358
359
    private void performSwap(Entity target) {
360
        if (awaitingBack) return;
361
362
        if (mode.get() == Mode.Simple) {
363
            doSwap(targetSlot.get() - 1);
364
        } else {
365
            doSwap(getSmartSlot(target));
366
        }
367
    }
368
369
    private void doSwap(int slotIndex) {
370
        if (awaitingBack) return;
371
372
        if (slotIndex < 0 || slotIndex > 8) return;
373
        if (slotIndex == mc.player.getInventory().getSelectedSlot()) return;
374
375
        if (!InvUtils.swap(slotIndex, swapBack.get())) return;
376
377
        awaitingBack = swapBack.get();
378
        if (awaitingBack) backTimer = swapBackDelay.get();
379
    }
380
381
    @EventHandler
382
    private void onTick(TickEvent.Post event) {
383
        if (!awaitingBack) return;
384
        if (backTimer-- > 0) return;
385
        InvUtils.swapBack();
386
        awaitingBack = false;
387
    }
388
389
    private boolean canSwapByWeapon() {
390
        if (!onlyOnWeapon.get()) return true;
391
        return InvUtils.testInMainHand(item ->
392
            (sword.get() && item.is(ItemTags.SWORDS)) ||
393
                (axe.get() && item.is(ItemTags.AXES)) ||
394
                (pickaxe.get() && item.is(ItemTags.PICKAXES)) ||
395
                (shovel.get() && item.is(ItemTags.SHOVELS)) ||
396
                (hoe.get() && item.is(ItemTags.HOES)) ||
397
                (mace.get() && item.getItem() instanceof MaceItem) ||
398
                (trident.get() && item.getItem() instanceof TridentItem)
399
        );
400
    }
401
402
    private int getSmartSlot(Entity target) {
403
        ItemStack currentStack = mc.player.getMainHandItem();
404
405
        if (target != null && smartShieldBreak.get() && target instanceof LivingEntity living && living.isBlocking()) {
406
            if (currentStack.getItem() instanceof AxeItem) return -1;
407
            int axeSlot = InvUtils.findInHotbar(item -> item.getItem() instanceof AxeItem).slot();
408
            if (axeSlot != -1) return axeSlot;
409
        }
410
411
        boolean isFalling = mc.player.fallDistance > 1.5;
412
        boolean durability = smartDurability.get();
413
414
        boolean isLiving = target instanceof LivingEntity;
415
        boolean isPlayer = target instanceof Player;
416
        boolean isOnFire = target != null && target.isOnFire();
417
        boolean isUndead = target != null && target.typeHolder().is(EntityTypeTags.SENSITIVE_TO_SMITE);
418
        boolean isArthropod = target != null && target.typeHolder().is(EntityTypeTags.SENSITIVE_TO_BANE_OF_ARTHROPODS);
419
        boolean isAquatic = target != null && target.typeHolder().is(EntityTypeTags.SENSITIVE_TO_IMPALING);
420
        boolean hasFireResistance = isLiving && (((LivingEntity) target).hasEffect(MobEffects.FIRE_RESISTANCE) || hasFireProtectionArmor((LivingEntity) target));
421
        double armor = isLiving ? ((LivingEntity) target).getAttributeValue(Attributes.ARMOR) : 0;
422
        float health = isLiving ? ((LivingEntity) target).getHealth() : 0;
423
424
        int bestSlot = -1;
425
        double bestScore = getItemScore(currentStack, isFalling, durability, isLiving, isPlayer, isOnFire, hasFireResistance, isUndead, isArthropod, isAquatic, armor, health);
426
427
        for (int i = 0; i < 9; i++) {
428
            if (i == mc.player.getInventory().getSelectedSlot()) continue;
429
430
            ItemStack stack = mc.player.getInventory().getItem(i);
431
            if (stack.isEmpty() && !durability) continue;
432
433
            double score = getItemScore(stack, isFalling, durability, isLiving, isPlayer, isOnFire, hasFireResistance, isUndead, isArthropod, isAquatic, armor, health);
434
            if (score > bestScore) {
435
                bestScore = score;
436
                bestSlot = i;
437
            }
438
        }
439
440
        return bestSlot;
441
    }
442
443
    private int getSmartSpearSlot(boolean requireLunge) {
444
        for (int i = 0; i < 9; i++) {
445
            if (i == mc.player.getInventory().getSelectedSlot()) continue;
446
            ItemStack stack = mc.player.getInventory().getItem(i);
447
            if (!stack.is(ItemTags.SPEARS)) continue;
448
449
            boolean hasLunge = Utils.getEnchantmentLevel(stack, Enchantments.LUNGE) > 0;
450
            if (requireLunge && !hasLunge) continue;
451
            if (!requireLunge && excludeLungeFromHitbox.get() && hasLunge) continue;
452
453
            return i;
454
        }
455
456
        return -1;
457
    }
458
459
    private Entity getTargetEntity() {
460
        double maxDistance = 7;
461
        Vec3 start = mc.player.getEyePosition(1.0f);
462
        Vec3 look = mc.player.getViewVector(1.0f);
463
        Vec3 end = start.add(look.scale(maxDistance));
464
465
        AABB box = mc.player.getBoundingBox().expandTowards(look.scale(maxDistance)).inflate(1.0);
466
467
        Entity target = null;
468
        double closestDistance = maxDistance * maxDistance;
469
470
        for (Entity entity : mc.level.getEntities(mc.player, box, e -> !e.isSpectator() && e.isPickable())) {
471
            // expanding entity's hitbox by 0.15 to simulate spear's actual hitbox margin
472
            AABB expandedBox = entity.getBoundingBox().inflate(0.150);
473
474
            if (expandedBox.clip(start, end).isPresent()) {
475
                double distSq = start.distanceToSqr(entity.getX(), entity.getY(), entity.getZ());
476
                if (distSq < closestDistance) {
477
                    closestDistance = distSq;
478
                    target = entity;
479
                }
480
            }
481
        }
482
483
        return target;
484
    }
485
486
    private double getItemScore(ItemStack stack, boolean isFalling, boolean durability, boolean isLiving, boolean isPlayer, boolean isOnFire, boolean hasFireResistance, boolean isUndead, boolean isArthropod, boolean isAquatic, double armor, float health) {
487
        double score = 0;
488
489
        if (durability) {
490
            score += getDurabilityScore(stack);
491
        }
492
493
        if (stack.isEmpty()) return score;
494
495
        score += getCombatScore(stack, isFalling, isLiving, isPlayer, isOnFire, hasFireResistance, isUndead, isArthropod, isAquatic, armor, health);
496
497
        return score;
498
    }
499
500
    private double getDurabilityScore(ItemStack stack) {
501
        if (!stack.isDamageableItem()) return 4;
502
503
        int unbreaking = Utils.getEnchantmentLevel(stack, Enchantments.UNBREAKING);
504
        if (unbreaking > 0) return unbreaking * 0.05;
505
506
        return 0;
507
    }
508
509
    private double getCombatScore(ItemStack stack, boolean isFalling, boolean isLiving, boolean isPlayer, boolean isOnFire, boolean hasFireResistance, boolean isUndead, boolean isArthropod, boolean isAquatic, double armor, float health) {
510
        double score = 0;
511
512
        if (swordSwapping.get()) {
513
            score += getFireAspectScore(stack, isOnFire, hasFireResistance);
514
            score += getLootingScore(stack, isPlayer, isLiving, isOnFire, health);
515
            score += getSharpnessScore(stack, isOnFire);
516
            score += getSmiteScore(stack, isUndead, isOnFire);
517
            score += getBaneOfArthropodsScore(stack, isArthropod, isOnFire);
518
            score += getSweepingEdgeScore(stack);
519
        }
520
        if (maceSwapping.get()) {
521
            score += getBreachScore(stack, isLiving, armor);
522
            score += getDensityScore(stack, isFalling);
523
            score += getWindBurstScore(stack, isFalling);
524
            score += getMaceScore(stack, isFalling);
525
        }
526
        if (otherSwapping.get()) {
527
            score += getImpalingScore(stack, isAquatic);
528
        }
529
530
        return score;
531
    }
532
533
    private double getFireAspectScore(ItemStack stack, boolean isOnFire, boolean hasFireResistance) {
534
        if (!enchantFireAspect.get() || isOnFire || hasFireResistance) return 0;
535
        int level = Utils.getEnchantmentLevel(stack, Enchantments.FIRE_ASPECT);
536
        return (level > 0) ? 30 : 0;
537
    }
538
539
    private double getLootingScore(ItemStack stack, boolean isPlayer, boolean isLiving, boolean isOnFire, float health) {
540
        if (!enchantLooting.get() || isPlayer) return 0;
541
        int level = Utils.getEnchantmentLevel(stack, Enchantments.LOOTING);
542
        if (level > 0) {
543
            boolean execute = (isLiving && health < 20) || isOnFire;
544
            return level * (execute ? 10 : 5);
545
        }
546
        return 0;
547
    }
548
549
    private double getSharpnessScore(ItemStack stack, boolean isOnFire) {
550
        if (!enchantSharpness.get()) return 0;
551
        int level = Utils.getEnchantmentLevel(stack, Enchantments.SHARPNESS);
552
        if (level > 0) {
553
            double baseScore = (1 + 0.5 * (level - 1)) * 3;
554
            return isOnFire ? baseScore * 1.5 : baseScore;
555
        }
556
        return 0;
557
    }
558
559
    private double getSmiteScore(ItemStack stack, boolean isUndead, boolean isOnFire) {
560
        if (!enchantSmite.get() || !isUndead) return 0;
561
        int level = Utils.getEnchantmentLevel(stack, Enchantments.SMITE);
562
        if (level > 0) {
563
            double baseScore = level * 5;
564
            return isOnFire ? baseScore * 1.5 : baseScore;
565
        }
566
        return 0;
567
    }
568
569
    private double getBaneOfArthropodsScore(ItemStack stack, boolean isArthropod, boolean isOnFire) {
570
        if (!enchantBaneOfArthropods.get() || !isArthropod) return 0;
571
        int level = Utils.getEnchantmentLevel(stack, Enchantments.BANE_OF_ARTHROPODS);
572
        if (level > 0) {
573
            double baseScore = level * 5;
574
            return isOnFire ? baseScore * 1.5 : baseScore;
575
        }
576
        return 0;
577
    }
578
579
    private double getSweepingEdgeScore(ItemStack stack) {
580
        if (!enchantSweepingEdge.get()) return 0;
581
        int level = Utils.getEnchantmentLevel(stack, Enchantments.SWEEPING_EDGE);
582
        if (level > 0) {
583
            return level * 3;
584
        }
585
        return 0;
586
    }
587
588
    private double getImpalingScore(ItemStack stack, boolean isAquatic) {
589
        if (!enchantImpaling.get() || !isAquatic) return 0;
590
591
        int level = Utils.getEnchantmentLevel(stack, Enchantments.IMPALING);
592
        if (level > 0) {
593
            return level * 5;
594
        }
595
        return 0;
596
    }
597
598
    private double getBreachScore(ItemStack stack, boolean isLiving, double armor) {
599
        if (!enchantBreach.get() || !isLiving || armor <= 0) return 0;
600
        int level = Utils.getEnchantmentLevel(stack, Enchantments.BREACH);
601
        if (level > 0) {
602
            return level * armor * 0.3;
603
        }
604
        return 0;
605
    }
606
607
    private double getDensityScore(ItemStack stack, boolean isFalling) {
608
        if (!enchantDensity.get() || !isFalling) return 0;
609
        int level = Utils.getEnchantmentLevel(stack, Enchantments.DENSITY);
610
        if (level > 0) return 50 + (level * mc.player.fallDistance * 2);
611
        return 0;
612
    }
613
614
    private double getWindBurstScore(ItemStack stack, boolean isFalling) {
615
        if (!enchantWindBurst.get() || !isFalling) return 0;
616
        int level = Utils.getEnchantmentLevel(stack, Enchantments.WIND_BURST);
617
        if (level > 0) return level * 20;
618
        return 0;
619
    }
620
621
    private double getMaceScore(ItemStack stack, boolean isFalling) {
622
        if (!regularMace.get() || !isFalling) return 0;
623
        if (stack.getItem() instanceof MaceItem) return 40;
624
        return 0;
625
    }
626
627
    private boolean hasFireProtectionArmor(LivingEntity entity) {
628
        for (EquipmentSlot slot : EquipmentSlotGroup.ARMOR) {
629
            ItemStack stack = entity.getItemBySlot(slot);
630
            if (stack.isEmpty()) continue;
631
632
            int fireProtection = Utils.getEnchantmentLevel(stack, Enchantments.FIRE_PROTECTION);
633
            if (fireProtection > 0) return true;
634
        }
635
        return false;
636
    }
637
638
    public enum Mode {
639
        Simple,
640
        Smart
641
    }
642
}
643