@@ -25,8 +25,7 @@ public class AimlessClient implements ClientModInitializer {
2525
2626 private static KeyMapping aimKeyBind ;
2727
28- private static final double MAX_RANGE = 3.0 ;
29- private static final AimlessConfig CONFIG = AimlessConfig .load ();
28+ private static final double MAX_RANGE = 4.0 ;
3029 private int tickCounter = 0 ;
3130 private boolean aiming = false ;
3231
@@ -54,16 +53,24 @@ public void onInitializeClient() {
5453
5554 ClientCommandRegistrationCallback .EVENT .register ((dispatcher , registryAccess ) ->
5655 dispatcher .register (ClientCommands .literal ("aimless" )
56+ .then (ClientCommands .literal ("config" )
57+ .executes (ctx -> {
58+ Minecraft .getInstance ().execute (() ->
59+ Minecraft .getInstance ().setScreen (AimlessConfigScreen .build (null ))
60+ );
61+ return 1 ;
62+ })
63+ )
5764 .then (ClientCommands .literal ("exception" )
5865 .then (ClientCommands .literal ("add" )
5966 .then (ClientCommands .argument ("player" , StringArgumentType .word ())
6067 .suggests (PLAYER_SUGGESTIONS )
6168 .executes (ctx -> {
6269 String name = StringArgumentType .getString (ctx , "player" );
63- if (CONFIG .isExcepted (name )) {
70+ if (AimlessConfig . CONFIG .isExcepted (name )) {
6471 ctx .getSource ().sendFeedback (Component .literal ("§e" + name + " is already excepted" ));
6572 } else {
66- CONFIG .addException (name );
73+ AimlessConfig . CONFIG .addException (name );
6774 ctx .getSource ().sendFeedback (Component .literal ("§aAdded " + name + " to exception list" ));
6875 }
6976 return 1 ;
@@ -75,8 +82,8 @@ public void onInitializeClient() {
7582 .suggests (PLAYER_SUGGESTIONS )
7683 .executes (ctx -> {
7784 String name = StringArgumentType .getString (ctx , "player" );
78- if (CONFIG .isExcepted (name )) {
79- CONFIG .removeException (name );
85+ if (AimlessConfig . CONFIG .isExcepted (name )) {
86+ AimlessConfig . CONFIG .removeException (name );
8087 ctx .getSource ().sendFeedback (Component .literal ("§aRemoved " + name + " from exception list" ));
8188 } else {
8289 ctx .getSource ().sendFeedback (Component .literal ("§e" + name + " is not in the exception list" ));
@@ -87,7 +94,7 @@ public void onInitializeClient() {
8794 )
8895 .then (ClientCommands .literal ("list" )
8996 .executes (ctx -> {
90- java .util .List <String > ex = CONFIG .getExceptions ();
97+ java .util .List <String > ex = AimlessConfig . CONFIG .getExceptions ();
9198 if (ex .isEmpty ()) {
9299 ctx .getSource ().sendFeedback (Component .literal ("§eNo exceptions configured" ));
93100 } else {
@@ -98,7 +105,7 @@ public void onInitializeClient() {
98105 )
99106 .then (ClientCommands .literal ("clear" )
100107 .executes (ctx -> {
101- CONFIG .clearExceptions ();
108+ AimlessConfig . CONFIG .clearExceptions ();
102109 ctx .getSource ().sendFeedback (Component .literal ("§aCleared all exceptions" ));
103110 return 1 ;
104111 })
@@ -107,13 +114,13 @@ public void onInitializeClient() {
107114 .then (ClientCommands .argument ("ticks" , IntegerArgumentType .integer (1 , 100 ))
108115 .executes (ctx -> {
109116 int value = IntegerArgumentType .getInteger (ctx , "ticks" );
110- CONFIG .setReactionTicks (value );
117+ AimlessConfig . CONFIG .setReactionTicks (value );
111118 ctx .getSource ().sendFeedback (Component .literal ("§aReaction ticks set to " + value ));
112119 return 1 ;
113120 })
114121 )
115122 .executes (ctx -> {
116- ctx .getSource ().sendFeedback (Component .literal ("§eReaction ticks: " + CONFIG .getReactionTicks ()));
123+ ctx .getSource ().sendFeedback (Component .literal ("§eReaction ticks: " + AimlessConfig . CONFIG .getReactionTicks ()));
117124 return 1 ;
118125 })
119126 )
@@ -127,7 +134,10 @@ public void onInitializeClient() {
127134
128135 if (aimKeyBind .consumeClick ()) {
129136 aiming = !aiming ;
130- player .sendOverlayMessage (Component .literal (aiming ? "Aimless §aEnabled §7(rt: " + CONFIG .getReactionTicks () + ")" : "Aimless §cDisabled" ));
137+ player .sendOverlayMessage (Component .literal (aiming
138+ ? String .format ("Aimless §aEnabled §7(h: %.0f%% x: %+.1f z: %+.1f rt: %d)" ,
139+ AimlessConfig .CONFIG .getBodyHeight () * 100 , AimlessConfig .CONFIG .getOffsetX (), AimlessConfig .CONFIG .getOffsetZ (), AimlessConfig .CONFIG .getReactionTicks ())
140+ : "Aimless §cDisabled" ));
131141 }
132142
133143 if (!aiming ) {
@@ -136,7 +146,7 @@ public void onInitializeClient() {
136146 }
137147
138148 tickCounter ++;
139- if (tickCounter < CONFIG .getReactionTicks ()) return ;
149+ if (tickCounter < AimlessConfig . CONFIG .getReactionTicks ()) return ;
140150 tickCounter = 0 ;
141151
142152 Player closestTarget = findClosestPlayer (player , level );
@@ -152,7 +162,7 @@ private Player findClosestPlayer(LocalPlayer player, ClientLevel level) {
152162
153163 for (Player target : level .players ()) {
154164 if (target == player || !target .isAlive () || !PlayerEntityVerifier .isLegitimateHumanPlayer (target )
155- || CONFIG .isExcepted (target .getGameProfile ().name ())) continue ;
165+ || AimlessConfig . CONFIG .isExcepted (target .getGameProfile ().name ())) continue ;
156166
157167 double distance = player .distanceTo (target );
158168 if (distance < closestDistance ) {
@@ -165,11 +175,14 @@ private Player findClosestPlayer(LocalPlayer player, ClientLevel level) {
165175
166176 private void applyAim (LocalPlayer player , Player target ) {
167177 Vec3 playerEyePos = player .getEyePosition ();
168- Vec3 targetEyePos = target .getEyePosition ();
169178
170- double dx = targetEyePos .x - playerEyePos .x ;
171- double dy = targetEyePos .y - playerEyePos .y ;
172- double dz = targetEyePos .z - playerEyePos .z ;
179+ double targetX = target .getX () + AimlessConfig .CONFIG .getOffsetX ();
180+ double targetY = target .getY () + (AimlessConfig .CONFIG .getBodyHeight () * target .getBbHeight ());
181+ double targetZ = target .getZ () + AimlessConfig .CONFIG .getOffsetZ ();
182+
183+ double dx = targetX - playerEyePos .x ;
184+ double dy = targetY - playerEyePos .y ;
185+ double dz = targetZ - playerEyePos .z ;
173186 double distanceXZ = Math .sqrt (dx * dx + dz * dz );
174187
175188 float targetYaw = (float ) (Math .atan2 (dz , dx ) * 180.0 / Math .PI ) - 90.0f ;
0 commit comments