| 1 | package thunder.hack.features.modules.client;
|
| 2 |
|
| 3 | import meteordevelopment.orbit.EventHandler;
|
| 4 | import net.minecraft.network.protocol.game.ClientboundExplodePacket;
|
| 5 | import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket;
|
| 6 | import net.minecraft.network.protocol.game.ClientboundPlayerPositionPacket;
|
| 7 | import org.jetbrains.annotations.NotNull;
|
| 8 | import thunder.hack.events.impl.PacketEvent;
|
| 9 | import thunder.hack.features.modules.Module;
|
| 10 | import thunder.hack.setting.Setting;
|
| 11 | import thunder.hack.utility.Timer;
|
| 12 |
|
| 13 | public class AntiCrash extends Module { //https://github.com/Bram1903/MinecraftPlayerCrasher
|
| 14 | public final Setting<Boolean> debug = new Setting<>("Debug", false);
|
| 15 |
|
| 16 | private Timer debugTimer = new Timer();
|
| 17 |
|
| 18 | public AntiCrash() {
|
| 19 | super("AntiCrash", Category.CLIENT);
|
| 20 | }
|
| 21 |
|
| 22 | @EventHandler
|
| 23 | public void onPacketReceive(PacketEvent.@NotNull Receive receive) {
|
| 24 | if (receive.getPacket() instanceof ClientboundExplodePacket exp) {
|
| 25 | if (exp.center().x > 1E9 || exp.center().y > 1E9 || exp.center().z > 1E9
|
| 26 | || exp.playerKnockback().map(vec -> Math.abs(vec.x) > 1E9 || Math.abs(vec.y) > 1E9 || Math.abs(vec.z) > 1E9).orElse(false)) {
|
| 27 | if (debug.getValue() && debugTimer.passedMs(1000)) {
|
| 28 | sendMessage("ExplosionS2CPacket canceled");
|
| 29 | debugTimer.reset();
|
| 30 | }
|
| 31 | receive.cancel();
|
| 32 | }
|
| 33 | } else if (receive.getPacket() instanceof ClientboundLevelParticlesPacket p && (p.getX() > 1E9 || p.getY() > 1E9 || p.getZ() > 1E9 || p.getMaxSpeed() > 1E9 || p.getXDist() > 1E9 || p.getYDist() > 1E9 || p.getZDist() > 1E9)) {
|
| 34 | if (debug.getValue() && debugTimer.passedMs(1000)) {
|
| 35 | sendMessage("ParticleS2CPacket canceled");
|
| 36 | debugTimer.reset();
|
| 37 | }
|
| 38 | receive.cancel();
|
| 39 | } else if (receive.getPacket() instanceof ClientboundPlayerPositionPacket pos) {
|
| 40 | if (pos.change().position().x > 1E9 || pos.change().position().y > 1E9 || pos.change().position().z > 1E9
|
| 41 | || pos.change().yRot() > 1E9 || pos.change().xRot() > 1E9) {
|
| 42 | if (debug.getValue() && debugTimer.passedMs(1000)) {
|
| 43 | sendMessage("PlayerPositionLookS2CPacket canceled");
|
| 44 | debugTimer.reset();
|
| 45 | }
|
| 46 | receive.cancel();
|
| 47 | }
|
| 48 | }
|
| 49 | }
|
| 50 | }
|
| 51 |
|