From 8722ef565afa02ca4b6d9710a20fc9fcfd97bf05 Mon Sep 17 00:00:00 2001 From: Based Ricky <80427814+RickyTheRacc@users.noreply.github.com> Date: Wed, 21 Dec 2022 14:55:29 -0600 Subject: [PATCH] KillAura Improvements (#3085) --- .../systems/modules/combat/CrystalAura.java | 7 +- .../systems/modules/combat/KillAura.java | 293 ++++++++++-------- 2 files changed, 163 insertions(+), 137 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java index 3095613ec5..52d1c9749b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/CrystalAura.java @@ -150,7 +150,7 @@ public class CrystalAura extends Module { .build() ); - private final Setting placeDelay = sgPlace.add(new IntSetting.Builder() + public final Setting placeDelay = sgPlace.add(new IntSetting.Builder() .name("place-delay") .description("The delay in ticks to wait to place a crystal after it's exploded.") .defaultValue(0) @@ -464,6 +464,7 @@ public class CrystalAura extends Module { private final IntSet placedCrystals = new IntOpenHashSet(); private boolean placing; private int placingTimer; + public int kaTimer; private final BlockPos.Mutable placingCrystalBlockPos = new BlockPos.Mutable(); private final IntSet removed = new IntOpenHashSet(); @@ -502,6 +503,7 @@ public void onActivate() { placing = false; placingTimer = 0; + kaTimer = 0; attacks = 0; @@ -546,6 +548,8 @@ private void onPreTick(TickEvent.Pre event) { else placing = false; } + if (kaTimer > 0) kaTimer--; + if (ticksPassed < 20) ticksPassed++; else { ticksPassed = 0; @@ -921,6 +925,7 @@ private void placeCrystal(BlockHitResult result, double damage, BlockPos support placing = true; placingTimer = 4; + kaTimer = 8; placingCrystalBlockPos.set(result.getBlockPos()).move(0, 1, 0); renderTimer = renderTime.get(); diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java index 6f71199012..3a2da61550 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/KillAura.java @@ -9,10 +9,12 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanMap; import meteordevelopment.meteorclient.events.packets.PacketEvent; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.friends.Friends; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.Target; @@ -21,6 +23,7 @@ import meteordevelopment.meteorclient.utils.player.InvUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.player.Rotations; +import meteordevelopment.meteorclient.utils.world.TickRate; import meteordevelopment.orbit.EventHandler; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -30,13 +33,15 @@ import net.minecraft.entity.mob.EndermanEntity; import net.minecraft.entity.mob.ZombifiedPiglinEntity; import net.minecraft.entity.passive.AnimalEntity; +import net.minecraft.entity.passive.LlamaEntity; import net.minecraft.entity.passive.WolfEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.AxeItem; -import net.minecraft.item.Item; -import net.minecraft.item.SwordItem; +import net.minecraft.item.*; import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket; import net.minecraft.util.Hand; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.GameMode; import java.util.ArrayList; @@ -45,7 +50,7 @@ public class KillAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTargeting = settings.createGroup("Targeting"); - private final SettingGroup sgDelay = settings.createGroup("Delay"); + private final SettingGroup sgTiming = settings.createGroup("Timing"); // General @@ -56,6 +61,13 @@ public class KillAura extends Module { .build() ); + private final Setting rotation = sgGeneral.add(new EnumSetting.Builder() + .name("rotate") + .description("Determines when you should rotate towards the target.") + .defaultValue(RotationMode.Always) + .build() + ); + private final Setting autoSwitch = sgGeneral.add(new BoolSetting.Builder() .name("auto-switch") .description("Switches to your selected weapon when attacking the target.") @@ -70,72 +82,52 @@ public class KillAura extends Module { .build() ); - private final Setting onlyWhenLook = sgGeneral.add(new BoolSetting.Builder() - .name("only-when-look") - .description("Only attacks when you are looking at the entity.") + private final Setting onlyOnLook = sgGeneral.add(new BoolSetting.Builder() + .name("only-on-look") + .description("Only attacks when looking at an entity.") .defaultValue(false) .build() ); - private final Setting randomTeleport = sgGeneral.add(new BoolSetting.Builder() - .name("random-teleport") - .description("Randomly teleport around the target.") - .defaultValue(false) - .visible(() -> !onlyWhenLook.get()) - .build() - ); - - private final Setting rotation = sgGeneral.add(new EnumSetting.Builder() - .name("rotate") - .description("Determines when you should rotate towards the target.") - .defaultValue(RotationMode.Always) - .build() - ); - - private final Setting hitChance = sgGeneral.add(new DoubleSetting.Builder() - .name("hit-chance") - .description("The probability of your hits landing.") - .defaultValue(100) - .range(1, 100) - .sliderRange(1, 100) - .build() - ); - private final Setting pauseOnCombat = sgGeneral.add(new BoolSetting.Builder() - .name("pause-on-combat") + .name("pause-baritone") .description("Freezes Baritone temporarily until you are finished attacking the entity.") .defaultValue(true) .build() ); - private final Setting noRightClick = sgGeneral.add(new BoolSetting.Builder() - .name("pause-on-use") - .description("Does not attack if using an item.") - .defaultValue(true) + private final Setting shieldMode = sgGeneral.add(new EnumSetting.Builder() + .name("shield-mode") + .description("Will try and use an axe to break target shields.") + .defaultValue(ShieldMode.Break) + .visible(() -> autoSwitch.get() && weapon.get() != Weapon.Axe) .build() ); // Targeting - private final Setting ignorePassive = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-passive") - .description("Will only attack sometimes passive mobs if they are targeting you.") - .defaultValue(true) + private final Setting>> entities = sgTargeting.add(new EntityTypeListSetting.Builder() + .name("entities") + .description("Entities to attack.") + .onlyAttackable() + .defaultValue(EntityType.PLAYER) .build() ); - private final Setting ignoreTamed = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-tamed") - .description("Will avoid attacking mobs you tamed.") - .defaultValue(false) + private final Setting priority = sgTargeting.add(new EnumSetting.Builder() + .name("priority") + .description("How to filter targets within range.") + .defaultValue(SortPriority.ClosestAngle) .build() ); - - private final Setting>> entities = sgTargeting.add(new EntityTypeListSetting.Builder() - .name("entities") - .description("Entities to attack.") - .onlyAttackable() + private final Setting maxTargets = sgTargeting.add(new IntSetting.Builder() + .name("max-targets") + .description("How many entities to target at once.") + .defaultValue(1) + .min(1) + .sliderRange(1, 5) + .visible(() -> !onlyOnLook.get()) .build() ); @@ -157,90 +149,94 @@ public class KillAura extends Module { .build() ); - private final Setting priority = sgTargeting.add(new EnumSetting.Builder() - .name("priority") - .description("How to filter targets within range.") - .defaultValue(SortPriority.LowestHealth) + private final Setting ignoreBabies = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-babies") + .description("Whether or not to attack baby variants of the entity.") + .defaultValue(true) .build() ); - private final Setting maxTargets = sgTargeting.add(new IntSetting.Builder() - .name("max-targets") - .description("How many entities to target at once.") - .defaultValue(1) - .min(1) - .sliderRange(1, 5) + private final Setting ignoreNamed = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-named") + .description("Whether or not to attack mobs with a name.") + .defaultValue(false) .build() ); - private final Setting babies = sgTargeting.add(new BoolSetting.Builder() - .name("babies") - .description("Whether or not to attack baby variants of the entity.") + private final Setting ignorePassive = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-passive") + .description("Will only attack sometimes passive mobs if they are targeting you.") .defaultValue(true) .build() ); - private final Setting nametagged = sgTargeting.add(new BoolSetting.Builder() - .name("nametagged") - .description("Whether or not to attack mobs with a name tag.") + private final Setting ignoreTamed = sgTargeting.add(new BoolSetting.Builder() + .name("ignore-tamed") + .description("Will avoid attacking mobs you tamed.") .defaultValue(false) .build() ); - private final Setting ignoreShield = sgGeneral.add(new BoolSetting.Builder() - .name("ignore-shield") - .description("Attacks only if the blow is not blocked by a shield.") + // Timing + + private final Setting pauseOnLag = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-lag") + .description("Pauses if the server is lagging.") .defaultValue(true) .build() ); - // Delay + private final Setting pauseOnUse = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-use") + .description("Does not attack while using an item.") + .defaultValue(false) + .build() + ); - private final Setting smartDelay = sgDelay.add(new BoolSetting.Builder() - .name("smart-delay") - .description("Uses the vanilla cooldown to attack entities.") + private final Setting pauseOnCA = sgTiming.add(new BoolSetting.Builder() + .name("pause-on-CA") + .description("Does not attack while CA is placing.") .defaultValue(true) .build() ); - private final Setting hitDelay = sgDelay.add(new IntSetting.Builder() - .name("hit-delay") - .description("How fast you hit the entity in ticks.") - .defaultValue(0) - .min(0) - .sliderMax(60) - .visible(() -> !smartDelay.get()) + private final Setting tpsSync = sgTiming.add(new BoolSetting.Builder() + .name("TPS-sync") + .description("Tries to sync attack delay with the server's TPS.") + .defaultValue(true) .build() ); - private final Setting randomDelayEnabled = sgDelay.add(new BoolSetting.Builder() - .name("random-delay-enabled") - .description("Adds a random delay between hits to attempt to bypass anti-cheats.") + private final Setting customDelay = sgTiming.add(new BoolSetting.Builder() + .name("custom-delay") + .description("Use a custom delay instead of the vanilla cooldown.") .defaultValue(false) - .visible(() -> !smartDelay.get()) .build() ); - private final Setting randomDelayMax = sgDelay.add(new IntSetting.Builder() - .name("random-delay-max") - .description("The maximum value for random delay.") - .defaultValue(4) + private final Setting hitDelay = sgTiming.add(new IntSetting.Builder() + .name("hit-delay") + .description("How fast you hit the entity in ticks.") + .defaultValue(11) .min(0) - .sliderMax(20) - .visible(() -> randomDelayEnabled.get() && !smartDelay.get()) + .sliderMax(60) + .visible(customDelay::get) .build() ); - private final Setting switchDelay = sgDelay.add(new IntSetting.Builder() + private final Setting switchDelay = sgTiming.add(new IntSetting.Builder() .name("switch-delay") .description("How many ticks to wait before hitting an entity after switching hotbar slots.") .defaultValue(0) .min(0) + .sliderMax(10) .build() ); + CrystalAura ca = Modules.get().get(CrystalAura.class); private final List targets = new ArrayList<>(); - private int hitDelayTimer, switchTimer; + private final Vec3d hitVec = new Vec3d(0, 0, 0); + private int switchTimer, hitTimer; private boolean wasPathing = false; public KillAura() { @@ -249,15 +245,29 @@ public KillAura() { @Override public void onDeactivate() { - hitDelayTimer = 0; targets.clear(); } @EventHandler private void onTick(TickEvent.Pre event) { if (!mc.player.isAlive() || PlayerUtils.getGameMode() == GameMode.SPECTATOR) return; + if (pauseOnUse.get() && (mc.interactionManager.isBreakingBlock() || mc.player.isUsingItem())) return; + if (onlyOnClick.get() && !mc.options.attackKey.isPressed()) return; + if (TickRate.INSTANCE.getTimeSinceLastTick() >= 1f && pauseOnLag.get()) return; + if (pauseOnCA.get() && ca.isActive() && ca.kaTimer > 0) return; + + if (onlyOnLook.get()) { + Entity targeted = mc.targetedEntity; - TargetUtils.getList(targets, this::entityCheck, priority.get(), maxTargets.get()); + if (targeted == null) return; + if (!entityCheck(targeted)) return; + + targets.clear(); + targets.add(mc.targetedEntity); + } else { + targets.clear(); + TargetUtils.getList(targets, this::entityCheck, priority.get(), maxTargets.get()); + } if (targets.isEmpty()) { if (wasPathing) { @@ -269,20 +279,6 @@ private void onTick(TickEvent.Pre event) { Entity primary = targets.get(0); - if (rotation.get() == RotationMode.Always) rotate(primary, null); - - if (onlyOnClick.get() && !mc.options.attackKey.isPressed()) return; - - if (onlyWhenLook.get()) { - primary = mc.targetedEntity; - - if (primary == null) return; - if (!entityCheck(primary)) return; - - targets.clear(); - targets.add(primary); - } - if (autoSwitch.get()) { FindItemResult weaponResult = InvUtils.findInHotbar(itemStack -> { Item item = itemStack.getItem(); @@ -295,21 +291,30 @@ private void onTick(TickEvent.Pre event) { }; }); + if (shouldShieldBreak()) { + FindItemResult axeResult = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof AxeItem); + if (axeResult.found()) weaponResult = axeResult; + } + InvUtils.swap(weaponResult.slot(), false); } if (!itemInHand()) return; + Box hitbox = primary.getBoundingBox(); + ((IVec3d) hitVec).set( + MathHelper.clamp(mc.player.getX(), hitbox.minX, hitbox.maxX), + MathHelper.clamp(mc.player.getY(), hitbox.minY, hitbox.maxY), + MathHelper.clamp(mc.player.getZ(), hitbox.minZ, hitbox.maxZ) + ); + + if (rotation.get() == RotationMode.Always) Rotations.rotate(Rotations.getYaw(primary), Rotations.getPitch(primary, Target.Body)); if (pauseOnCombat.get() && BaritoneAPI.getProvider().getPrimaryBaritone().getPathingBehavior().isPathing() && !wasPathing) { BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause"); wasPathing = true; } if (delayCheck()) targets.forEach(this::attack); - - if (randomTeleport.get() && !onlyWhenLook.get()) { - mc.player.setPosition(primary.getX() + randomOffset(), primary.getY(), primary.getZ() + randomOffset()); - } } @EventHandler @@ -319,17 +324,32 @@ private void onSendPacket(PacketEvent.Send event) { } } - private double randomOffset() { - return Math.random() * 4 - 2; + private boolean shouldShieldBreak() { + for (Entity target : targets) { + if (target instanceof PlayerEntity player) { + if (player.blockedByShield(DamageSource.player(mc.player)) && shieldMode.get() == ShieldMode.Break) { + return true; + } + } + } + + return false; } private boolean entityCheck(Entity entity) { if (entity.equals(mc.player) || entity.equals(mc.cameraEntity)) return false; if ((entity instanceof LivingEntity && ((LivingEntity) entity).isDead()) || !entity.isAlive()) return false; - if (noRightClick.get() && (mc.interactionManager.isBreakingBlock() || mc.player.isUsingItem())) return false; - if (!PlayerUtils.isWithin(entity, range.get())) return false; + + Box hitbox = entity.getBoundingBox(); + ((IVec3d)hitVec).set( + MathHelper.clamp(mc.player.getX(), hitbox.minX, hitbox.maxX), + MathHelper.clamp(mc.player.getY(), hitbox.minY, hitbox.maxY), + MathHelper.clamp(mc.player.getZ(), hitbox.minZ, hitbox.maxZ) + ); + if (!PlayerUtils.isWithin(hitVec, range.get())) return false; + if (!entities.get().getBoolean(entity.getType())) return false; - if (!nametagged.get() && entity.hasCustomName()) return false; + if (ignoreNamed.get() && entity.hasCustomName()) return false; if (!PlayerUtils.canSeeEntity(entity) && !PlayerUtils.isWithin(entity, wallsRange.get())) return false; if (ignoreTamed.get()) { if (entity instanceof Tameable tameable @@ -341,13 +361,14 @@ private boolean entityCheck(Entity entity) { if (entity instanceof EndermanEntity enderman && !enderman.isAngryAt(mc.player)) return false; if (entity instanceof ZombifiedPiglinEntity piglin && !piglin.isAngryAt(mc.player)) return false; if (entity instanceof WolfEntity wolf && !wolf.isAttacking()) return false; + if (entity instanceof LlamaEntity llama && !llama.isAttacking()) return false; } if (entity instanceof PlayerEntity player) { if (player.isCreative()) return false; if (!Friends.get().shouldAttack(player)) return false; - if (ignoreShield.get() && player.blockedByShield(DamageSource.player(mc.player))) return false; + if (shieldMode.get() == ShieldMode.Ignore && player.blockedByShield(DamageSource.player(mc.player))) return false; } - return !(entity instanceof AnimalEntity animal) || babies.get() || !animal.isBaby(); + return !(entity instanceof AnimalEntity animal) || !ignoreBabies.get() || !animal.isBaby(); } private boolean delayCheck() { @@ -356,35 +377,29 @@ private boolean delayCheck() { return false; } - if (smartDelay.get()) return mc.player.getAttackCooldownProgress(0.5f) >= 1; + float delay = (customDelay.get()) ? hitDelay.get() : 0.5f; + if (tpsSync.get()) delay /= (TickRate.INSTANCE.getTickRate() / 20); - if (hitDelayTimer > 0) { - hitDelayTimer--; - return false; - } else { - hitDelayTimer = hitDelay.get(); - if (randomDelayEnabled.get()) hitDelayTimer += Math.round(Math.random() * randomDelayMax.get()); - return true; - } + if (customDelay.get()) { + if (hitTimer < delay) { + hitTimer++; + return false; + } else return true; + } else return mc.player.getAttackCooldownProgress(delay) >= 1; } private void attack(Entity target) { - if (Math.random() > hitChance.get() / 100) return; + if (rotation.get() == RotationMode.OnHit) Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target, Target.Body)); - if (rotation.get() == RotationMode.OnHit) rotate(target, () -> hitEntity(target)); - else hitEntity(target); - } - - private void hitEntity(Entity target) { mc.interactionManager.attackEntity(mc.player, target); mc.player.swingHand(Hand.MAIN_HAND); - } - private void rotate(Entity target, Runnable callback) { - Rotations.rotate(Rotations.getYaw(target), Rotations.getPitch(target, Target.Body), callback); + hitTimer = 0; } private boolean itemInHand() { + if (shouldShieldBreak()) return mc.player.getMainHandStack().getItem() instanceof AxeItem; + return switch (weapon.get()) { case Axe -> mc.player.getMainHandStack().getItem() instanceof AxeItem; case Sword -> mc.player.getMainHandStack().getItem() instanceof SwordItem; @@ -416,4 +431,10 @@ public enum RotationMode { OnHit, None } + + public enum ShieldMode { + Ignore, + Break, + None + } }