-
Notifications
You must be signed in to change notification settings - Fork 359
/
Copy pathFarPlace.java
46 lines (38 loc) · 1.68 KB
/
FarPlace.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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.collisions.datatypes.SimpleCollisionBox;
import ac.grim.grimac.utils.math.VectorUtils;
import com.github.retrooper.packetevents.protocol.player.GameMode;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.util.Vector3i;
import org.bukkit.util.Vector;
@CheckData(name = "FarPlace")
public class FarPlace extends BlockPlaceCheck {
public FarPlace(GrimPlayer player) {
super(player);
}
@Override
public void onBlockPlace(final BlockPlace place) {
Vector3i blockPos = place.getPlacedAgainstBlockLocation();
if (place.getMaterial() == StateTypes.SCAFFOLDING) return;
double min = Double.MAX_VALUE;
for (double d : player.getPossibleEyeHeights()) {
SimpleCollisionBox box = new SimpleCollisionBox(blockPos);
Vector eyes = new Vector(player.x, player.y + d, player.z);
Vector best = VectorUtils.cutBoxToVector(eyes, box);
min = Math.min(min, eyes.distanceSquared(best));
}
// getPickRange() determines this?
double maxReach = player.gamemode == GameMode.CREATIVE ? 6.0 : 4.5D;
double threshold = player.getMovementThreshold();
maxReach += Math.hypot(threshold, threshold);
if (min > maxReach * maxReach) { // fail
if (flagAndAlert() && shouldModifyPackets()) {
place.resync();
}
}
}
}