Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class KillAura extends Module {
- public Timer timer = new Timer();
- public NumberSetting range = new NumberSetting("Range", 4, 1, 6.5, 0.1);
- public BooleanSetting rotation = new BooleanSetting("Rotation", true);
- public BooleanSetting noSwing = new BooleanSetting("No Swing", false);
- public static BooleanSetting autoDisable = new BooleanSetting("Auto Disable", true);
- private EntityLivingBase currentTarget; // Add a field to track the current target entity
- private boolean switchingTargets; // Add a field to track if we are currently switching targets in "Single Target" mode
- private ModeSetting mode = new ModeSetting("Mode", "Single Target", "Single Target", "Switch Targets"); // Add a setting to switch between modes
- public KillAura() {
- super("KillAura", Keyboard.KEY_X, Category.COMBAT);
- this.addSettings(range, rotation, noSwing, autoDisable, mode);
- }
- public void onEnable(){
- }
- public void onDisable(){
- currentTarget = null; // Clear the target when disabling the module
- switchingTargets = false;
- }
- public boolean canAttackTarget(Entity entity) {
- return !entity.isDead && entity.isEntityAlive() && mc.player.canEntityBeSeen(entity);
- }
- public void onEvent(Event e){
- if(e instanceof EventMotion) {
- if(e.isPre()) {
- EventMotion event = (EventMotion)e;
- List<Entity> targets = mc.world.loadedEntityList.stream().filter(EntityLivingBase.class::isInstance).collect(Collectors.toList());
- if(mode.isCurrentMode("Single Target")) {
- targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.player) < range.getValue() && entity != mc.player && canAttackTarget(entity) && !entity.isInvisible()).collect(Collectors.toList());
- targets.sort(Comparator.comparingDouble(entity ->((EntityLivingBase)entity).getDistanceToEntity(mc.player)));
- if(!targets.isEmpty()) {
- Entity target = targets.get(0);
- if(currentTarget == null && switchTget) {
- target = currentTarget;
- }
- if (currentTarget != null && (!canAttackTarget(currentTarget) || currentTarget.getDistanceSq(mc.player) > range.getValue() * range.getValue())) {
- // Target is out of range or dead, switch to the nearest target
- currentTarget = null;
- switchTg = true;
- }
- if(currentTarget != null && currentTarget != target) {
- lastTarget = currentTarget; // Set the previous target to the current target
- currentTarget = null; // Clear the target if we switched targets
- switchingTargets = true; // Set switchingTargets to true if we are switching targets
- }
- if(switchingTargets && lastTarget == null) { // If we have just switched to a new target, set lastTarget to the old target
- lastTarget = currentTarget;
- }
- if(lastTarget != null && !canAttackTarget(lastTarget)) { // If the previous target is dead or out of range, clear it
- lastTarget = null;
- }
- if(!switchingTargets && rotation.isEnabled()) {
- float[] rotations = getRotation(currentTarget);
- mc.player.rotationYawHead = rotations[0];
- mc.player.renderYawOffset = rotations[0];
- mc.player.rotationPitchHead = rotations[1];
- }
- if (!mc.player.isHandActive() && mc.player.getCooledAttackStrength(0.0f) >= 1.0f) {
- if(noSwing.isEnabled()) {
- mc.player.connection.sendPacket(new CPacketAnimation());
- } else {
- mc.player.swingArm(EnumHand.MAIN_HAND);
- }
- mc.playerController.attackEntity(mc.player, currentTarget);
- }
- } else {
- currentTarget = null; // Clear the current target if there are no valid targets
- switchingTargets = false;
- lastTarget = null; // Clear the previous target if there are no valid targets
- }
- } else if(mode.isCurrentMode("Switch Targets")) {
- targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.player) < range.getValue() && entity != mc.player && canAttackTarget(entity) && !entity.isInvisible()).collect(Collectors.toList());
- if(!targets.isEmpty()) {
- for(Entity target : targets) {
- if (!mc.player.isHandActive() && mc.player.getCooledAttackStrength(0.0f) >= 1.0f) {
- mc.playerController.attackEntity(mc.player,
Advertisement
Add Comment
Please, Sign In to add comment