0x12 S12PacketEntityVelocity
Sets an entity's velocity (e.g., from knockback, explosion, piston push).
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| entityId | VarInt | |
| motionX | short | Velocity X × 8000 |
| motionY | short | Velocity Y × 8000 |
| motionZ | short | Velocity Z × 8000 |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Entity ID | VarInt | |
| Velocity X | short | × 8000 |
| Velocity Y | short | × 8000 |
| Velocity Z | short | × 8000 |
MCP References
NetHandlerPlayClient.handleEntityVelocity()Handler Interface
INetHandlerPlayClientNotes
Vanilla Source
| 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 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
Deobfuscated MCP 1.8.9 source of S12PacketEntityVelocity, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S12PacketEntityVelocity.java) at build time and verified present.
Deep Dive
Role in the protocol
The velocity/knockback packet: entity id plus three motion shorts at x8000. The server emits it in three situations: EntityTrackerEntry broadcasts when a tracked entity's motion changes beyond a threshold (sendVelocityUpdates with lastTrackedEntityMotionX/Y/Z), EntityPlayer.attackEntityFrom sends it to the damaged player with the knockback vector, and explosions apply their push through S27. handleEntityVelocity overwrites the target entity's motion directly, which makes this the single most important clientbound packet for anti-knockback work.
Vanilla handling
EntityTrackerEntry compares the tracked entity's current motion to the last tracked values each tick and sends S12 when the delta crosses the threshold; EntityPlayer.attackEntityFrom sends the knockback vector straight to the damaged player's connection. On the client, handleEntityVelocity sets motionX/Y/Z = value / 8000.0 with no interpolation and no validation, so the packet is a direct write into the physics state that every movement check in the tick loop reads.
Why clients touch it
The most-handled clientbound packet in the corpus after S08. Four families: (1) cancel-or-scale anti-knockback (Memeware, Nekoware, Spicy, Tenacity, Rise 5.99 Custom); (2) per-anticheat timing games that cancel selectively or replay the knockback the way the anticheat expects (Rise 5.99 Vulcan/Tick Cancel/Stack/Follow First Tick/Ground, Sigma AACPush/AACFlag, the Rise 6.x ten-mode Velocity suite); (3) movement modules that consume S12 as a boost trigger (Rise 6.x GrimFlight TNT, WatchdogLongJump, WatchdogFireball, MatrixFlight, MineLandFlight, WatchdogBowLongJump; Rise 5.99 Fly Minemenclub and LongJump Hycraft/Vulcan; Sigma Fly; Tenacity FlightModule); (4) infrastructure: Rise's PingSpoofComponent buffers S12 in the velocity class, EntityTickComponent and ItemDamageComponent observe it, and Timer/Breaker/HurtCamera cancel it as collateral. November Recode 2.0's VelocityModule adds REDUCE, REVERSE, CANCEL and the per-anticheat GRIM, VULCAN, WATCHDOG and WATCHDOG_SAFE modes, with GRIM buffering S32 transactions and VULCAN cancelling the C0F echo.
Exploit surface
The server recomputes knockback from attack packets and expects the resulting motion to appear in the player's reported positions over the next ticks. Cancelling S12 desyncs those reports, which is exactly what velocity checks measure, so the arms race is about timing: Tick Cancel and Stack modes cancel the first N velocity packets and let one through to satisfy the check, Sigma's AACFlag injects a NaN position to blind the check, and WatchdogVelocity modes apply the knockback client-side exactly as the server computes it. The companion S27PacketExplosion carries its own knockback and must be handled separately, which is why every serious module pairs S12 and S27. Rise 5.99 even ships an anticheat-side velocity recorder in dev/rise/anticheat/data/PlayerData.java and a dcOnVeloCheck disconnect in AutoHypixel that reacts to velocity-based server checks.
Server-Side Handling
EntityTrackerEntry keeps lastTrackedEntityMotionX/Y/Z and sends S12 to tracked players when the entity's motion changes beyond a threshold (sendVelocityUpdates). EntityPlayer.attackEntityFrom sends S12 to the damaged player with the knockback vector from the attacker's motion. The client applies value / 8000.0 directly to motionX/Y/Z with no validation, so the packet is a trusted write into the physics state. Explosion knockback travels separately in S27 and is not covered by S12.
Protocol Analysis
VarInt entity id plus three shorts at x8000, no rotations, no metadata. Values are signed, so negative motion (pulled, pushed back) encodes naturally. The client divides by 8000.0 on apply; the short range limits motion to roughly -4.096 to 4.096 blocks/tick. Because the write is direct, packet order matters: an S12 arriving after the tick's movement code runs applies one tick late, which knockback-timing modules exploit.
Anti-Cheat Landscape
Velocity checks reconcile the knockback vector with the player's reported position over the following ticks. Cancelling S12 is instantly measurable, so modern modes instead cancel selectively (first N packets, then pass one), reverse the vector (Sigma AACPush converts it into a strafe boost), or replay the exact server motion (WatchdogVelocity). Grim and Vulcan are sensitive to delayed application, which is why Rise 6.x splits the Velocity module into per-anticheat modes (GrimVelocity, VulcanVelocity, MMCVelocity, RedeskyVelocity, UniversoCraftVelocity, WatchdogPredictionVelocity) and why Rise 5.99's own anticheat records S12 in PlayerData.java for its checks.
implementation Implementation Cases
The knockback packet: three shorts at x8000 written directly into entity motion. The most-handled clientbound packet in the 8-client corpus, spanning cancel-or-scale anti-knockback (Memeware, Nekoware, Spicy, Tenacity, Rise 5.99), per-anticheat timing suites (Sigma AAC modes, Rise 5.99 modes, the Rise 6.x ten-mode Velocity module), movement modules that use S12 as a boost trigger (GrimFlight TNT, WatchdogLongJump, WatchdogFireball, Sigma Fly), and component infrastructure (PingSpoofComponent buffers it as the velocity class).
Remove or scale knockback by intercepting the S12 that targets the local player.
A packet-receive handler checks the entity id; if it matches the player, the packet is cancelled outright (Memeware, Nekoware, Rise 5.99 at 0% settings) or its motion fields are scaled by horizontal/vertical percentages (Spicy, Tenacity). S27PacketExplosion is cancelled or scaled in the same handler because explosion knockback bypasses S12.
// ===== FILE: Memeware 7.3, me/memewaredevs/client/module/combat/Velocity.java =====
package me.memewaredevs.client.module.combat;
import me.hippo.api.lwjeb.annotation.Handler;
import me.memewaredevs.client.event.events.PacketInEvent;
import me.memewaredevs.client.module.Module;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S27PacketExplosion;
import java.util.function.Consumer;
public class Velocity extends Module {
public Velocity(final String name, final int key, final Module.Category category) {
super(name, key, category);
}
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
@Handler
public Consumer<PacketInEvent> update = e -> {
if (mc.thePlayer == null) {
return;
}
if (e.getPacket() instanceof S27PacketExplosion) {
e.cancel();
}
if (e.getPacket() instanceof S12PacketEntityVelocity) {
final S12PacketEntityVelocity packetEntityVelocity = (S12PacketEntityVelocity) e.getPacket();
if (packetEntityVelocity.func_149412_c() != mc.thePlayer.getEntityId()) {
return;
}
e.cancel();
}
};
}
// NOTE (AI): Cancels S27PacketExplosion unconditionally and S12 only when the entity id matches the local player. The event bus delivers clientbound packets before the vanilla handler, so the cancel prevents NetHandlerPlayClient from applying the motion. Classic full anti-knockback: no scaling, no modes, no timing games.Defeat knockback with anticheat-specific tricks instead of a plain cancel.
Basic mode scales or cancels S12 and cancels S27. AACPush samples the knockback vector, cancels the packet and turns the stored motion into a decaying strafe boost over 10 ticks. AACFlag cancels the packet and injects a C04 with NaN Y while the player is in hurt time, desyncing the anticheat's position model.
// ===== FILE: Sigma 4.11, info/sigmaclient/module/impl/combat/AntiVelocity.java =====
package info.sigmaclient.module.impl.combat;
import tv.twitch.chat.Chat;
import info.sigmaclient.Client;
import info.sigmaclient.event.Event;
import info.sigmaclient.event.RegisterEvent;
import info.sigmaclient.event.impl.EventPacket;
import info.sigmaclient.event.impl.EventUpdate;
import info.sigmaclient.management.MoveUtils;
import info.sigmaclient.module.Module;
import info.sigmaclient.module.data.ModuleData;
import info.sigmaclient.module.data.Options;
import info.sigmaclient.module.data.Setting;
import info.sigmaclient.module.impl.movement.Fly;
import info.sigmaclient.util.MathUtils;
import info.sigmaclient.util.misc.ChatUtil;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C03PacketPlayer.C04PacketPlayerPosition;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S27PacketExplosion;
import net.minecraft.util.MathHelper;
/*
* Made by LeakedPvP
*/
public class AntiVelocity extends Module {
private String VELOCITY = "MODE";
public AntiVelocity(ModuleData data) {
super(data);
settings.put(VELOCITY, new Setting<>(VELOCITY, new Options("Mode", "Basic", new String[]{"Basic", "AACPush", "AACFlag"}), "AntiVelocity method."));
settings.put(HORIZONTAL, new Setting<>(HORIZONTAL, 0, "Horizontal velocity factor.", 10, 0, 100));
settings.put(VERTICAL, new Setting<>(VERTICAL, 0, "Vertical velocity factor.", 10, 0, 100));
}
double count = 0;
public static String HORIZONTAL = "HORIZONTAL";
public static String VERTICAL = "VERTICAL";
double xmot, zmot, ymot = 0;
@Override
public void onEnable() {
super.onEnable();
count = 0;
}
@Override
@RegisterEvent(events = {EventPacket.class,EventUpdate.class})
public void onEvent(Event event) {
String currentMode = ((Options) settings.get(VELOCITY).getValue()).getSelected();
setSuffix(currentMode);
if(event instanceof EventPacket){
EventPacket ep = (EventPacket) event;
Packet p = ep.getPacket();
if (ep.isOutgoing()) {
if (p instanceof C03PacketPlayer)
return;
}
if(p instanceof S08PacketPlayerPosLook){
S08PacketPlayerPosLook pac = (S08PacketPlayerPosLook) ep.getPacket();
if(currentMode.equalsIgnoreCase("AACFlag") && mc.thePlayer.hurtResistantTime > 0){
pac.yaw = mc.thePlayer.rotationYaw;
pac.pitch = mc.thePlayer.rotationPitch;
}
}
if (p instanceof S12PacketEntityVelocity) {
S12PacketEntityVelocity packet = (S12PacketEntityVelocity) p;
int entId = packet.getEntityID();
int x = packet.getX();
int y = packet.getY();
int z = packet.getZ();
if (entId == mc.thePlayer.getEntityId() && !(Client.getModuleManager().isEnabled(Fly.class) && ((Options)Client.getModuleManager().get(Fly.class).getSetting("MODE").getValue()).getSelected().equalsIgnoreCase("BowFly"))) {
switch(currentMode){
case"AACPush":
if(x != 0 && z != 0){
count = 10;
xmot = x/1000;
zmot = z/1000;
}
break;
case"Basic":
int vertical = ((Number) settings.get(VERTICAL).getValue()).intValue();
int horizontal = ((Number) settings.get(HORIZONTAL).getValue()).intValue();
if (vertical != 0 || horizontal != 0) {
packet.setMotX(horizontal * packet.getX() / 100);
packet.setMotY(vertical * packet.getY() / 100);
packet.setMotZ(horizontal * packet.getZ() / 100);
} else {
ep.setCancelled(true);
}
break;
case"AACFlag":
if(x != 0 && z != 0){
C04PacketPlayerPosition pack = new C04PacketPlayerPosition(mc.thePlayer.posX, Double.NaN, mc.thePlayer.posZ, true);
mc.thePlayer.sendQueue.addToSendQueue(pack);
ep.setCancelled(true);
}
break;
}
}
}
if (p instanceof S27PacketExplosion && currentMode.equalsIgnoreCase("basic")) {
if(ep.isPre()){
ep.setCancelled(true);
}
}
}else if(event instanceof EventUpdate && mc.thePlayer.hurtResistantTime > 0 && currentMode.equalsIgnoreCase("aacpush")){
if(count > 0){
double boost = 0.05 - count/200;
count --;
if(count <=10){
double speedcheck = Math.sqrt(xmot * xmot + zmot * zmot);
MoveUtils.strafe(boost);
double speed = Math.sqrt(mc.thePlayer.motionX * mc.thePlayer.motionX + mc.thePlayer.motionZ * mc.thePlayer.motionZ);
if(speed > 0.35){
count = 0;
mc.thePlayer.motionX *= 0;
mc.thePlayer.motionZ *= 0;
MoveUtils.strafe(0.2);
}
if(mc.thePlayer.moveForward == 0 && mc.thePlayer.moveStrafing == 0){
double value = 0.8-boost;
mc.thePlayer.motionX *= value;
mc.thePlayer.motionZ *= value;
}
}
}
}
}
}
// NOTE (AI): Three modes. Basic scales or cancels S12 and cancels S27. AACPush converts the knockback vector into a decaying strafe boost over 10 ticks. AACFlag sends a NaN-position C04 while the knockback is live to derail the anticheat's position tracking, then cancels the packet. The Fly BowFly check stops anti-knockback from eating the velocity a bow-boost fly depends on.Per-anticheat anti-knockback: ten modes in the Velocity module, each tuned to a specific server anticheat.
Each mode is a Mode subclass of the Velocity module handling PacketReceiveEvent: StandardVelocity scales/cancels and optionally copies the server's vertical motion into motionY; GrimVelocity, VulcanVelocity, MMCVelocity, RedeskyVelocity and UniversoCraftVelocity tune cancellation and replay timing per anticheat; WatchdogVelocity and WatchdogPredictionVelocity emulate the knockback the Watchdog check expects; BufferAbuseVelocity and LegitVelocity delay or minimize application. The onSwing gate skips handling unless the player is swinging, which hides the module's presence during combos.
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/combat/velocity/StandardVelocity.java =====
package com.alan.clients.module.impl.combat.velocity;
import com.alan.clients.Client;
import com.alan.clients.event.Listener;
import com.alan.clients.event.Priorities;
import com.alan.clients.event.annotations.EventLink;
import com.alan.clients.event.impl.motion.PreMotionEvent;
import com.alan.clients.event.impl.other.TeleportEvent;
import com.alan.clients.event.impl.packet.PacketReceiveEvent;
import com.alan.clients.module.impl.combat.Criticals;
import com.alan.clients.module.impl.combat.Velocity;
import com.alan.clients.module.impl.movement.Speed;
import com.alan.clients.util.packet.PacketUtil;
import com.alan.clients.util.player.MoveUtil;
import com.alan.clients.value.Mode;
import com.alan.clients.value.impl.BooleanValue;
import com.alan.clients.value.impl.NumberValue;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C07PacketPlayerDigging;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S27PacketExplosion;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
public final class StandardVelocity extends Mode<Velocity> {
public Boolean disable2 = false;
private Integer time = 0;
private Speed speed = null;
private String mode = null;
private int amount;
private final NumberValue horizontal = new NumberValue("Horizontal", this, 0, 0, 100, 1);
private final NumberValue vertical = new NumberValue("Vertical", this, 0, 0, 100, 1);
private final BooleanValue onExplode = new BooleanValue("Explosion Ignore", this, false);
@Override
public void onEnable() {
time = 0;
setDisable2(false);
}
public StandardVelocity(String name, Velocity parent) {
super(name, parent);
}
@EventLink(value = Priorities.VERY_LOW)
public final Listener<PacketReceiveEvent> onPacketReceiveEvent = event -> {
if ((getParent().onSwing.getValue() && !mc.thePlayer.isSwingInProgress) || event.isCancelled()) {
return;
}
final Packet<?> p = event.getPacket();
final double horizontal = this.horizontal.getValue().doubleValue();
final double vertical = this.vertical.getValue().doubleValue();
final boolean onExplode = this.onExplode.getValue();
if (p instanceof S12PacketEntityVelocity) {
final S12PacketEntityVelocity wrapper = (S12PacketEntityVelocity) p;
if (wrapper.getEntityID() == mc.thePlayer.getEntityId()) {
if (horizontal == 0) {
if (vertical != 0 && !event.isCancelled()) {
mc.thePlayer.motionY = wrapper.getMotionY() / 8000.0D;
}
event.setCancelled();
return;
}
wrapper.motionX *= horizontal / 100;
wrapper.motionY *= vertical / 100;
wrapper.motionZ *= horizontal / 100;
event.setPacket(wrapper);
}
} else if (p instanceof S27PacketExplosion) {
final S27PacketExplosion wrapper = (S27PacketExplosion) p;
if (onExplode) {
event.setCancelled();
return;
}
wrapper.posX *= horizontal / 100;
wrapper.posY *= vertical / 100;
wrapper.posZ *= horizontal / 100;
event.setPacket(wrapper);
}
};
@EventLink
public final Listener<PreMotionEvent> onPreMotionEvent = event -> {
if (speed == null) {
speed = getModule(Speed.class);
}
/*
if(speed.isEnabled() && Client.INSTANCE.getModuleManager().get(Speed.class).mode.getValue().getName().equals("Watchdog")) {
if (mc.thePlayer.hurtTime > 9) {
mc.thePlayer.motionZ *= 0;
mc.thePlayer.motionX *= 0;
time++;
if (!MoveUtil.isMoving()) {
mc.thePlayer.motionZ *= 0;
mc.thePlayer.motionX *= 0;
}
}
if (mc.thePlayer.hurtTime == 9) {
if (MoveUtil.isMoving() && !mc.thePlayer.onGround && !( mc.thePlayer.offGroundTicks == 1)) {
// MoveUtil.partialStrafePercent(99);
double speed =1;
speed = Math.random()/50;
MoveUtil.strafe(.3);
// mc.thePlayer.motionZ *= .95;
// mc.thePlayer.motionX *= .95;
} else {
mc.thePlayer.motionZ *= -.2;
mc.thePlayer.motionX *= -.2;
}
}
}
*/
};
@EventLink
public final Listener<TeleportEvent> onTeleport = event -> {
if (event.getPosY() < mc.thePlayer.posY - 2);
};
public Boolean getDisable2() {
return disable2;
}
public void setDisable2(Boolean disable2) {
this.disable2 = disable2;
}
}
// NOTE (AI): Base mode of the Rise 6.x Velocity module. Cancels S12 outright when both sliders are 0, otherwise rescales and re-sets the packet on the event so the pipeline sees a modified packet. The vertical-only branch copies the server velocity into motionY directly, preserving the y-component anti-cheats expect while dropping horizontal drift. S27 explosion knockback is scaled or cancelled via the Explosion Ignore toggle.Use the player's own S12 as a trigger or fuel for flight and longjump acceleration.
Flight and longjump modes listen for S12 targeting the player and either flip a state flag that enables teleport-style flight (GrimFlight TNT), buffer the velocity for a follow-up boost (WatchdogLongJump, WatchdogFireball), or scale it into movement acceleration (Sigma Fly, Tenacity FlightModule). The packet is deliberately not cancelled, because the anti-cheat expects the knockback motion to exist.
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/movement/flight/GrimFlight.java =====
package com.alan.clients.module.impl.movement.flight;
import com.alan.clients.component.impl.player.Slot;
import com.alan.clients.component.impl.render.NotificationComponent;
import com.alan.clients.event.Listener;
import com.alan.clients.event.annotations.EventLink;
import com.alan.clients.event.impl.motion.PreMotionEvent;
import com.alan.clients.event.impl.other.TeleportEvent;
import com.alan.clients.event.impl.packet.PacketReceiveEvent;
import com.alan.clients.module.impl.movement.Flight;
import com.alan.clients.util.chat.ChatUtil;
import com.alan.clients.util.packet.PacketUtil;
import com.alan.clients.util.player.MoveUtil;
import com.alan.clients.util.rotation.RotationUtil;
import com.alan.clients.util.vector.Vector2f;
import com.alan.clients.util.vector.Vector3d;
import com.alan.clients.value.Mode;
import com.alan.clients.value.impl.ModeValue;
import com.alan.clients.value.impl.SubMode;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
public class GrimFlight extends Mode<Flight> {
private final ModeValue Mode = new ModeValue("Sub-Mode", this)
.add(new SubMode("Block"))
.add(new SubMode("TNT"))
.setDefault("Block");
private Boolean Flight;
public GrimFlight(String name, Flight parent) {
super(name, parent);
}
@Override
public void onEnable() {
Flight = false;
if(Mode.getValue().getName().equals("Block")) {
ChatUtil.display("Any blocks you place will be ghost blocks. You have infinite range to place blocks.");
} else {
NotificationComponent.post("Grim TNT Fly","Get knock-back from a TNT to trigger the flight",2500);
}
}
@EventLink
private final Listener<PreMotionEvent> preMotion = event -> {
switch(Mode.getValue().getName()) {
case "Block":
if (mc.gameSettings.keyBindUseItem.isKeyDown()) {
// Creating a variable that gets the block that the user is looking at and creating another variable with incremented Y position of the position so that the user teleports on top of the block.
MovingObjectPosition movingObjectPosition = mc.thePlayer.rayTrace(999, 1);
if (movingObjectPosition == null) return;
final BlockPos pos = movingObjectPosition.getBlockPos();
final BlockPos tpPos = pos.offset(movingObjectPosition.sideHit, 4);
Vector2f rotations = RotationUtil.calculate(
new Vector3d(tpPos.getX(), tpPos.getY(), tpPos.getZ()),
new Vector3d(pos.getX(), pos.getY(), pos.getZ()));
PacketUtil.send(new C03PacketPlayer.C06PacketPlayerPosLook(tpPos.getX(), tpPos.getY() - 1, tpPos.getZ(), rotations.x, rotations.y, false));
mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, getComponent(Slot.class).getItemStack(),
movingObjectPosition.getBlockPos(), movingObjectPosition.sideHit, movingObjectPosition.hitVec);
}
break;
case "TNT":
if(Flight) {
final double yaw = Math.toRadians(MoveUtil.direction());
event.setPosX(mc.thePlayer.posX - Math.sin(yaw) * 500);
event.setPosY(MoveUtil.predictedMotion(mc.thePlayer.motionY));
event.setPosZ(mc.thePlayer.posZ + Math.cos(yaw) * 500);
}
break;
}
};
@EventLink
private final Listener<PacketReceiveEvent> packetReceiveEventListener = event -> {
if (Mode.getValue().getName().equals("TNT")) {
if (event.getPacket() instanceof S12PacketEntityVelocity) {
final S12PacketEntityVelocity packet = (S12PacketEntityVelocity) event.getPacket();
if (packet.getEntityID() != mc.thePlayer.getEntityId()) {
return;
}
Flight = true;
}
}
};
@EventLink
private final Listener<TeleportEvent> teleport = event -> {
if (Mode.getValue().getName().equals("Block") && mc.gameSettings.keyBindUseItem.isKeyDown()) event.setCancelled();
};
}
// NOTE (AI): TNT sub-mode turns the player's own S12 into a flight trigger: the packet is not cancelled, it flips the Flight flag, and PreMotion then reports the player 500 blocks ahead along the move direction every tick. Letting the velocity packet through is deliberate, because Grim's knockback check expects the motion to be present.Delay S12 alongside transactions and keepalives while ping spoofing, which delays knockback application as a side effect.
The component classifies packets into tuples: S12 is grouped with S27 in the velocity tuple. While a spoof is active, matching packets are cancelled from the event stream and parked in a timestamped queue; onPostMotion flushes entries whose delay elapsed via PacketUtil.queue, which bypasses the event bus. The players tuple holds S13 and the S14/S18/S19/S20 entity stream so entity ordering survives the buffering.
// ===== FILE: Rise 6.1.30, com/alan/clients/component/impl/player/PingSpoofComponent.java =====
package com.alan.clients.component.impl.player;
import com.alan.clients.component.Component;
import com.alan.clients.event.CancellableEvent;
import com.alan.clients.event.Listener;
import com.alan.clients.event.annotations.EventLink;
import com.alan.clients.event.impl.motion.PostMotionEvent;
import com.alan.clients.event.impl.other.WorldChangeEvent;
import com.alan.clients.event.impl.packet.PacketReceiveEvent;
import com.alan.clients.event.impl.packet.PacketSendEvent;
import com.alan.clients.util.packet.PacketUtil;
import net.minecraft.client.gui.GuiDownloadTerrain;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.*;
import net.minecraft.network.play.server.*;
import net.minecraft.util.Tuple;
import rip.vantage.commons.util.time.StopWatch;
import java.util.Arrays;
import java.util.concurrent.ConcurrentLinkedQueue;
public final class PingSpoofComponent extends Component {
public static ConcurrentLinkedQueue<PacketUtil.TimedPacket> packets = new ConcurrentLinkedQueue<>();
static StopWatch enabledTimer = new StopWatch();
public static boolean enabled;
static long amount;
static Tuple<Class[], Boolean> regular = new Tuple<>(new Class[]{C0FPacketConfirmTransaction.class, C00PacketKeepAlive.class, S1CPacketEntityMetadata.class}, false);
static Tuple<Class[], Boolean> velocity = new Tuple<>(new Class[]{S12PacketEntityVelocity.class, S27PacketExplosion.class}, false);
static Tuple<Class[], Boolean> teleports = new Tuple<>(new Class[]{S08PacketPlayerPosLook.class, S39PacketPlayerAbilities.class, S09PacketHeldItemChange.class}, false);
static Tuple<Class[], Boolean> players = new Tuple<>(new Class[]{S13PacketDestroyEntities.class, S14PacketEntity.class, S14PacketEntity.S16PacketEntityLook.class, S14PacketEntity.S15PacketEntityRelMove.class, S14PacketEntity.S17PacketEntityLookMove.class, S18PacketEntityTeleport.class, S20PacketEntityProperties.class, S19PacketEntityHeadLook.class}, false);
static Tuple<Class[], Boolean> blink = new Tuple<>(new Class[]{C02PacketUseEntity.class, C0DPacketCloseWindow.class, C0EPacketClickWindow.class, C0CPacketInput.class, C0BPacketEntityAction.class, C08PacketPlayerBlockPlacement.class, C07PacketPlayerDigging.class, C09PacketHeldItemChange.class, C13PacketPlayerAbilities.class, C15PacketClientSettings.class, C16PacketClientStatus.class, C17PacketCustomPayload.class, C18PacketSpectate.class, C19PacketResourcePackStatus.class, C03PacketPlayer.class, C03PacketPlayer.C04PacketPlayerPosition.class, C03PacketPlayer.C05PacketPlayerLook.class, C03PacketPlayer.C06PacketPlayerPosLook.class, C0APacketAnimation.class}, false);
static Tuple<Class[], Boolean> movement = new Tuple<>(new Class[]{C03PacketPlayer.class, C03PacketPlayer.C04PacketPlayerPosition.class, C03PacketPlayer.C05PacketPlayerLook.class, C03PacketPlayer.C06PacketPlayerPosLook.class}, false);
public static Tuple<Class[], Boolean>[] types = new Tuple[]{regular, velocity, teleports, players, blink, movement};
@EventLink
public final Listener<PacketSendEvent> send = event -> event.setCancelled(onPacket(event.getPacket(), event).isCancelled());
@EventLink
public final Listener<PacketReceiveEvent> receive = event -> event.setCancelled(onPacket(event.getPacket(), event).isCancelled());
public CancellableEvent onPacket(Packet<?> packet, CancellableEvent event) {
if (!event.isCancelled() && enabled && Arrays.stream(types).anyMatch(tuple -> tuple.getSecond() && Arrays.stream(tuple.getFirst()).anyMatch(regularpacket -> regularpacket == packet.getClass()))) {
event.setCancelled();
packets.add(new PacketUtil.TimedPacket(packet));
}
return event;
}
public static void dispatch() {
if (!packets.isEmpty()) {
// Stops the packets from being called twice
boolean enabled = PingSpoofComponent.enabled;
PingSpoofComponent.enabled = false;
packets.forEach(timedPacket -> PacketUtil.queue(timedPacket.getPacket()));
PingSpoofComponent.enabled = enabled;
packets.clear();
}
}
public static void disable() {
enabled = false;
enabledTimer.setMillis(enabledTimer.millis - 999999999);
}
@EventLink
public final Listener<WorldChangeEvent> onWorldChange = event -> dispatch();
@EventLink
public final Listener<PostMotionEvent> onPostMotion = event -> {
if (!(enabled = !enabledTimer.finished(100) && !(mc.currentScreen instanceof GuiDownloadTerrain))) {
dispatch();
} else {
// Stops the packets from being called twice
enabled = false;
packets.forEach(packet -> {
if (packet.getTime() + amount < System.currentTimeMillis()) {
PacketUtil.queue(packet.getPacket());
packets.remove(packet);
}
});
enabled = true;
}
};
public static void spoof(int amount, boolean regular, boolean velocity, boolean teleports, boolean players) {
spoof(amount, regular, velocity, teleports, players, false);
}
public static void spoof(int amount, boolean regular, boolean velocity, boolean teleports, boolean players, boolean blink, boolean movement) {
enabledTimer.reset();
PingSpoofComponent.regular.setSecond(regular);
PingSpoofComponent.velocity.setSecond(velocity);
PingSpoofComponent.teleports.setSecond(teleports);
PingSpoofComponent.players.setSecond(players);
PingSpoofComponent.blink.setSecond(blink);
PingSpoofComponent.movement.setSecond(movement);
PingSpoofComponent.amount = amount;
}
public static void spoof(int amount, boolean regular, boolean velocity, boolean teleports, boolean players, boolean blink) {
spoof(amount, regular, velocity, teleports, players, blink, false);
}
public static void blink() {
spoof(9999999, true, false, false, false, true);
}
}
// NOTE (AI): Component shared by PingSpoof and the Timer module. S12 is grouped with S27 in the velocity tuple; while a spoof is active the packets are pulled out of the event stream, timestamped and replayed by dispatch(). Delaying S12 delays knockback application, so the component doubles as a soft anti-velocity. The players tuple (S13, S14 family, S18, S19, S20) keeps entity-stream ordering intact while entity packets are held.Per-mode anti-knockback: scale, reverse or cancel S12 for the local player, with anticheat-specific transaction handling for Grim and Vulcan.
The packet listener ignores S12 whose entity id is not the local player, then switches on mode. REDUCE and REVERSE scale the motion fields in place with horizontal and vertical percentages and REVERSE negates the result; CANCEL, GRIM and VULCAN cancel the event; INTAVE and WATCHDOG are TODO stubs; WATCHDOG_SAFE cancels then re-applies only the vertical component to motionY while on the ground. GRIM mode additionally buffers S32 confirm-transaction actions and cancels the matching C0F echo on the send side; VULCAN cancels a single C0F echo after the first knockback.
// ===== FILE: November Recode 2.0, feature/module/impl/combat/VelocityModule.java =====
/* November.lol © 2023 */
package lol.november.feature.module.impl.combat;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import lol.november.feature.module.Category;
import lol.november.feature.module.Module;
import lol.november.feature.module.Register;
import lol.november.feature.setting.Setting;
import lol.november.listener.bus.Listener;
import lol.november.listener.bus.Subscribe;
import lol.november.listener.event.net.EventPacket;
import lol.november.listener.event.player.EventUpdate;
import net.minecraft.network.play.client.C0FPacketConfirmTransaction;
import net.minecraft.network.play.server.S12PacketEntityVelocity;
import net.minecraft.network.play.server.S32PacketConfirmTransaction;
/**
* @author Gavin
* @since 2.0.0
*/
@Register(
name = "Velocity",
description = "Reduces or cancels out taken velocity",
category = Category.COMBAT
)
public class VelocityModule extends Module {
private final Setting<Mode> mode = new Setting<>("Mode", Mode.CANCEL);
private final Setting<Float> horizontal = new Setting<>(
() -> mode.getValue() == Mode.REDUCE || mode.getValue() == Mode.REVERSE,
"Horizontal",
50.0f,
0.01f,
0.0f,
200.0f
);
private final Setting<Float> vertical = new Setting<>(
() -> mode.getValue() == Mode.REDUCE || mode.getValue() == Mode.REVERSE,
"Vertical",
50.0f,
0.01f,
0.0f,
200.0f
);
private final Queue<Short> transactionQueue = new ConcurrentLinkedQueue<>();
private boolean funny;
@Override
public void disable() {
super.disable();
funny = false;
transactionQueue.clear();
}
@Subscribe
private final Listener<EventUpdate> update = event -> {
if (mode.getValue() == Mode.GRIM) {
// finish trolling
if (transactionQueue.isEmpty() && funny) funny = false;
}
};
@Subscribe
private final Listener<EventPacket.In> packetIn = event -> {
if (mc.thePlayer == null || mc.theWorld == null) {
// basic resets
funny = false;
if (!transactionQueue.isEmpty()) transactionQueue.clear();
return;
}
if (event.get() instanceof S12PacketEntityVelocity packet) {
if (packet.getEntityID() != mc.thePlayer.getEntityId()) return;
switch (mode.getValue()) {
case REDUCE, REVERSE -> {
packet.setMotionX(
(int) (packet.getMotionX() * (horizontal.getValue() / 100.0f))
);
packet.setMotionY(
(int) (packet.getMotionY() * (vertical.getValue() / 100.0f))
);
packet.setMotionZ(
(int) (packet.getMotionZ() * (horizontal.getValue() / 100.0f))
);
if (mode.getValue() == Mode.REVERSE) {
packet.setMotionX(-packet.getMotionX());
packet.setMotionY(-packet.getMotionY());
packet.setMotionZ(-packet.getMotionZ());
}
}
case CANCEL, GRIM, VULCAN -> {
event.setCanceled(true);
if (
mode.getValue() == Mode.GRIM || mode.getValue() == Mode.VULCAN
) funny = true;
}
case INTAVE -> {
// TODO: i have no clue
}
case WATCHDOG -> {
// TODO: frappy or plus add this i dont have alts
}
case WATCHDOG_SAFE -> {
event.setCanceled(true);
if (mc.thePlayer.onGround) {
// as far as im aware, this should work
mc.thePlayer.motionY += (double) packet.getMotionY() / 8000.0;
}
}
}
} else if (event.get() instanceof S32PacketConfirmTransaction packet) {
if (mode.getValue() == Mode.GRIM) {
if (!funny) return;
event.setCanceled(true);
transactionQueue.add(packet.getActionNumber());
}
}
};
@Subscribe
private final Listener<EventPacket.Out> packetOut = event -> {
if (event.get() instanceof C0FPacketConfirmTransaction packet) {
if (mode.getValue() == Mode.GRIM) {
if (!funny || transactionQueue.isEmpty()) return;
// if the queue contains our transaction UID, cancel
if (transactionQueue.remove(packet.getUid())) event.setCanceled(true);
} else if (mode.getValue() == Mode.VULCAN) {
// this works on older versions of vulcan
if (funny) {
event.setCanceled(true);
funny = false;
}
}
}
};
private enum Mode {
REDUCE,
REVERSE,
CANCEL,
GRIM,
INTAVE,
VULCAN,
WATCHDOG,
WATCHDOG_SAFE,
}
}
// NOTE (AI): VelocityModule is a per-mode anti-knockback. REDUCE and REVERSE scale the motion fields in place using horizontal and vertical percentages, REVERSE negates the result, CANCEL, GRIM and VULCAN cancel the event outright, INTAVE and WATCHDOG are TODO stubs, and WATCHDOG_SAFE cancels the packet then re-applies the vertical component directly to motionY only while on the ground. GRIM mode pairs the S12 cancel with S32 confirm-transaction buffering: incoming S32 actions are queued and the matching C0F echo is cancelled on the send side, hiding the transaction gap Grim uses to detect velocity removal. VULCAN cancels a single C0F echo after the first knockback to break the check's sync window. The funny flag gates both transaction paths.anticheat Anti-Cheat Checks
S12 is the server telling the client to apply a velocity vector, normally knockback, and every anticheat treats it as a promise: the client's next movement ticks must reflect the vector it was sent. The corpus splits into direct statistical checks (Azure VelocityA compares the vertical delta against the sent vector) and transaction-ordered simulation checks (Grim KnockbackHandler, Artemis VelocityPreProcessor, Frequency VelocityManager) that know exactly when the packet arrived at the client and require the knockback in the following prediction. This packet is the reason anti-knockback cheats cancel or alter S12 specifically.
Requires the client's simulated motion to include the exact knockback vector the server sent, flagging any reduction or delay.
On the OUT side, wraps each entity-velocity packet for the player (or their vehicle) between two transaction packets, recording the vector with the first transaction id. As client transactions arrive, knockbacks move from a future queue into known-taken state; the prediction engine then compares the player's actual movement against the required knockback, accumulating a threshold-bounded buffer and triggering a setback above the immediate threshold.
// ===== FILE: GrimAnticheat-Grim, common/src/main/java/ac/grim/grimac/checks/impl/velocity/KnockbackHandler.java =====
package ac.grim.grimac.checks.impl.velocity;
import ac.grim.grimac.api.config.ConfigManager;
import ac.grim.grimac.api.storage.verbose.Verbose;
import ac.grim.grimac.checks.Check;
import ac.grim.grimac.checks.CheckData;
import ac.grim.grimac.checks.type.PacketSendListener;
import ac.grim.grimac.checks.type.PostPredictionListener;
import ac.grim.grimac.player.GrimPlayer;
import ac.grim.grimac.utils.anticheat.update.PredictionComplete;
import ac.grim.grimac.utils.data.Pair;
import ac.grim.grimac.utils.data.VectorData;
import ac.grim.grimac.utils.data.VelocityData;
import ac.grim.grimac.utils.math.Vector3dm;
import com.github.retrooper.packetevents.event.PacketSendEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.util.Vector3d;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityVelocity;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import java.util.Deque;
import java.util.LinkedList;
// We are making a velocity sandwich between two pieces of transaction packets (bread)
@CheckData(name = "AntiKB", stableKey = "grim.velocity.anti_knockback", alternativeName = "AntiKnockback", configName = "Knockback", description = "Did not take the expected entity knockback", setback = 10, decay = 0.025)
public class KnockbackHandler extends Check implements PacketSendListener, PostPredictionListener {
private static final Verbose V = Verbose.of("[ignored knockback|o: {offset}]");
private final Deque<VelocityData> firstBreadMap = new LinkedList<>();
private final Deque<VelocityData> lastKnockbackKnownTaken = new LinkedList<>();
private VelocityData firstBreadOnlyKnockback = null;
@Getter
private boolean knockbackPointThree = false;
private double offsetToFlag;
private double maxAdv, immediate, ceiling, multiplier;
private double threshold;
public KnockbackHandler(GrimPlayer player) {
super(player);
}
@Override
public void onPacketSend(final PacketSendEvent event) {
if (event.getPacketType() == PacketType.Play.Server.ENTITY_VELOCITY) {
WrapperPlayServerEntityVelocity velocity = new WrapperPlayServerEntityVelocity(event);
int entityId = velocity.getEntityId();
// Detect whether this knockback packet affects the player or if it is useless
// Mojang sends extra useless knockback packets for no apparent reason
if (player.compensatedEntities.serverPlayerVehicle != null && entityId != player.compensatedEntities.serverPlayerVehicle) {
return;
}
if (player.compensatedEntities.serverPlayerVehicle == null && entityId != player.entityID) {
return;
}
// If the player isn't in a vehicle and the ID is for the player, the player will take kb
// If the player is in a vehicle and the ID is for the player's vehicle, the player will take kb
Vector3d playerVelocity = velocity.getVelocity();
// Blacklist problemated vector until mojang fixes a client-sided bug
if (playerVelocity.getY() == -0.04) {
velocity.setVelocity(playerVelocity.add(new Vector3d(0, 1 / 8000D, 0)));
playerVelocity = velocity.getVelocity();
event.markForReEncode(true);
}
playerVelocity = VectorPrecisionConverter.convert(player.getClientVersion(), playerVelocity);
// Wrap velocity between two transactions
player.sendTransaction();
addPlayerKnockback(entityId, player.lastTransactionSent.get(), new Vector3dm(playerVelocity.getX(), playerVelocity.getY(), playerVelocity.getZ()));
event.getTasksAfterSend().add(player::sendTransaction);
}
}
@NotNull
public Pair<VelocityData, Vector3dm> getFutureKnockback() {
// Chronologically in the future
if (!firstBreadMap.isEmpty()) {
VelocityData data = firstBreadMap.peek();
return new Pair<>(data, data != null ? data.vector : null);
}
// Less in the future
if (!lastKnockbackKnownTaken.isEmpty()) {
VelocityData data = lastKnockbackKnownTaken.peek();
return new Pair<>(data, data != null ? data.vector : null);
}
// Uncertain, might be in the future
if (player.firstBreadKB != null && player.likelyKB == null) {
VelocityData data = player.firstBreadKB;
return new Pair<>(data, data.vector.clone());
} else if (player.likelyKB != null) { // Known to be in the present
VelocityData data = player.likelyKB;
return new Pair<>(data, data.vector.clone());
}
return new Pair<>(null, null);
}
private void addPlayerKnockback(int entityID, int breadOne, @NotNull Vector3dm knockback) {
firstBreadMap.add(new VelocityData(entityID, breadOne, player.getSetbackTeleportUtil().isSendingSetback, knockback));
}
public VelocityData calculateRequiredKB(int entityID, int transaction, boolean isJustTesting) {
tickKnockback(transaction);
VelocityData returnLastKB = null;
for (VelocityData data : lastKnockbackKnownTaken) {
if (data.entityID == entityID)
returnLastKB = data;
}
if (!isJustTesting) {
lastKnockbackKnownTaken.clear();
}
return returnLastKB;
}
private void tickKnockback(int transactionID) {
firstBreadOnlyKnockback = null;
if (firstBreadMap.isEmpty()) return;
VelocityData data = firstBreadMap.peek();
while (data != null) {
if (data.transaction == transactionID) { // First bread knockback
firstBreadOnlyKnockback = new VelocityData(data.entityID, data.transaction, data.isSetback, data.vector);
//firstBreadMap.poll();
break; // All knockback after this will have not been applied
} else if (data.transaction < transactionID) { // This kb has 100% arrived to the player
VelocityData velocityData = new VelocityData(data.entityID, data.transaction, data.isSetback, data.vector);
if (firstBreadOnlyKnockback != null) { // Don't require kb twice
velocityData.offset = data.offset;
}
lastKnockbackKnownTaken.add(velocityData);
// Knockback has been applied and is now required, remove it from first bread
firstBreadOnlyKnockback = null;
firstBreadMap.poll();
data = firstBreadMap.peek();
} else { // We are too far ahead in the future
break;
}
}
}
public void forceExempt() {
// Unsure knockback was taken
if (player.firstBreadKB != null) {
player.firstBreadKB.offset = 0;
}
if (player.likelyKB != null) {
player.likelyKB.offset = 0;
}
}
public void setPointThree(boolean isPointThree) {
knockbackPointThree = knockbackPointThree || isPointThree;
}
public void handlePredictionAnalysis(double offset) {
if (player.firstBreadKB != null) {
player.firstBreadKB.offset = Math.min(player.firstBreadKB.offset, offset);
}
if (player.likelyKB != null) {
player.likelyKB.offset = Math.min(player.likelyKB.offset, offset);
}
}
@Override
public void onPredictionComplete(final PredictionComplete predictionComplete) {
double offset = predictionComplete.getOffset();
if (!predictionComplete.isChecked() || predictionComplete.getData().isTeleport()) {
forceExempt();
return;
}
boolean wasZero = knockbackPointThree;
knockbackPointThree = false;
if (player.likelyKB == null && player.firstBreadKB == null) {
return;
}
if (player.predictedVelocity.isFirstBreadKb()) {
firstBreadOnlyKnockback = null;
firstBreadMap.poll(); // Remove from map so we don't pull it again
}
if (wasZero || player.predictedVelocity.isKnockback()) {
// Unsure knockback was taken
if (player.firstBreadKB != null) {
player.firstBreadKB.offset = Math.min(player.firstBreadKB.offset, offset);
}
// 100% known kb was taken
if (player.likelyKB != null) {
player.likelyKB.offset = Math.min(player.likelyKB.offset, offset);
}
}
if (player.likelyKB != null) {
if (player.likelyKB.offset > offsetToFlag) {
threshold = Math.min(threshold + player.likelyKB.offset, ceiling);
if (player.likelyKB.isSetback) { // Don't increase violations if this velocity was setback, just teleport and resend them velocity.
if (!isNoSetbackPermission()) {
player.getSetbackTeleportUtil().executeViolationSetback();
}
} else {
boolean ignored = player.likelyKB.offset == Integer.MAX_VALUE;
if (flag(V.write(verbose()).bool(ignored).f64(player.likelyKB.offset))) { // This velocity was sent by the server.
if (player.likelyKB.offset >= immediate || threshold >= maxAdv) {
setbackIfAboveSetbackVL();
}
} else {
reward();
}
}
} else if (threshold > 0.05) {
threshold *= multiplier;
}
}
}
public boolean shouldIgnoreForPrediction(VectorData data) {
if (data.isKnockback() && data.isFirstBreadKb()) {
return player.firstBreadKB.offset > offsetToFlag;
}
return false;
}
public boolean wouldFlag() {
return (player.likelyKB != null && player.likelyKB.offset > offsetToFlag) || (player.firstBreadKB != null && player.firstBreadKB.offset > offsetToFlag);
}
public VelocityData calculateFirstBreadKnockback(int entityID, int transaction) {
tickKnockback(transaction);
if (firstBreadOnlyKnockback != null && firstBreadOnlyKnockback.entityID == entityID)
return firstBreadOnlyKnockback;
return null;
}
@Override
public void onReload(@NotNull ConfigManager config) {
offsetToFlag = config.getDoubleElse("Knockback.threshold", 0.001);
maxAdv = config.getDoubleElse("Knockback.max-advantage", 1);
immediate = config.getDoubleElse("Knockback.immediate-setback-threshold", 0.1);
multiplier = config.getDoubleElse("Knockback.setback-decay-multiplier", 0.999);
ceiling = config.getDoubleElse("Knockback.max-ceiling", 4);
if (maxAdv < 0) maxAdv = Double.MAX_VALUE;
if (immediate < 0) immediate = Double.MAX_VALUE;
}
}
// NOTE (AI): Grim even rewrites a vanilla bug vector (Y = -0.04) before recording it, so the required knockback matches what the client actually applies.Classic 1.8 statistical check: the reported upward move after a knockback packet must be at least 77 percent of the sent vertical velocity.
Reads the OUT entity-velocity packet, keeps the vertical component (field c divided by 8000.0) when the entity id matches the player, and skips causes that do not produce knockback (starvation, fire, drowning, poison, wither, thorns, fall, lava). On the next upward move it compares deltaY to the recorded velocity and reports the taken percentage as a violation.
// ===== FILE: AimbotPvP-azure-anticheat, src/main/java/us/skidrevenant/azure/check/checks/combat/velocity/VelocityA.java =====
package us.skidrevenant.azure.check.checks.combat.velocity;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityVelocity;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerMoveEvent;
import us.skidrevenant.azure.check.Check;
import us.skidrevenant.azure.stats.PlayerStats;
import us.skidrevenant.azure.util.reflection.ReflectionUtil;
/**
* @author SkidRevenant
* at 30/05/2018
*/
public class VelocityA extends Check {
private double verticalVelocity;
public VelocityA(PlayerStats player) {
super(player);
}
@Override
public void onMove(Location from, Location to, PlayerMoveEvent event) {
if (from.getY() >= to.getY()) {
return;
}
double deltaY = to.getY() - from.getY();
if (deltaY > 0 && deltaY < 0.42 && deltaY < verticalVelocity * 0.77) {
long velocity = Math.round(100.0 * deltaY / verticalVelocity);
verticalVelocity = 0;
onViolation(String.format("Velocity Type A (%d%%)", velocity), 10000L, 4);
}
}
@Override
public void onPacketSend(Class<? extends Packet> type, Packet packet) {
if (type == PacketPlayOutEntityVelocity.class) {
PacketPlayOutEntityVelocity entityVelocity = (PacketPlayOutEntityVelocity) packet;
int entityId = ReflectionUtil.getFieldValue(ReflectionUtil.getField(PacketPlayOutEntityVelocity.class, "a", int.class), entityVelocity);
if (entityId == player.getBukkitPlayer().getEntityId()) {
if (player.getBukkitPlayer().getLastDamageCause() != null) {
switch (player.getBukkitPlayer().getLastDamageCause().getCause()) {
case STARVATION:
case FIRE_TICK:
case DROWNING:
case POISON:
case WITHER:
case THORNS:
case FALL:
case LAVA:
case FIRE:
verticalVelocity = 0;
return;
}
}
verticalVelocity = (int) ReflectionUtil.getFieldValue(ReflectionUtil.getField(PacketPlayOutEntityVelocity.class, "c", int.class), entityVelocity) / 8000.0;
}
}
}
}
// NOTE (AI): Reflection-based field access is used instead of a wrapper, typical of the 1.8 generation.Records every player-targeted S12 into a short-lived velocity window that all movement checks read for exemptions and baselines.
The outgoing packet processor wraps each entity-velocity packet, and when the entity id is the player, pushes the vector into the VelocityManager. The manager keeps snapshots with horizontal and vertical magnitudes for two seconds, exposing max values that the speed and invalid checks add to their expected baselines, and the VELOCITY exemption type switches off checks while a recent velocity is active.
// ===== FILE: ElevatedDev-Frequency, src/main/java/xyz/elevated/frequency/processor/impl/OutgoingPacketProcessor.java =====
package xyz.elevated.frequency.processor.impl;
import net.minecraft.server.v1_8_R3.*;
import xyz.elevated.frequency.data.PlayerData;
import xyz.elevated.frequency.processor.type.Processor;
import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutKeepAlive;
import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutEntityVelocity;
import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutTeleport;
import xyz.elevated.frequency.wrapper.impl.server.WrappedPlayOutTransaction;
public final class OutgoingPacketProcessor implements Processor<Packet<PacketListenerPlayOut>> {
@Override
public void process(final PlayerData playerData, final Packet<PacketListenerPlayOut> packet) {
if (packet instanceof PacketPlayOutEntityVelocity) {
final WrappedPlayOutEntityVelocity wrapper = new WrappedPlayOutEntityVelocity(packet);
final int packetEntityId = wrapper.getEntityId();
final int playerEntityId = playerData.getBukkitPlayer().getEntityId();
if (packetEntityId == playerEntityId) {
final double velocityX = wrapper.getX();
final double velocityY = wrapper.getY();
final double velocityZ = wrapper.getZ();
playerData.getVelocityManager().addVelocityEntry(velocityX, velocityY, velocityZ);
}
} else if (packet instanceof PacketPlayOutEntityTeleport) {
final WrappedPlayOutTeleport wrapper = new WrappedPlayOutTeleport(packet);
final int entityId = wrapper.getEntityId();
final int playerId = playerData.getBukkitPlayer().getEntityId();
if (entityId == playerId) {
playerData.getActionManager().onTeleport();
}
} else if (packet instanceof PacketPlayOutPosition) {
playerData.getActionManager().onTeleport();
}
}
}
// NOTE (AI): The processor also feeds teleport events (entity teleport and position packets) into the action manager, keeping velocity and teleport exemptions in one stream.Applies the S12 velocity to the movement holder only after the client confirms the packet, so prediction checks see it in the correct tick.
Matches the OUT entity-velocity packet for the player's entity id, builds a Velocity object, and registers it in the connection's transaction confirmation. The pre action moves the current velocity into lastVelocity and installs the new vector as processed; the post action clears the processed flag when the transaction returns.
// ===== FILE: artemisac-artemis-minecraft-anticheat, ac.artemis.core/src/main/java/ac/artemis/core/v4/processor/velocity/VelocityPreProcessor.java =====
package ac.artemis.core.v4.processor.velocity;
import ac.artemis.core.v4.check.TeleportHandler;
import ac.artemis.core.v4.check.VelocityHandler;
import ac.artemis.core.v4.data.PlayerData;
import ac.artemis.core.v4.data.holders.ConnectionHolder;
import ac.artemis.core.v4.processor.AbstractHandler;
import ac.artemis.core.v4.utils.chat.Chat;
import ac.artemis.core.v4.utils.function.PacketAction;
import cc.ghast.packet.PacketAPI;
import ac.artemis.packet.spigot.wrappers.GPacket;
import cc.ghast.packet.wrapper.packet.play.client.GPacketPlayClientTransaction;
import ac.artemis.core.v4.utils.position.Velocity;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerEntityVelocity;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerTransaction;
import java.util.*;
public class VelocityPreProcessor extends AbstractHandler {
public VelocityPreProcessor(final PlayerData data) {
super("Velocity [0x01]", data);
}
@Override
public void handle(final GPacket packet) {
// If the packet is a velocity packet
if (packet instanceof GPacketPlayServerEntityVelocity) {
// Assign the packet
final GPacketPlayServerEntityVelocity vel = (GPacketPlayServerEntityVelocity) packet;
// Ensure the packet's entity id corresponds to the player's
if (vel.getEntityId() == data.getPlayer().getEntityId()) {
// Create a new velocity object
final Velocity velocity = new Velocity(vel.getValueX(), vel.getValueY(), vel.getZ());
data.connection.confirmFunction(ConnectionHolder.ConfirmationType.TRANSACTION, new PacketAction() {
@Override
public void pre() {
// If the previous velocity isn't null, assign it to this variable
if (data.movement.getVelocity() != null) data.movement.setLastVelocity(data.movement.getVelocity());
// Assign the velocity
data.movement.setVelocity(velocity);
// Set the boolean as processed
data.movement.setProcessedVelocity(true);
}
@Override
public void post() {
data.movement.setProcessedVelocity(false);
}
});
}
}
}
}
// NOTE (AI): Keeping lastVelocity lets checks distinguish a fresh knockback from a stale one across the confirm boundary.Related Packets
Wiki Cross-Reference
PLAY id 0x12: VarInt entityId plus three signed shorts; real motion equals encoded value / 8000.0, clamped near +-3.9.
Handler writes motionX/Y/Z directly with no interpolation, so cancel-or-scale hooks are the standard anti-knockback point.
MCP 1.8.9 S12PacketEntityVelocity implements Packet
1.8.9 callers: EntityTrackerEntry.? sends new S12PacketEntityVelocity (line 238) +1 more: https://github.com/Marcelektro/MavenMCP-1.8.9/blob/master/src/main/java/net/minecraft/entity/EntityTrackerEntry.java
Cross-checked against minecraft.wiki (CC BY-SA 3.0) for 1.8.9 accuracy.
Vanilla Internals
Full 1.8.9 logic-class sources that send or handle this packet, stored verbatim.
Module Analyses Using S12PacketEntityVelocity
Full source walkthroughs of the modules and anti-cheats that use this packet.