nguyenphuc2009

killaura chatgpt

Jun 24th, 2023
1,027
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.47 KB | None | 0 0
  1. public class KillAura extends Module {
  2.    
  3.     public Timer timer = new Timer();
  4.     public NumberSetting range = new NumberSetting("Range", 4, 1, 6.5, 0.1);
  5.     public BooleanSetting rotation = new BooleanSetting("Rotation", true);
  6.     public BooleanSetting noSwing = new BooleanSetting("No Swing", false);
  7.     public static BooleanSetting autoDisable = new BooleanSetting("Auto Disable", true);
  8.     private EntityLivingBase currentTarget; // Add a field to track the current target entity
  9.     private boolean switchingTargets; // Add a field to track if we are currently switching targets in "Single Target" mode
  10.     private ModeSetting mode = new ModeSetting("Mode", "Single Target", "Single Target", "Switch Targets"); // Add a setting to switch between modes
  11.    
  12.     public KillAura() {
  13.         super("KillAura", Keyboard.KEY_X, Category.COMBAT);
  14.         this.addSettings(range, rotation, noSwing, autoDisable, mode);
  15.     }
  16.    
  17.     public void onEnable(){
  18.        
  19.     }
  20.    
  21.     public void onDisable(){
  22.         currentTarget = null; // Clear the target when disabling the module
  23.         switchingTargets = false;
  24.     }
  25.    
  26.     public boolean canAttackTarget(Entity entity) {
  27.         return !entity.isDead && entity.isEntityAlive() && mc.player.canEntityBeSeen(entity);
  28.     }
  29.    
  30.     public void onEvent(Event e){
  31.         if(e instanceof EventMotion) {
  32.             if(e.isPre()) {
  33.                 EventMotion event = (EventMotion)e;
  34.                
  35.                 List<Entity> targets = mc.world.loadedEntityList.stream().filter(EntityLivingBase.class::isInstance).collect(Collectors.toList());
  36.                
  37.                 if(mode.isCurrentMode("Single Target")) {
  38.                     targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.player) < range.getValue() && entity != mc.player && canAttackTarget(entity) && !entity.isInvisible()).collect(Collectors.toList());
  39.                
  40.                     targets.sort(Comparator.comparingDouble(entity ->((EntityLivingBase)entity).getDistanceToEntity(mc.player)));
  41.                
  42.                     if(!targets.isEmpty()) {
  43.                         Entity target = targets.get(0);
  44.  
  45.                         if(currentTarget == null && switchTget) {
  46.                             target = currentTarget;
  47.                         }
  48.  
  49.     if (currentTarget != null && (!canAttackTarget(currentTarget) || currentTarget.getDistanceSq(mc.player) > range.getValue() * range.getValue())) {
  50.                     // Target is out of range or dead, switch to the nearest target
  51.                     currentTarget = null;
  52.                     switchTg = true;
  53.                 }
  54.                        
  55.                         if(currentTarget != null && currentTarget != target) {
  56.                             lastTarget = currentTarget; // Set the previous target to the current target
  57.                             currentTarget = null; // Clear the target if we switched targets
  58.                             switchingTargets = true; // Set switchingTargets to true if we are switching targets
  59.                         }
  60.    
  61.                         if(switchingTargets && lastTarget == null) { // If we have just switched to a new target, set lastTarget to the old target
  62.                             lastTarget = currentTarget;
  63.                         }
  64.                        
  65.                         if(lastTarget != null && !canAttackTarget(lastTarget)) { // If the previous target is dead or out of range, clear it
  66.                             lastTarget = null;
  67.                         }
  68.    
  69.                         if(!switchingTargets && rotation.isEnabled()) {    
  70.                             float[] rotations = getRotation(currentTarget);
  71.                             mc.player.rotationYawHead = rotations[0];
  72.                             mc.player.renderYawOffset = rotations[0];
  73.                             mc.player.rotationPitchHead = rotations[1];
  74.                         }
  75.                        
  76.                         if (!mc.player.isHandActive() && mc.player.getCooledAttackStrength(0.0f) >= 1.0f) {
  77.                             if(noSwing.isEnabled()) {
  78.                                 mc.player.connection.sendPacket(new CPacketAnimation());
  79.                             } else {
  80.                                 mc.player.swingArm(EnumHand.MAIN_HAND);
  81.                             }
  82.                                                
  83.                             mc.playerController.attackEntity(mc.player, currentTarget);                    
  84.                         }
  85.                     } else {
  86.                         currentTarget = null; // Clear the current target if there are no valid targets
  87.                         switchingTargets = false;
  88.                         lastTarget = null; // Clear the previous target if there are no valid targets
  89.                     }
  90.                 } else if(mode.isCurrentMode("Switch Targets")) {
  91.                     targets = targets.stream().filter(entity -> entity.getDistanceToEntity(mc.player) < range.getValue() && entity != mc.player && canAttackTarget(entity) && !entity.isInvisible()).collect(Collectors.toList());
  92.                    
  93.                     if(!targets.isEmpty()) {
  94.                         for(Entity target : targets) {
  95.                             if (!mc.player.isHandActive() && mc.player.getCooledAttackStrength(0.0f) >= 1.0f) {
  96.                                 mc.playerController.attackEntity(mc.player,
Advertisement
Add Comment
Please, Sign In to add comment