Update to 1.21.3/1.21.4 (#399)
* Update to 1.21.3 part 1 Don't expect it to work anytime soon. * Update to 1.21.3 part 2 * Gradle 8.8 -> 8.12 * Working Build 1.21.3 Had to revert gradle to 8.10 due to unforseen issues. * Removed Unused Imports * Small rendering fixes (hopefully) * 1.21.4 port * Use Utils.canUpdate in AutoCraft * Intellij code fixes --------- Co-authored-by: crazymoose77756 <ryanrogo064@gmail.com> Co-authored-by: SByte <stormybytes@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.ExplosionS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class AntiCrash extends Module {
|
||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||
@@ -29,22 +30,25 @@ public class AntiCrash extends Module {
|
||||
@EventHandler
|
||||
private void onPacketReceive(PacketEvent.Receive event) {
|
||||
if (event.packet instanceof ExplosionS2CPacket packet) {
|
||||
if (/* outside of world */ packet.getX() > 30_000_000 || packet.getY() > 30_000_000 || packet.getZ() > 30_000_000 || packet.getX() < -30_000_000 || packet.getY() < -30_000_000 || packet.getZ() < -30_000_000 ||
|
||||
// power too high
|
||||
packet.getRadius() > 1000 ||
|
||||
// too many blocks
|
||||
packet.getAffectedBlocks().size() > 100_000 ||
|
||||
Vec3d explodePos = packet.center();
|
||||
// TODO: 1.21.3
|
||||
Vec3d playerKnockback = new Vec3d(0, 0, 0);
|
||||
if(packet.playerKnockback().isPresent()) {
|
||||
playerKnockback = packet.playerKnockback().get();
|
||||
}
|
||||
if (/* outside of world */ explodePos.getX() > 30_000_000 || explodePos.getY() > 30_000_000 || explodePos.getZ() > 30_000_000 || explodePos.getX() < -30_000_000 || explodePos.getY() < -30_000_000 || explodePos.getZ() < -30_000_000 ||
|
||||
// too much knockback
|
||||
packet.getPlayerVelocityX() > 30_000_000 || packet.getPlayerVelocityY() > 30_000_000 || packet.getPlayerVelocityZ() > 30_000_000
|
||||
playerKnockback.x > 30_000_000 || playerKnockback.y > 30_000_000 || playerKnockback.z > 30_000_000
|
||||
// knockback can be negative?
|
||||
|| packet.getPlayerVelocityX() < -30_000_000 || packet.getPlayerVelocityY() < -30_000_000 || packet.getPlayerVelocityZ() < -30_000_000
|
||||
|| playerKnockback.x < -30_000_000 || playerKnockback.y < -30_000_000 || playerKnockback.z < -30_000_000
|
||||
) cancel(event);
|
||||
} else if (event.packet instanceof ParticleS2CPacket packet) {
|
||||
// too many particles
|
||||
if (packet.getCount() > 100_000) cancel(event);
|
||||
} else if (event.packet instanceof PlayerPositionLookS2CPacket packet) {
|
||||
Vec3d playerPos = packet.change().position();
|
||||
// out of world movement
|
||||
if (packet.getX() > 30_000_000 || packet.getY() > 30_000_000 || packet.getZ() > 30_000_000 || packet.getX() < -30_000_000 || packet.getY() < -30_000_000 || packet.getZ() < -30_000_000)
|
||||
if (playerPos.x > 30_000_000 || playerPos.y > 30_000_000 || playerPos.z > 30_000_000 || playerPos.x < -30_000_000 || playerPos.y < -30_000_000 || playerPos.z < -30_000_000)
|
||||
cancel(event);
|
||||
} else if (event.packet instanceof EntityVelocityUpdateS2CPacket packet) {
|
||||
// velocity
|
||||
|
||||
Reference in New Issue
Block a user