Skip to content

Commit

Permalink
Finish merging new inventory checks and packetorder checks; backport …
Browse files Browse the repository at this point in the history
…to Java 8
  • Loading branch information
Axionize committed Nov 17, 2024
1 parent 7015a9e commit c68f7bd
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package ac.grim.grimac.checks.impl.inventory;

import ac.grim.grimac.GrimAPI;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity.InteractAction;
import io.github.retrooper.packetevents.util.FoliaCompatUtil;

@CheckData(name = "InventoryA", setback = 3)
public class InventoryA extends InventoryCheck {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
package ac.grim.grimac.checks.impl.inventory;

import ac.grim.grimac.GrimAPI;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity.InteractAction;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
import io.github.retrooper.packetevents.util.FoliaCompatUtil;

@CheckData(name = "InventoryB", setback = 3)
public class InventoryB extends InventoryCheck {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
package ac.grim.grimac.checks.impl.inventory;

import ac.grim.grimac.GrimAPI;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.BlockPlace;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import io.github.retrooper.packetevents.util.FoliaCompatUtil;

@CheckData(name = "InventoryC", setback = 3)
public class InventoryC extends InventoryCheck {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package ac.grim.grimac.checks.impl.inventory;

import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.checks.type.PostPredictionCheck;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
import ac.grim.grimac.utils.data.VectorData;
import ac.grim.grimac.utils.data.VectorData.MoveVectorData;
import ac.grim.grimac.utils.data.VehicleData;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientCloseWindow;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerCloseWindow;
import java.util.StringJoiner;

@CheckData(name = "InventoryD", setback = 1, decay = 0.25)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package ac.grim.grimac.checks.impl.inventory;

import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.checks.type.PacketCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.InventoryCheck;
import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;

@CheckData(name = "InventoryG", setback = 3, experimental = true)
public class InventoryG extends InventoryCheck {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public PacketOrderH(final GrimPlayer player) {
public void onPacketReceive(PacketReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.ENTITY_ACTION) {
switch (new WrapperPlayClientEntityAction(event).getAction()) {
case START_SPRINTING, STOP_SPRINTING -> {
case START_SPRINTING:
case STOP_SPRINTING:
if (player.packetOrderProcessor.isSneaking()) {
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) {
flagAndAlert();
} else {
invalid++;
}
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public void onPacketReceive(PacketReceiveEvent event) {
if (damage >= 1 || damage <= 0 && player.gamemode == GameMode.CREATIVE) {
return;
}
case CANCELLED_DIGGING, FINISHED_DIGGING:
case CANCELLED_DIGGING:
case FINISHED_DIGGING:
if (exemptPlacingWhileDigging || player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_7_10)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,47 @@ public void onPacketReceive(PacketReceiveEvent event) {

if (packetType == PacketType.Play.Client.PLAYER_DIGGING) {
switch (new WrapperPlayClientPlayerDigging(event).getAction()) {
case SWAP_ITEM_WITH_OFFHAND -> swapping = true;
case DROP_ITEM, DROP_ITEM_STACK -> dropping = true;
case RELEASE_USE_ITEM -> releasing = true;
case FINISHED_DIGGING, CANCELLED_DIGGING, START_DIGGING -> digging = true;
case SWAP_ITEM_WITH_OFFHAND:
swapping = true;
break;
case DROP_ITEM:
case DROP_ITEM_STACK:
dropping = true;
break;
case RELEASE_USE_ITEM:
releasing = true;
break;
case FINISHED_DIGGING:
case CANCELLED_DIGGING:
case START_DIGGING:
digging = true;
break;
}
}

if (packetType == PacketType.Play.Client.ENTITY_ACTION) {
switch (new WrapperPlayClientEntityAction(event).getAction()) {
case START_SPRINTING, STOP_SPRINTING -> sprinting = true;
case STOP_SNEAKING, START_SNEAKING -> sneaking = true;
case LEAVE_BED -> leavingBed = true;
case START_FLYING_WITH_ELYTRA -> startingToGlide = true;
case OPEN_HORSE_INVENTORY -> openingInventory = true;
case START_JUMPING_WITH_HORSE, STOP_JUMPING_WITH_HORSE -> jumpingWithMount = true;
case START_SPRINTING:
case STOP_SPRINTING:
sprinting = true;
break;
case STOP_SNEAKING:
case START_SNEAKING:
sneaking = true;
break;
case LEAVE_BED:
leavingBed = true;
break;
case START_FLYING_WITH_ELYTRA:
startingToGlide = true;
break;
case OPEN_HORSE_INVENTORY:
openingInventory = true;
break;
case START_JUMPING_WITH_HORSE:
case STOP_JUMPING_WITH_HORSE:
jumpingWithMount = true;
break;
}
}

Expand All @@ -97,8 +123,13 @@ public void onPacketReceive(PacketReceiveEvent event) {
clickingInInventory = true;

switch (new WrapperPlayClientClickWindow(event).getWindowClickType()) {
case QUICK_MOVE -> quickMoveClicking = true;
case PICKUP, PICKUP_ALL -> pickUpClicking = true;
case QUICK_MOVE:
quickMoveClicking = true;
break;
case PICKUP:
case PICKUP_ALL:
pickUpClicking = true;
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void onPostFlyingBlockPlace(BlockPlace place) {
ignorePost = false;
return;
}

blocksChangedList.clear();
// Ray trace to try and hit the target block.
boolean hit = didRayTraceHit(place);
// This can false with rapidly moving yaw in 1.8+ clients
Expand All @@ -83,7 +83,6 @@ public void onPostFlyingBlockPlace(BlockPlace place) {
else {
flagBuffer = Math.max(0, flagBuffer - 0.1);
}
blocksChangedList.clear();
}

private boolean checkIfShouldSkip(BlockPlace place) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/ac/grim/grimac/checks/type/InventoryCheck.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ac.grim.grimac.checks.type;

import ac.grim.grimac.checks.Check;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.data.VectorData;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
Expand Down

0 comments on commit c68f7bd

Please sign in to comment.