File tree Expand file tree Collapse file tree 5 files changed +10
-5
lines changed
common/src/main/java/ac/grim/grimac Expand file tree Collapse file tree 5 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 88import com .github .retrooper .packetevents .protocol .packettype .PacketType ;
99import com .github .retrooper .packetevents .protocol .packettype .PacketTypeCommon ;
1010import com .github .retrooper .packetevents .protocol .player .ClientVersion ;
11+ import com .github .retrooper .packetevents .protocol .player .DiggingAction ;
1112import lombok .Getter ;
1213import lombok .Setter ;
1314import org .jetbrains .annotations .NotNull ;
@@ -207,4 +208,10 @@ public boolean isTickPacketIncludingNonMovement(PacketTypeCommon packetType) {
207208 return isFlying (packetType );
208209 }
209210
211+ // prevent causing exploits with packet cancelling (ie noslow)
212+ public boolean canCancel (DiggingAction action ) {
213+ return action != DiggingAction .RELEASE_USE_ITEM
214+ // we check client version here because 1.8- doesn't predict dropping items, so we can cancel them. (see CompensatedInventory)
215+ && (action != DiggingAction .DROP_ITEM && action != DiggingAction .DROP_ITEM_STACK || player .getClientVersion ().isOlderThanOrEquals (ClientVersion .V_1_8 ));
216+ }
210217}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
4343 + ", face=" + packet .getBlockFace ()
4444 + ", sequence=" + packet .getSequence ()
4545 + ", action=" + packet .getAction ().toString ().toLowerCase (Locale .ROOT )
46- ) && shouldModifyPackets () && packet .getAction () != DiggingAction . RELEASE_USE_ITEM ) {
46+ ) && shouldModifyPackets () && canCancel ( packet .getAction ()) ) {
4747 event .setCancelled (true );
4848 player .onPacketCancel ();
4949 }
Original file line number Diff line number Diff line change 77import ac .grim .grimac .utils .anticheat .update .PredictionComplete ;
88import com .github .retrooper .packetevents .event .PacketReceiveEvent ;
99import com .github .retrooper .packetevents .protocol .packettype .PacketType ;
10- import com .github .retrooper .packetevents .protocol .player .DiggingAction ;
1110import com .github .retrooper .packetevents .wrapper .play .client .WrapperPlayClientClientStatus ;
1211import com .github .retrooper .packetevents .wrapper .play .client .WrapperPlayClientPlayerDigging ;
1312
@@ -42,7 +41,7 @@ && new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClie
4241 if (!player .canSkipTicks ()) {
4342 if (flagAndAlert (verbose ) && shouldModifyPackets ()) {
4443 if (event .getPacketType () == PacketType .Play .Client .PLAYER_DIGGING
45- && new WrapperPlayClientPlayerDigging (event ).getAction () == DiggingAction . RELEASE_USE_ITEM
44+ && ! canCancel ( new WrapperPlayClientPlayerDigging (event ).getAction ())
4645 ) return ; // don't cause a noslow
4746
4847 event .setCancelled (true );
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ && new WrapperPlayClientClientStatus(event).getAction() == WrapperPlayClientClie
4848 + ", picking=" + player .packetOrderProcessor .isPicking ()
4949 + ", digging=" + player .packetOrderProcessor .isDigging ();
5050 if (!player .canSkipTicks ()) {
51- if (flagAndAlert (verbose ) && shouldModifyPackets ()) {
51+ if (flagAndAlert (verbose ) && shouldModifyPackets () && canCancel ( action ) ) {
5252 event .setCancelled (true );
5353 player .onPacketCancel ();
5454 }
Original file line number Diff line number Diff line change 11package ac .grim .grimac .events .packets ;
22
33import ac .grim .grimac .GrimAPI ;
4- import ac .grim .grimac .checks .impl .movement .NoSlow ;
54import ac .grim .grimac .player .GrimPlayer ;
65import ac .grim .grimac .utils .item .ItemBehaviour ;
76import ac .grim .grimac .utils .item .ItemBehaviourRegistry ;
You can’t perform that action at this time.
0 commit comments