0x12 S12PacketEntityVelocity
Sets an entity's velocity (e.g., from knockback, explosion, piston push).
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
MCP
NetHandlerPlayClient.handleEntityVelocity()Handler Interface
HND
INetHandlerPlayClientNotes
Velocities are encoded as (value * 8000). Real velocity = encoded / 8000.
implementation Implementation Cases
Velocity
(Tenacity 5.1, Sigma 3.9, Raze v1.5b, Gugustus, November 0.2, Nekoware v1, Memeware 7.3, Jigsaw 0.24, Helium B41420)
Cancel or scale velocity. Most common anti-knockback implementation. Cancel entirely (100% antiKB) or scale motionX/Y/Z by percentage. Backtrack buffers S12 for delayed processing.
// Cancel
if (event.getPacket() instanceof S12PacketEntityVelocity) {
S12PacketEntityVelocity s12 = (S12PacketEntityVelocity) event.getPacket();
if (s12.getEntityID() == mc.thePlayer.getEntityId()) event.setCancelled(true);
}
// Scale
if (s12.getEntityID() == mc.thePlayer.getEntityId()) {
s12.motionX *= horizontal / 100.0;
s12.motionY *= vertical / 100.0;
s12.motionZ *= horizontal / 100.0;
}AntiKnockback
(Tenacity 5.1, Sigma 3.9, Raze v1.5b, Gugustus, November 0.2, Nekoware v1, Memeware 7.3, Jigsaw 0.24, Helium B41420)
Cancel or scale velocity. Most common anti-knockback implementation. Cancel entirely (100% antiKB) or scale motionX/Y/Z by percentage. Backtrack buffers S12 for delayed processing.
// Cancel
if (event.getPacket() instanceof S12PacketEntityVelocity) {
S12PacketEntityVelocity s12 = (S12PacketEntityVelocity) event.getPacket();
if (s12.getEntityID() == mc.thePlayer.getEntityId()) event.setCancelled(true);
}
// Scale
if (s12.getEntityID() == mc.thePlayer.getEntityId()) {
s12.motionX *= horizontal / 100.0;
s12.motionY *= vertical / 100.0;
s12.motionZ *= horizontal / 100.0;
}Backtrack
(Tenacity 5.1, Sigma 3.9, Raze v1.5b, Gugustus, November 0.2, Nekoware v1, Memeware 7.3, Jigsaw 0.24, Helium B41420)
Cancel or scale velocity. Most common anti-knockback implementation. Cancel entirely (100% antiKB) or scale motionX/Y/Z by percentage. Backtrack buffers S12 for delayed processing.
// Cancel
if (event.getPacket() instanceof S12PacketEntityVelocity) {
S12PacketEntityVelocity s12 = (S12PacketEntityVelocity) event.getPacket();
if (s12.getEntityID() == mc.thePlayer.getEntityId()) event.setCancelled(true);
}
// Scale
if (s12.getEntityID() == mc.thePlayer.getEntityId()) {
s12.motionX *= horizontal / 100.0;
s12.motionY *= vertical / 100.0;
s12.motionZ *= horizontal / 100.0;
}