@@ -52,7 +52,11 @@ public class Reach extends Check implements PacketCheck {
52
52
53
53
private boolean cancelImpossibleHits ;
54
54
private double threshold ;
55
- private double cancelBuffer ; // For the next 4 hits after using reach, we aggressively cancel reach
55
+
56
+ private double flagBufferMax = 1 ;
57
+ private double flagBufferIncrement = 1 ;
58
+ private double flagBufferDecay = 0.25 ;
59
+ private double flagBuffer ; // For the next 4 hits after using reach, we aggressively cancel reach
56
60
57
61
public Reach (GrimPlayer player ) {
58
62
super (player );
@@ -129,7 +133,7 @@ private boolean isKnownInvalid(PacketEntity reachEntity) {
129
133
if (player .compensatedEntities .getSelf ().inVehicle ()) return false ;
130
134
131
135
// Filter out what we assume to be cheats
132
- if (cancelBuffer != 0 ) {
136
+ if (flagBuffer > 0 ) {
133
137
return checkReach (reachEntity , new Vector3d (player .x , player .y , player .z ), true ) != null ; // If they flagged
134
138
} else {
135
139
SimpleCollisionBox targetBox = reachEntity .getPossibleCollisionBoxes ();
@@ -223,13 +227,13 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre
223
227
// if the entity is not exempt and the entity is alive
224
228
if ((!blacklisted .contains (reachEntity .getType ()) && reachEntity .isLivingEntity ()) || reachEntity .getType () == EntityTypes .END_CRYSTAL ) {
225
229
if (minDistance == Double .MAX_VALUE ) {
226
- cancelBuffer = 1 ;
230
+ flagBuffer = Math . min ( flagBuffer + flagBufferIncrement , flagBufferMax ) ;
227
231
return "Missed hitbox" ;
228
232
} else if (minDistance > player .compensatedEntities .getSelf ().getAttributeValue (Attributes .ENTITY_INTERACTION_RANGE )) {
229
- cancelBuffer = 1 ;
233
+ flagBuffer = Math . min ( flagBuffer + flagBufferIncrement , flagBufferMax ) ;
230
234
return String .format ("%.5f" , minDistance ) + " blocks" ;
231
235
} else {
232
- cancelBuffer = Math .max (0 , cancelBuffer - 0.25 );
236
+ flagBuffer = Math .max (0 , flagBuffer - flagBufferDecay );
233
237
}
234
238
}
235
239
@@ -238,7 +242,15 @@ private String checkReach(PacketEntity reachEntity, Vector3d from, boolean isPre
238
242
239
243
@ Override
240
244
public void onReload (ConfigManager config ) {
241
- this .cancelImpossibleHits = config .getBooleanElse ("Reach.block-impossible-hits" , true );
242
- this .threshold = config .getDoubleElse ("Reach.threshold" , 0.0005 );
245
+ this .cancelImpossibleHits = config .getBooleanElse (getConfigName () + ".block-impossible-hits" , true );
246
+ this .threshold = config .getDoubleElse (getConfigName () + ".threshold" , 0.0005 );
247
+
248
+ this .flagBufferMax = config .getDoubleElse (getConfigName () + ".flag-buffer-max" , 1 );
249
+ this .flagBufferIncrement = config .getDoubleElse (getConfigName () + ".flag-buffer-increment" , 1 );
250
+ this .flagBufferDecay = config .getDoubleElse (getConfigName () + ".flag-buffer-decay" , 0.25 );
251
+
252
+ if (this .flagBufferMax == -1 ) {
253
+ this .flagBufferMax = Double .MAX_VALUE ;
254
+ }
243
255
}
244
256
}
0 commit comments