@@ -34,7 +34,7 @@ public record InvAction(int slot, int button, ActionType action){
3434 @ Override public InvAction clone (){return new InvAction (slot , button , action );}
3535 }
3636
37- private static int MAX_CLICKS ; public static int getMaxClicks (){return MAX_CLICKS ;}
37+ private static int MAX_CLICKS ; public static final int getMaxClicks (){return MAX_CLICKS ;}
3838 private static int [] tickDurationArr ;
3939 private static int tickDurIndex , sumClicksInDuration ;
4040 private static long lastTick ;
@@ -43,9 +43,9 @@ public record InvAction(int slot, int button, ActionType action){
4343 public static long TICK_DURATION = 51l ; // In millis
4444
4545 private static boolean thisClickIsBotted ;
46- public static boolean isThisClickBotted (/*MixinClientPlayerInteractionManager.Friend friend*/ ){return thisClickIsBotted ;}
46+ public static final boolean isThisClickBotted (/*MixinClientPlayerInteractionManager.Friend friend*/ ){return thisClickIsBotted ;}
4747
48- public static void refreshLimits (final int MAX_CLICKS , int FOR_TICKS ){
48+ public static final void refreshLimits (final int MAX_CLICKS , int FOR_TICKS ){
4949 if (clickOpOngoing ){
5050 Main .LOGGER .error ("ClickUtils.refreshLimits() called DURING AN ACTIVE CLICK-OPERATION!! May cause crash or incorrect result" );
5151 }
@@ -74,7 +74,7 @@ public static void refreshLimits(final int MAX_CLICKS, int FOR_TICKS){
7474// return serverInfo == null ? 0 : serverInfo.ping;
7575// }
7676
77- private static void updateAvailableClicks (){
77+ private static final void updateAvailableClicks (){
7878 final long curTick = System .currentTimeMillis ()/TICK_DURATION ;
7979 if (curTick != lastTick ){
8080// final long pingTicks = (long)Math.ceil(getPing()/(double)TICK_DURATION);
@@ -91,14 +91,14 @@ private static void updateAvailableClicks(){
9191 }
9292 }
9393 }
94- public static int calcAvailableClicks (){
94+ public static final int calcAvailableClicks (){
9595 if (tickDurationArr == null ) return MAX_CLICKS ;
9696 synchronized (tickDurationArr ){
9797 updateAvailableClicks ();
9898 return MAX_CLICKS - sumClicksInDuration ;
9999 }
100100 }
101- public static boolean addClick (/*SlotActionType type*/ ){ // friend MixinClientPlayerInteractionManager?
101+ public static final boolean addClick (/*SlotActionType type*/ ){ // friend MixinClientPlayerInteractionManager?
102102// assert type != null; // unused
103103
104104 synchronized (tickDurationArr ){
@@ -111,22 +111,22 @@ public static boolean addClick(/*SlotActionType type*/){ // friend MixinClientPl
111111 }
112112 }
113113
114- private static void adjustTickRate (long msPerTick ){
114+ private static final void adjustTickRate (final long msPerTick ){
115115 // If TPS is degrading, don't clear old tick data (this isn't a perfect solution by any means)
116116 if (msPerTick > TICK_DURATION ) lastTick = System .currentTimeMillis ()/TICK_DURATION ;
117117 else calcAvailableClicks ();
118118 TICK_DURATION = msPerTick ;
119119 lastTick = System .currentTimeMillis ()/TICK_DURATION ;
120120 }
121121
122- private static int calcRemainingTicks (int clicksToExecute ){
122+ private static final int calcRemainingTicks (int clicksToExecute ){
123123 synchronized (tickDurationArr ){
124124 updateAvailableClicks ();
125125 final int availableNow = MAX_CLICKS - sumClicksInDuration ;
126126 if (availableNow >= clicksToExecute ) return 0 ;
127127 clicksToExecute -= availableNow ;
128128 tickDurationArr [tickDurIndex ] += availableNow ;
129-
129+
130130 int ticksIntoFuture ;
131131 for (ticksIntoFuture = 1 ; clicksToExecute > 0 ; ++ticksIntoFuture ){
132132 clicksToExecute -= tickDurationArr [(tickDurIndex + ticksIntoFuture ) % tickDurationArr .length ];
@@ -137,7 +137,7 @@ private static int calcRemainingTicks(int clicksToExecute){
137137 }
138138
139139 private static final Pattern tpsPattern = Pattern .compile ("(\\ d{1,2}(?:\\ .\\ d+))\\ s?tps" , Pattern .CASE_INSENSITIVE );
140- private static long /*getTPS*/ getMillisPerTick (MinecraftClient client ){
140+ private static final long /*getTPS*/ getMillisPerTick (MinecraftClient client ){
141141 // Alternative: client.getNetworkHandler().onPlayerListHeader(PlayerListHeaderS2CPacket plhp)
142142
143143 final AccessorPlayerListHud playerListHudAccessor = (AccessorPlayerListHud )client .inGameHud .getPlayerListHud ();
@@ -156,8 +156,8 @@ private static int calcRemainingTicks(int clicksToExecute){
156156
157157 private static boolean clickOpOngoing /*, waitedForClicks*/ ;
158158 private static int estimatedMsLeft ;
159- public static boolean hasOngoingClicks (){return clickOpOngoing ;}
160- public static void executeClicks (Function <InvAction , Boolean > canProceed , Runnable onComplete , Queue <InvAction > clicks ){
159+ public static final boolean hasOngoingClicks (){return clickOpOngoing ;}
160+ public static final void executeClicks (final Function <InvAction , Boolean > canProceed , final Runnable onComplete , final Queue <InvAction > clicks ){
161161 if (clicks .isEmpty ()){
162162 Main .LOGGER .warn ("executeClicks() called with an empty ClickEvent list" );
163163 onComplete .run ();
@@ -183,14 +183,14 @@ public static void executeClicks(Function<InvAction, Boolean> canProceed, Runnab
183183 estimatedMsLeft = Integer .MAX_VALUE ;
184184
185185 new Timer ().schedule (new TimerTask (){
186- private void stopTask (){
186+ private final void stopTask (){
187187 synchronized (tickDurationArr ){
188188 cancel ();
189189 clickOpOngoing =false ;
190190 onComplete .run ();
191191 }
192192 }
193- @ Override public void run (){
193+ @ Override public final void run (){
194194 if (client .player == null ){
195195 Main .LOGGER .error ("executeClicks() failed due to null player! num clicks in arr: " +sumClicksInDuration );
196196 stopTask (); return ;
@@ -211,7 +211,7 @@ private void stopTask(){
211211 Main .LOGGER .error ("executeClicks() lost available click mid-op, seemingly due to click(s) occuring during check of canProceed()!" );
212212 break ;
213213 }
214- InvAction click = clicks .remove ();
214+ final InvAction click = clicks .remove ();
215215 try {
216216// Main.LOGGER.info("Executing click: "+click.slot+","+click.button+","+click.action+" | available="+calcAvailableClicks());
217217 thisClickIsBotted = true ;
@@ -253,11 +253,11 @@ private void stopTask(){
253253 }
254254 }, 0l , 23l );//51l = just over a tick, 23l=just under half a tick
255255 }
256- public static void executeClicks (Function <InvAction , Boolean > canProceed , Runnable onComplete , InvAction ... clicks ){
256+ public static final void executeClicks (final Function <InvAction , Boolean > canProceed , final Runnable onComplete , final InvAction ... clicks ){
257257 executeClicks (canProceed , onComplete , new ArrayDeque <>(List .of (clicks )));
258258 }
259259
260- public static void executeClicksLEGACY (
260+ public static final void executeClicksLEGACY (
261261 MinecraftClient client ,
262262 Queue <InvAction > clicks , final int MILLIS_BETWEEN_CLICKS , final int MAX_CLICKS_PER_SECOND ,
263263 Function <InvAction , Boolean > canProceed , Runnable onComplete )
0 commit comments