| 
1 |  | -package dev.nero.aimassistance.module;  | 
 | 1 | +package dev.nero.aimassistance.core;  | 
2 | 2 | 
 
  | 
3 | 3 | import dev.nero.aimassistance.config.Config;  | 
 | 4 | +import dev.nero.aimassistance.utils.MouseUtils;  | 
4 | 5 | import dev.nero.aimassistance.utils.TimeHelper;  | 
5 | 6 | import dev.nero.aimassistance.utils.Wrapper;  | 
6 | 7 | import net.minecraft.entity.Entity;  | 
@@ -33,7 +34,7 @@ public class AimAssistance {  | 
33 | 34 |     private final float INTERACTION_ATTACK_SPEED = 1f / 1000f; // (attacks per ms) user faster means user attacking  | 
34 | 35 |     private final int INTERACTION_ATTACK_DURATION = 2000; // (ms) duration after which we give up  | 
35 | 36 |     private final int INTERACTION_MINING_DURATION = 500; // (ms) duration the player needs to be mining to assist  | 
36 |  | -    private final int ASSISTANCE_ATTACK_DURATION = 1000; // (ms) duration during which the assistance will assist on mobs  | 
 | 37 | +    private final int ASSISTANCE_ATTACK_DURATION = 1700; // (ms) duration during which the assistance will assist on mobs  | 
37 | 38 |     private final int ASSISTANCE_MINING_DURATION = 300; // (ms) duration during which the assistance will assist on blocks  | 
38 | 39 |     private final float RANGE_TO_SCAN = 5; // (blocks) range to scan from the player to find entities  | 
39 | 40 |     private final Class<? extends Entity> ENTITY_TYPE_TO_SCAN = MobEntity.class; // defines the type of entity to scan  | 
@@ -109,6 +110,8 @@ else if (!this.miningTimer.isDelayComplete(this.INTERACTION_MINING_DURATION) &&  | 
109 | 110 |         // Else (means that the player is mining) if the player has been mining for the given duration, then they're  | 
110 | 111 |         // interacting  | 
111 | 112 |         else if (this.miningTimer.isDelayComplete(this.INTERACTION_MINING_DURATION) && Wrapper.attackKeyPressed()) {  | 
 | 113 | +            this.attackTimer.stop();  | 
 | 114 | + | 
112 | 115 |             this.miningTimer.stop();  | 
113 | 116 |             this.interactionTimer.start(); // it will reset if already started, so we're all good  | 
114 | 117 |             this.interactingWith = TargetType.BLOCK;  | 
@@ -141,6 +144,8 @@ else if (this.attackCount > 0 && playerAttacks) {  | 
141 | 144 |             // If player's attack speed is greater than the speed given to toggle the assistance, then we can tell to  | 
142 | 145 |             // the instance that the player is interacting  | 
143 | 146 |             if (speed > this.INTERACTION_ATTACK_SPEED) {  | 
 | 147 | +                this.miningTimer.stop();  | 
 | 148 | + | 
144 | 149 |                 // We need to reset the variables that are used to define if the player is interacting because we know  | 
145 | 150 |                 // that the user is interacting right now  | 
146 | 151 |                 this.attackCount = 0;  | 
@@ -191,7 +196,33 @@ public void assistIfPossible() {  | 
191 | 196 |                     aimForce, aimForce // forceX, forceY  | 
192 | 197 |             );  | 
193 | 198 | 
 
  | 
194 |  | -            Wrapper.setRotations(rotations[0], rotations[1]);  | 
 | 199 | +            boolean assist = true;  | 
 | 200 | + | 
 | 201 | +            // We need to prevent focusing an other block while assisting if the player is not moving his mouse  | 
 | 202 | +            if (this.interactingWith == TargetType.BLOCK && !MouseUtils.mouseMoved()) {  | 
 | 203 | +                BlockRayTraceResult nextBlock = Wrapper.rayTrace(  | 
 | 204 | +                        this.BLOCK_REACH, Wrapper.MC.player.getEyePosition(1.0F), rotations[0], rotations[1]  | 
 | 205 | +                );  | 
 | 206 | + | 
 | 207 | +                // If, after moving the mouse, an other block is focused, then don't assist  | 
 | 208 | +                if (nextBlock != null && this.target.getTarget() != null) {  | 
 | 209 | +                    if (this.target.getTarget() instanceof BlockRayTraceResult) {  | 
 | 210 | + | 
 | 211 | +                        BlockPos next = nextBlock.getPos();  | 
 | 212 | +                        BlockPos curr = ((BlockRayTraceResult) this.target.getTarget()).getPos();  | 
 | 213 | + | 
 | 214 | +                        assist = (  | 
 | 215 | +                                next.getX() == curr.getX() &&  | 
 | 216 | +                                        next.getY() == curr.getY() &&  | 
 | 217 | +                                        next.getZ() == curr.getZ()  | 
 | 218 | +                        );  | 
 | 219 | +                    } else {  | 
 | 220 | +                        assist = false;  | 
 | 221 | +                    }  | 
 | 222 | +                }  | 
 | 223 | +            }  | 
 | 224 | + | 
 | 225 | +            if (assist) Wrapper.setRotations(rotations[0], rotations[1]);  | 
195 | 226 |         }  | 
196 | 227 |     }  | 
197 | 228 | }  | 
0 commit comments