Skip to content

Commit 08029e1

Browse files
authored
Merge pull request #3 from N3ROO/MC_1.16.2_dev
Mc 1.16.2 dev
2 parents 196cdee + ad25911 commit 08029e1

File tree

13 files changed

+133
-29
lines changed

13 files changed

+133
-29
lines changed
3.9 MB
Loading

.github/images/1_2_0_smart_aim.gif

674 KB
Loading
980 KB
Loading

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
## Version 1.2.0
2+
3+
- Smart block aim assistance
4+
5+
**BEFORE:**
6+
![before](.github/images/1_2_0_before_update.gif)
7+
8+
**AFTER:**
9+
10+
It will recognize the block that you're trying to break.
11+
![smart aim](.github/images/1_2_0_smart_aim.gif)
12+
13+
But, if you want to change the block that you're breaking, just move your mouse.
14+
![smart aim](.github/images/1_2_0_smart_aim_captions.gif)
15+
16+
- Improved attack assistance (it puts your crosshair higher than before)
17+
- Increased attack assistance duration (1 sec -> 1.7 sec)
18+
- The assistance won't be running while you're in GUIs
19+
20+
121
## Version 1.1.0
222

323
- Built for forge 1.16.2 (also works with forge 1.16.1)

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
1313
apply plugin: 'eclipse'
1414
apply plugin: 'maven-publish'
1515

16-
version = '1.1.0-MC1.16.2'
16+
version = '1.2.0-MC1.16.2'
1717
group = 'dev.nero.aimassistance' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1818
archivesBaseName = 'aimassistance'
1919

@@ -34,7 +34,7 @@ minecraft {
3434
property 'forge.logging.console.level', 'debug'
3535

3636
mods {
37-
examplemod {
37+
aimassistancemod {
3838
source sourceSets.main
3939
}
4040
}
@@ -43,5 +43,5 @@ minecraft {
4343
}
4444

4545
dependencies {
46-
minecraft 'net.minecraftforge:forge:1.16.2-33.0.21'
46+
minecraft 'net.minecraftforge:forge:1.16.2-33.0.37'
4747
}

src/main/java/dev/nero/aimassistance/AimAssistanceMod.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package dev.nero.aimassistance;
22

33
import dev.nero.aimassistance.config.Config;
4-
import dev.nero.aimassistance.module.AimAssistance;
4+
import dev.nero.aimassistance.core.AimAssistance;
5+
import dev.nero.aimassistance.utils.MouseUtils;
56
import dev.nero.aimassistance.utils.Wrapper;
67
import net.minecraftforge.common.MinecraftForge;
78
import net.minecraftforge.event.TickEvent;
@@ -55,6 +56,7 @@ public void onPlayerTick(TickEvent.PlayerTickEvent playerTickEvent) {
5556
@SubscribeEvent
5657
public void onClientTick(TickEvent.ClientTickEvent clientTickEvent) {
5758
if (Wrapper.playerPlaying()) {
59+
MouseUtils.checkForMouseMove();
5860
aimAssistance.analyseEnvironment();
5961
}
6062
}

src/main/java/dev/nero/aimassistance/module/AimAssistance.java renamed to src/main/java/dev/nero/aimassistance/core/AimAssistance.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package dev.nero.aimassistance.module;
1+
package dev.nero.aimassistance.core;
22

33
import dev.nero.aimassistance.config.Config;
4+
import dev.nero.aimassistance.utils.MouseUtils;
45
import dev.nero.aimassistance.utils.TimeHelper;
56
import dev.nero.aimassistance.utils.Wrapper;
67
import net.minecraft.entity.Entity;
@@ -33,7 +34,7 @@ public class AimAssistance {
3334
private final float INTERACTION_ATTACK_SPEED = 1f / 1000f; // (attacks per ms) user faster means user attacking
3435
private final int INTERACTION_ATTACK_DURATION = 2000; // (ms) duration after which we give up
3536
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
3738
private final int ASSISTANCE_MINING_DURATION = 300; // (ms) duration during which the assistance will assist on blocks
3839
private final float RANGE_TO_SCAN = 5; // (blocks) range to scan from the player to find entities
3940
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) &&
109110
// Else (means that the player is mining) if the player has been mining for the given duration, then they're
110111
// interacting
111112
else if (this.miningTimer.isDelayComplete(this.INTERACTION_MINING_DURATION) && Wrapper.attackKeyPressed()) {
113+
this.attackTimer.stop();
114+
112115
this.miningTimer.stop();
113116
this.interactionTimer.start(); // it will reset if already started, so we're all good
114117
this.interactingWith = TargetType.BLOCK;
@@ -141,6 +144,8 @@ else if (this.attackCount > 0 && playerAttacks) {
141144
// If player's attack speed is greater than the speed given to toggle the assistance, then we can tell to
142145
// the instance that the player is interacting
143146
if (speed > this.INTERACTION_ATTACK_SPEED) {
147+
this.miningTimer.stop();
148+
144149
// We need to reset the variables that are used to define if the player is interacting because we know
145150
// that the user is interacting right now
146151
this.attackCount = 0;
@@ -191,7 +196,33 @@ public void assistIfPossible() {
191196
aimForce, aimForce // forceX, forceY
192197
);
193198

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]);
195226
}
196227
}
197228
}

src/main/java/dev/nero/aimassistance/module/Target.java renamed to src/main/java/dev/nero/aimassistance/core/Target.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dev.nero.aimassistance.module;
1+
package dev.nero.aimassistance.core;
22

33
import net.minecraft.entity.Entity;
44
import net.minecraft.util.Direction;

src/main/java/dev/nero/aimassistance/module/TargetType.java renamed to src/main/java/dev/nero/aimassistance/core/TargetType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package dev.nero.aimassistance.module;
1+
package dev.nero.aimassistance.core;
22

33
public enum TargetType {
44
ENTITY, BLOCK, NONE
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package dev.nero.aimassistance.utils;
2+
3+
/**
4+
* Need this class because forge did not implement the mouse move event. They did for the scroll and
5+
* input events, but not when the mouse moves.
6+
*/
7+
public class MouseUtils {
8+
9+
private static boolean mouseMoved;
10+
11+
private static int delay = 2;
12+
private static double prevX = -1;
13+
private static double prevY = -1;
14+
15+
public static void checkForMouseMove() {
16+
double currX = Wrapper.MC.mouseHelper.getMouseX();
17+
double currY = Wrapper.MC.mouseHelper.getMouseY();
18+
19+
if (prevX != -1 && prevY != -1) {
20+
mouseMoved = prevX != currX || prevY != currY;
21+
}
22+
23+
if (delay == 0) {
24+
prevX = currX;
25+
prevY = currY;
26+
delay = 2;
27+
} else {
28+
delay --;
29+
}
30+
}
31+
32+
public static boolean mouseMoved() {
33+
return mouseMoved;
34+
}
35+
}

0 commit comments

Comments
 (0)