-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1726 from ManInMyVan/multiplace
Add MultiPlace
- Loading branch information
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/main/java/ac/grim/grimac/checks/impl/scaffolding/MultiPlace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package ac.grim.grimac.checks.impl.scaffolding; | ||
|
||
import ac.grim.grimac.checks.CheckData; | ||
import ac.grim.grimac.checks.type.BlockPlaceCheck; | ||
import ac.grim.grimac.player.GrimPlayer; | ||
import ac.grim.grimac.utils.anticheat.update.BlockPlace; | ||
import ac.grim.grimac.utils.anticheat.update.PredictionComplete; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.protocol.player.ClientVersion; | ||
import com.github.retrooper.packetevents.protocol.world.BlockFace; | ||
import com.github.retrooper.packetevents.util.Vector3f; | ||
import com.github.retrooper.packetevents.util.Vector3i; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static ac.grim.grimac.utils.anticheat.MessageUtil.toUnlabledString; | ||
|
||
@CheckData(name = "MultiPlace", experimental = true) | ||
public class MultiPlace extends BlockPlaceCheck { | ||
public MultiPlace(GrimPlayer player) { | ||
super(player); | ||
} | ||
|
||
private final List<String> flags = new ArrayList<>(); | ||
|
||
private boolean hasPlaced; | ||
private BlockFace lastFace; | ||
private Vector3f lastCursor; | ||
private Vector3i lastPos; | ||
|
||
@Override | ||
public void onBlockPlace(final BlockPlace place) { | ||
final BlockFace face = place.getDirection(); | ||
final Vector3f cursor = place.getCursor(); | ||
final Vector3i pos = place.getPlacedAgainstBlockLocation(); | ||
|
||
if (hasPlaced && (face != lastFace || !cursor.equals(lastCursor) || !pos.equals(lastPos))) { | ||
final String verbose = "face=" + face + ", lastFace=" + lastFace | ||
+ ", cursor=" + toUnlabledString(cursor) + ", lastCursor=" + toUnlabledString(lastCursor) | ||
+ ", pos=" + toUnlabledString(pos) + ", lastPos=" + toUnlabledString(lastPos); | ||
if (player.getClientVersion().isOlderThanOrEquals(ClientVersion.V_1_8)) { | ||
if (flagAndAlert(verbose) && shouldModifyPackets() && shouldCancel()) { | ||
place.resync(); | ||
} | ||
} else { | ||
flags.add(verbose); | ||
} | ||
} | ||
|
||
lastFace = face; | ||
lastCursor = cursor; | ||
lastPos = pos; | ||
hasPlaced = true; | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { | ||
hasPlaced = false; | ||
} | ||
} | ||
|
||
@Override | ||
public void onPredictionComplete(PredictionComplete predictionComplete) { | ||
if (player.getClientVersion().isNewerThan(ClientVersion.V_1_8) && !player.skippedTickInActualMovement) { | ||
for (String verbose : flags) { | ||
flagAndAlert(verbose); | ||
} | ||
} | ||
|
||
flags.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters