Skip to content

Commit ba9024f

Browse files
authored
Merge pull request #6 from N3ROO/MC_1.16.3_dev
Version 1.4.0
2 parents 3bcbbcc + 57c51e6 commit ba9024f

File tree

8 files changed

+59
-19
lines changed

8 files changed

+59
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Version 1.4.0
2+
3+
- Smart aim assistance: it will aim the closest part of a mob (instead of its neck) - (it's optimized)
4+
- "Stop when reached" option for mobs: if turned on, the mob aim assistance stops when you are looking at a mob
5+
16
## Version 1.3.0
27

38
- Support for the best controller mod - [Controllable](https://mrcrayfish.com/mods?id=controllable)

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ apply plugin: 'net.minecraftforge.gradle'
1515
apply plugin: 'eclipse'
1616
apply plugin: 'maven-publish'
1717

18-
version = '1.3.0-MC1.16.x'
18+
version = '1.4.0-MC1.16.x'
1919
group = 'dev.nero.aimassistance' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
2020
archivesBaseName = 'aimassistance'
2121

src/main/java/dev/nero/aimassistance/config/ClientConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
public class ClientConfig {
77

8+
public final ForgeConfigSpec.BooleanValue stopWhenReached;
89
public final ForgeConfigSpec.DoubleValue aimForceMobs;
910
public final ForgeConfigSpec.DoubleValue aimForceBlocks;
1011
public final ForgeConfigSpec.BooleanValue aimMobs;
@@ -14,6 +15,11 @@ public ClientConfig(ForgeConfigSpec.Builder builder) {
1415

1516
builder.push("Aim assistance"); // Category
1617

18+
stopWhenReached = builder
19+
.comment("If true, it will stop assisting once you're looking at a mob")
20+
.translation(AimAssistanceMod.MOD_ID + ".config." + "stopWhenReached")
21+
.define("stopWhenReached", false);
22+
1723
aimForceMobs = builder
1824
.comment("What should be the force of the aim assistance on mobs?")
1925
.translation(AimAssistanceMod.MOD_ID + ".config." + "aimForceMobs")

src/main/java/dev/nero/aimassistance/config/Config.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Config {
1818
CLIENT = specPair.getLeft();
1919
}
2020

21+
private static boolean stopWhenReached;
2122
private static double aimForceMobs;
2223
private static double aimForceBlocks;
2324
private static boolean aimMobs;
@@ -31,12 +32,17 @@ public static void onModConfigEvent(final ModConfig.ModConfigEvent configEvent)
3132
}
3233

3334
public static void bakeConfig() {
35+
stopWhenReached = CLIENT.stopWhenReached.get();
3436
aimForceMobs = CLIENT.aimForceMobs.get();
3537
aimForceBlocks = CLIENT.aimForceBlocks.get();
3638
aimMobs = CLIENT.aimMobs.get();
3739
aimBlocks = CLIENT.aimBlocks.get();
3840
}
3941

42+
public static boolean isStopWhenReached() {
43+
return stopWhenReached;
44+
}
45+
4046
public static double getAimForceMobs() {
4147
return aimForceMobs;
4248
}

src/main/java/dev/nero/aimassistance/core/AimAssistance.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ public void assistIfPossible() {
222222
}
223223
}
224224

225+
// Don't assist if the option to stop when reached is on AND if the player is currently aiming at a mob
226+
if (this.interactingWith == TargetType.ENTITY) {
227+
assist = !(Config.isStopWhenReached() && Wrapper.isPlayerAimingMob());
228+
}
229+
225230
if (assist) Wrapper.setRotations(rotations[0], rotations[1]);
226231
}
227232
}

src/main/java/dev/nero/aimassistance/utils/Wrapper.java

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import dev.nero.aimassistance.core.TargetType;
66
import net.minecraft.client.Minecraft;
77
import net.minecraft.entity.Entity;
8+
import net.minecraft.entity.MobEntity;
89
import net.minecraft.util.math.*;
910
import net.minecraft.util.math.vector.Vector3d;
1011

@@ -103,6 +104,13 @@ private static BlockRayTraceResult rayTrace(double range) {
103104
);
104105
}
105106

107+
/**
108+
* @return true if the player is currently aiming at a mob
109+
*/
110+
public static boolean isPlayerAimingMob() {
111+
return Wrapper.MC.pointedEntity instanceof MobEntity;
112+
}
113+
106114
/**
107115
* @param range in blocks, defines the range around the player to scan for entities
108116
* @param entityClass the entity type to look for (Check the Entity class: MobEntity.class for mobs for example)
@@ -131,7 +139,7 @@ public static Entity getClosestEntityToCrosshair(List<Entity> entities) {
131139

132140
for(Entity entity : entities){
133141
// Get distance between the two entities (rotations)
134-
float[] yawPitch = getYawPitchBetween(
142+
float[] yawPitch = getClosestYawPitchBetween(
135143
Wrapper.MC.player, entity
136144
);
137145

@@ -154,22 +162,32 @@ public static Entity getClosestEntityToCrosshair(List<Entity> entities) {
154162
* @param source the source entity
155163
* @param target the target of the source entity
156164
*/
157-
public static float[] getYawPitchBetween(Entity source, Entity target) {
165+
public static float[] getClosestYawPitchBetween(Entity source, Entity target) {
158166
// getPosY returns the ground position
159167
// getPosY + EyeHeight return the eye's position
160168
// getPosY + EyeHeight/1.5 returns the upper body position
161-
final float SHIFT_FACTOR = 1.25f;
162-
163-
return Wrapper.getYawPitchBetween(
164-
// source
165-
source.getPosX(),
166-
source.getPosY() + source.getEyeHeight(),
167-
source.getPosZ(),
168-
// target
169-
target.getPosX(),
170-
target.getPosY() + (target.getEyeHeight() / SHIFT_FACTOR),
171-
target.getPosZ()
172-
);
169+
//final float SHIFT_FACTOR = 1.25f;
170+
171+
float[] bestYawPitch = new float[] { Float.MAX_VALUE, Float.MAX_VALUE };
172+
173+
for (float factor : new float[]{0f, 0.05f, 0.1f, 0.25f, 0.5f, 0.75f, 1.0f}) {
174+
float[] yawPitch = Wrapper.getYawPitchBetween(
175+
// source
176+
source.getPosX(),
177+
source.getPosY() + source.getEyeHeight(),
178+
source.getPosZ(),
179+
// target
180+
target.getPosX(),
181+
target.getPosY() + target.getEyeHeight() * factor,
182+
target.getPosZ()
183+
);
184+
185+
if (Math.abs(yawPitch[0]) + Math.abs(yawPitch[1]) < Math.abs(bestYawPitch[0]) + Math.abs(bestYawPitch[1])) {
186+
bestYawPitch = yawPitch;
187+
}
188+
}
189+
190+
return bestYawPitch;
173191
}
174192

175193
/**
@@ -206,7 +224,7 @@ public static float[] getRotationsNeeded(Target target, float fovX, float fovY,
206224
// We calculate the yaw/pitch difference between the target and the player
207225
float[] yawPitch;
208226
if (target.getType() == TargetType.ENTITY) {
209-
yawPitch = getYawPitchBetween(
227+
yawPitch = getClosestYawPitchBetween(
210228
Wrapper.MC.player,
211229
(Entity) target.getTarget()
212230
);

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license="MIT License"
55

66
[[mods]]
77
modId="aimassistancemod"
8-
version="1.3.0"
8+
version="1.4.0"
99
displayName="Aim Assistance"
1010
updateJSONURL="https://raw.githubusercontent.com/N3ROO/AimAssistanceMod/MC_1.16.3/update.json"
1111
displayURL="https://github.com/N3ROO/AimAssistanceMod/"

update.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"homepage": "https://github.com/N3ROO/AimAssistanceMod/releases",
33
"promos": {
4-
"1.16.3-latest": "1.3.0",
5-
"1.16.3-recommended": "1.3.0",
4+
"1.16.3-latest": "1.4.0",
5+
"1.16.3-recommended": "1.4.0",
66
"1.15.2-latest": "1.2.0",
77
"1.15.2-recommended": "1.2.0"
88
}

0 commit comments

Comments
 (0)