0x18 S18PacketEntityTeleport
Teleports an entity to an absolute position (fixed-point int × 32) and rotation.
Published 2026-06-18 · Updated 2026-10-14
Fields
| Field | Type | Description |
|---|---|---|
| entityId | VarInt | Entity ID |
| x/y/z | fixed-point int | Absolute position × 32 |
| yaw/pitch | byte | Rotation × 256/360 |
| onGround | boolean | Whether the entity is on ground |
Wire Encoding
| Field | Type | Notes |
|---|---|---|
| Entity ID | VarInt | |
| X | Int | x * 32 |
| Y | Int | y * 32 |
| Z | Int | z * 32 |
| Yaw | byte | yaw * 256/360 |
| Pitch | byte | pitch * 256/360 |
| On Ground | bool |
MCP References
NetHandlerPlayClient.handleEntityTeleport()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 | |
| 115 | |
| 116 | |
Deobfuscated MCP 1.8.9 source of S18PacketEntityTeleport, fetched directly from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S18PacketEntityTeleport.java) at build time and verified present.
Deep Dive
Role in the protocol
S18PacketEntityTeleport carries an absolute fixed-point position (ints x 32), rotation bytes and an onGround flag for one entity. It is the only entity-position packet with full coordinates, so it is both the correction mechanism for accumulated S14 error and the transport for genuine jumps: ender pearls, endermen, dimension changes and anything that moves more than 4 blocks in one tick. EntityTrackerEntry constructs it when the tracked entity's one-tick displacement exceeds the relative-move threshold (corpus line 222), and NetHandlerPlayServer sends it to a player on teleport (line 259).
Vanilla handling
NetHandlerPlayClient.handleEntityTeleport (Memeware 7.3 bundle, line 511) overwrites serverPosX/Y/Z with the absolute values, computes position as serverPos / 32.0 with y + 0.015625 (half a block in fixed point, the eye-height accommodation), decodes yaw/pitch as * 360 / 256, and calls setPositionAndRotation2 with interpolation 3 and the teleport flag. If the entity is already within 0.03125 blocks (x/z) and 0.015625 (y) of the target it keeps the current position and applies only rotation, which prevents micro-jitter on repeated teleports.
Why clients touch it
Five distinct consumers in the corpus. Rise 6.x: LegitReach snaps its realPosition to the absolute coordinates, WatchdogVelocity includes S18 in its spoof packet set and re-anchors on it, and PingSpoofComponent classifies it in the players tuple so teleports are delayed with the rest of the entity stream. Rise 5.99: PlayerData re-anchors serverPosX/Y/Z and zeroes ticksSinceLastTeleport so checks skip the teleport tick. Sigma 4.11: Ranking treats S18 as an entity-removal signal that finalizes kill/death records. Tenacity 6.0: AntiExploit cancels S18 with any coordinate beyond 30,000,000. Spicy: NoClip and Phase import the class but never branch on it, a leftover from their Sigma 2 lineage.
Exploit surface
S18 is clientbound and absolute, so the abuse direction is server to client: a malicious server can emit fixed-point coordinates that corrupt client-side position bookkeeping or trigger bounds bugs, which is exactly what Tenacity's AntiExploit threshold mitigates. For cheats, S18 is the epoch boundary of every position-based state machine: accumulated S14 error resets here, so reach and backtrack modules must re-anchor their reconstructed positions on it. The S08PacketPlayerPosLook + S18 pair is the server's complete teleport vocabulary, and disablers and reach modules watch both because a missed teleport poisons every later delta.
Server-Side Handling
The server side only emits S18, never validates it on receive. EntityTrackerEntry chooses it when the tracked entity moved 4+ blocks in a tick, and NetHandlerPlayServer sends it to a player being teleported. The client handler overwrites the entity's serverPosX/Y/Z, applies the +0.015625 y offset, keeps the current position when the entity is already within a 32nd of a block (rotation-only update), then interpolates with the teleport flag set. Because the client trusts the coordinates, a server can move an entity anywhere in the fixed-point range, which is the abuse AntiExploit guards against.
Protocol Analysis
Three ints (x 32), two bytes (x 256/360) and a boolean follow the VarInt entityId. The y offset of 0.015625 (0.5 / 32) is applied only on the client and is not part of the wire value. S18 supersedes any pending S14 deltas for the same entity because it overwrites the accumulated serverPosX/Y/Z. The packet is also sent to a player on respawn and dimension change, which is why Ranking's S08 + S18 combination distinguishes death from mere teleport.
Anti-Cheat Landscape
Server anticheats emit S18 as a correction and watch whether the client's later C03 positions rejoin the corrected location; a client that ignores the teleport or desyncs after it flags as position desync. The S08+S18 pair is the standard disabler/reach watch point: modules that delay clientbound traffic must flush on it or their position cache goes permanently stale. The client-side mirror (Rise 5.99 PlayerData) uses ticksSinceLastTeleport to suppress checks for a tick, an acknowledgment that even legitimate teleports produce movement anomalies.
implementation Implementation Cases
The absolute teleport packet is the reset point of entity position state. Cheat clients re-anchor their reconstructed position caches on it (LegitReach, WatchdogVelocity, Rise 5.99 anticheat), Sigma uses it as an entity-left signal, Tenacity hardens against server-side coordinate abuse, and Spicy's movement modules carry it as a dead import.
Re-anchor the tracked target's server-truth position on the absolute teleport so the ping-spoof reach window keeps measuring the real distance.
In the same PacketReceiveEvent handler that accumulates S14 deltas, an S18 for the tracked target replaces realPosition with new Vec3(getX() / 32D, getY() / 32D, getZ() / 32D). Without this branch, a teleported target would leave the accumulated position permanently wrong and the reach window would either never open or stay open against a ghost position.
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/combat/LegitReach.java =====
package com.alan.clients.module.impl.combat;
import com.alan.clients.component.impl.player.PingSpoofComponent;
import com.alan.clients.component.impl.player.TargetComponent;
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.packet.PacketReceiveEvent;
import com.alan.clients.event.impl.render.Render3DEvent;
import com.alan.clients.module.Module;
import com.alan.clients.module.api.Category;
import com.alan.clients.module.api.ModuleInfo;
import com.alan.clients.util.animation.Animation;
import com.alan.clients.util.animation.Easing;
import com.alan.clients.util.render.ColorUtil;
import com.alan.clients.util.render.RenderUtil;
import com.alan.clients.value.impl.BooleanValue;
import com.alan.clients.value.impl.NumberValue;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S14PacketEntity;
import net.minecraft.network.play.server.S18PacketEntityTeleport;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
import java.util.List;
@ModuleInfo(aliases = {"module.combat.legitreach.name", "Back Track"}, description = "module.combat.legitreach.description", category = Category.COMBAT)
public final class LegitReach extends Module {
public NumberValue maxPingSpoof = new NumberValue("Max Ping Spoof", this, 1000, 50, 10000, 1);
public BooleanValue render = new BooleanValue("Render Real Location", this, true);
private Vec3 realPosition = new Vec3(0, 0, 0);
private final Animation animatedX = new Animation(Easing.LINEAR, 50);
private final Animation animatedY = new Animation(Easing.LINEAR, 50);
private final Animation animatedZ = new Animation(Easing.LINEAR, 50);
public Entity targetEntity;
public boolean isActive;
@EventLink()
public final Listener<PostMotionEvent> onPost = event -> {
// Getting targets and selecting the nearest one
List<EntityLivingBase> targets = TargetComponent.getTargets(9);
if (targets.isEmpty()) {
isActive = true;
targetEntity = null;
return;
}
Entity entity = targets.get(0);
if (entity != targetEntity) {
targetEntity = entity;
realPosition.xCoord = entity.posX;
realPosition.yCoord = entity.posY;
realPosition.zCoord = entity.posZ;
}
if (targetEntity == null || !(mc.thePlayer.isSwingInProgress || getModule(KillAura.class).isEnabled())) {
return;
}
double realDistance = realPosition.distanceTo(mc.thePlayer);
double clientDistance = targetEntity.getDistanceToEntity(mc.thePlayer);
boolean on = realDistance > clientDistance && realDistance > 2.3 && realDistance < 5.9;
if (on) {
PingSpoofComponent.spoof(maxPingSpoof.getValue().intValue(), true, true, true, true);
} else {
PingSpoofComponent.disable();
PingSpoofComponent.dispatch();
}
};
@EventLink()
public final Listener<PacketReceiveEvent> onPacketReceiveEvent = event -> {
final Packet<?> packet = event.getPacket();
if (targetEntity == null) {
return;
}
if (packet instanceof S14PacketEntity) {
S14PacketEntity s14PacketEntity = ((S14PacketEntity) packet);
if (s14PacketEntity.entityId == targetEntity.getEntityId()) {
realPosition.xCoord += s14PacketEntity.getPosX() / 32D;
realPosition.yCoord += s14PacketEntity.getPosY() / 32D;
realPosition.zCoord += s14PacketEntity.getPosZ() / 32D;
}
} else if (packet instanceof S18PacketEntityTeleport) {
S18PacketEntityTeleport s18PacketEntityTeleport = ((S18PacketEntityTeleport) packet);
if (s18PacketEntityTeleport.getEntityId() == targetEntity.getEntityId()) {
realPosition = new Vec3(s18PacketEntityTeleport.getX() / 32D, s18PacketEntityTeleport.getY() / 32D, s18PacketEntityTeleport.getZ() / 32D);
}
}
};
@EventLink()
public final Listener<Render3DEvent> onRender3D = event -> {
if (targetEntity == null || !render.getValue()) {
return;
}
animatedX.setDuration(150);
animatedY.setDuration(150);
animatedZ.setDuration(150);
animatedX.run(realPosition.xCoord);
animatedY.run(realPosition.yCoord);
animatedZ.run(realPosition.zCoord);
GlStateManager.pushMatrix();
GlStateManager.pushAttrib();
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GL11.glDepthMask(false);
double expand = 0.14;
RenderUtil.color(ColorUtil.withAlpha(getTheme().getFirstColor(), 50));
RenderUtil.drawBoundingBox(mc.thePlayer.getEntityBoundingBox().offset(-mc.thePlayer.posX, -mc.thePlayer.posY, -mc.thePlayer.posZ).
offset(animatedX.getValue(), animatedY.getValue(), animatedZ.getValue()).expand(expand, expand, expand));
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GL11.glDepthMask(true);
GlStateManager.popAttrib();
GlStateManager.popMatrix();
GlStateManager.resetColor();
};
}
// NOTE (AI): realPosition is the server-truth position of the target, rebuilt from S14 deltas and S18
// NOTE (AI): absolutes while the renderer entity interpolates normally. The reach window opens when the
// NOTE (AI): real distance exceeds the client distance inside 2.3-5.9 blocks; PingSpoofComponent.spoof
// NOTE (AI): then delays all incoming player-class packets for up to maxPingSpoof ms, which keeps the
// NOTE (AI): server-side player position stale while the client hits from the closer interpolated spot.
Track kills and deaths for the client's stats system; an S18 teleport for a tracked player finalizes the pending record because a teleporting opponent is out of reach context.
A hidden, always-on module registered for EventAttack, EventPacket and EventUpdate. On EventAttack it records HitEntity entries per player; S0B animations timestamp attacker candidates; on S18 it calls onEntityRemoved(entityId), which flips the HitEntity to removed and reports killed() or prosecuted() if a chat message already matched the name in the last 3 seconds. S08PacketPlayerPosLook resets all prosecutor records (death/respawn), S13 destroys remove entities, S40 with 'ban' in the text reports a ban stat.
// ===== FILE: Sigma 4.11, info/sigmaclient/module/impl/other/Ranking.java =====
package info.sigmaclient.module.impl.other;
import info.sigmaclient.Client;
import info.sigmaclient.event.Event;
import info.sigmaclient.event.RegisterEvent;
import info.sigmaclient.event.impl.EventAttack;
import info.sigmaclient.event.impl.EventPacket;
import info.sigmaclient.event.impl.EventUpdate;
import info.sigmaclient.management.users.TTSystem;
import info.sigmaclient.module.Module;
import info.sigmaclient.module.data.ModuleData;
import info.sigmaclient.util.Timer;
import info.sigmaclient.util.misc.ChatUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.*;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
public class Ranking extends Module {
private HashMap<Integer, HitEntity> hitEntities = new HashMap<>();
private HashMap<Integer, HitEntity> prosecutorEntities = new HashMap<>();
private HashMap<Integer, Long> lastAnimationTimestamp = new HashMap<>();
private info.sigmaclient.util.Timer delay = new Timer();
public Ranking(ModuleData data) {
super(data);
setHidden(true);
if (!isEnabled()) {
toggle();
}
}
@Override
@RegisterEvent(events = {EventAttack.class, EventPacket.class, EventUpdate.class})
public void onEvent(Event e) {
if (e instanceof EventAttack) {
EventAttack ea = (EventAttack) e;
if (ea.getEntity() instanceof EntityPlayer) {
EntityPlayer ep = (EntityPlayer) ea.getEntity();
if (!ep.getName().isEmpty()) {
if (!hitEntities.containsKey(ep.getEntityId())) {
hitEntities.put(ep.getEntityId(), new HitEntity(ep));
} else {
hitEntities.get(ep.getEntityId()).refresh();
}
}
}
} else if (e instanceof EventPacket) {
EventPacket ep = (EventPacket) e;
Packet packet = ep.getPacket();
if (packet instanceof S0BPacketAnimation) {
S0BPacketAnimation packetAnimation = (S0BPacketAnimation) packet;
lastAnimationTimestamp.put(packetAnimation.func_148978_c(), System.currentTimeMillis());
}
if (packet instanceof S06PacketUpdateHealth) {
S06PacketUpdateHealth packetUpdateHealth = (S06PacketUpdateHealth) packet;
if (packetUpdateHealth.getHealth() <= Minecraft.getMinecraft().thePlayer.getHealth()) {
try{
for (Object o : mc.theWorld.getLoadedEntityList()) {
if (o instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer) o;
if (!(entityPlayer instanceof EntityPlayerSP) && lastAnimationTimestamp.containsKey(entityPlayer.getEntityId())) {
if (lastAnimationTimestamp.get(entityPlayer.getEntityId()) > System.currentTimeMillis() - 70 && entityPlayer.getPositionVector().squareDistanceTo(Minecraft.getMinecraft().thePlayer.getPositionVector()) < 9 * 9) {
if (!prosecutorEntities.containsKey(entityPlayer.getEntityId())) {
prosecutorEntities.put(entityPlayer.getEntityId(), new HitEntity(entityPlayer, true));
} else {
prosecutorEntities.get(entityPlayer.getEntityId()).refresh();
}
}
}
}
}
}catch(ConcurrentModificationException ee){};
}
if (packetUpdateHealth.getHealth() <= 0) {
onDeath();
}
}
if (packet instanceof S02PacketChat) {
S02PacketChat packetChat = (S02PacketChat) packet;
String message = packetChat.func_148915_c().getUnformattedText();
Iterator it = hitEntities.entrySet().iterator();
while (it.hasNext()) {
HitEntity hitEntity = ((Map.Entry<Integer, HitEntity>) it.next()).getValue();
if (hitEntity.getTime() > System.currentTimeMillis() - 3000 && message.contains(hitEntity.getName())) {
if (hitEntity.onChatMessage()) {
it.remove();
}
}
}
Iterator it2 = prosecutorEntities.entrySet().iterator();
while (it2.hasNext()) {
HitEntity hitEntity = ((Map.Entry<Integer, HitEntity>) it2.next()).getValue();
if (hitEntity.getTime() > System.currentTimeMillis() - 3000 && message.contains(hitEntity.getName()) && message.contains(Minecraft.getMinecraft().thePlayer.getName())) {
if (hitEntity.onChatMessage()) {
it2.remove();
}
}
}
} else if (packet instanceof S18PacketEntityTeleport) {
S18PacketEntityTeleport packetTeleport = (S18PacketEntityTeleport) packet;
int entityId = packetTeleport.func_149451_c();
onEntityRemoved(entityId);
} else if (packet instanceof S08PacketPlayerPosLook) {
onDeath();
} else if (packet instanceof S13PacketDestroyEntities) {
S13PacketDestroyEntities packetDestroyEntities = (S13PacketDestroyEntities) packet;
for (int entityId : packetDestroyEntities.func_149098_c()) {
onEntityRemoved(entityId);
}
} else if (packet instanceof S40PacketDisconnect) {
S40PacketDisconnect packetDisconnect = (S40PacketDisconnect) packet;
if (packetDisconnect.func_149165_c().getUnformattedText().toLowerCase().contains("ban") && Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().thePlayer.ticksExisted > 15 * 20) {
sendStat("ban", "");
}
}
} else if (e instanceof EventUpdate) {
if (delay.delay(1000 * 60 * 10)) {
delay.reset();
sendStat("tick", "");
}
}
}
private void onDeath() {
Iterator it2 = prosecutorEntities.entrySet().iterator();
while (it2.hasNext()) {
HitEntity hitEntity = ((Map.Entry<Integer, HitEntity>) it2.next()).getValue();
if (hitEntity.getTime() > System.currentTimeMillis() - 3000) {
if (hitEntity.onRemoved()) {
it2.remove();
}
}
}
}
private void onEntityRemoved(int entityId) {
Iterator it = hitEntities.entrySet().iterator();
while (it.hasNext()) {
HitEntity hitEntity = ((Map.Entry<Integer, HitEntity>) it.next()).getValue();
if (hitEntity.getTime() > System.currentTimeMillis() - 3000 && entityId == hitEntity.getEntityId()) {
if (hitEntity.onRemoved()) {
it.remove();
}
}
}
}
public void sendStat(String type, String data) {
}
private class HitEntity {
private long time = System.currentTimeMillis();
private UUID uuid;
private String name;
private int entityId;
private boolean removed = false;
private boolean chatMessage = false;
private boolean prosecutor = false;
public HitEntity(EntityPlayer ep) {
uuid = ep.getUniqueID();
name = ep.getName();
entityId = ep.getEntityId();
}
public HitEntity(EntityPlayer ep, boolean prosecutor) {
uuid = ep.getUniqueID();
name = ep.getName();
entityId = ep.getEntityId();
this.prosecutor = prosecutor;
}
public boolean onRemoved() {
removed = true;
if (chatMessage) {
if (prosecutor) {
prosecuted();
} else {
killed();
}
return true;
}
return false;
}
public boolean onChatMessage() {
chatMessage = true;
if (removed) {
if (prosecutor) {
prosecuted();
} else {
killed();
}
return true;
}
return false;
}
private void killed() {
//ChatUtil.printChat("Kill (" + name + ") " + uuid.toString());
sendStat("kill", "&uuid=" + uuid.toString().replaceAll("-", ""));
}
public void refresh() {
time = System.currentTimeMillis();
}
public String getName() {
return name;
}
public long getTime() {
return time;
}
public int getEntityId() {
return entityId;
}
public void prosecuted() {
//ChatUtil.printChat("Prosecuted (" + name + ") " + uuid.toString());
sendStat("death", "&uuid=" + uuid.toString().replaceAll("-", ""));
}
}
}
// NOTE (AI): S18PacketEntityTeleport is treated as an entity-removal signal: a player that teleports is
// NOTE (AI): out of reach context, so the pending HitEntity record is finalized (killed or prosecuted)
// NOTE (AI): if a matching chat kill message arrived in the last 3 seconds. S08PacketPlayerPosLook resets
// NOTE (AI): prosecutor records on death/respawn, S13 destroys remove entities outright.
Corpus hit is an import only: both movement modules import S18PacketEntityTeleport but never branch on it.
NoClip's onEvent sends C03PacketPlayer.C04PacketPlayerPosition through sendPacketNoEvent when collided horizontally, then teleports the local player by 3 blocks up to break free; Phase cancels block hitboxes (EventGetBlockHitbox) and nudges the player position in a 3-stage loop while sending C03PacketPlayer(true). NoClip's header comment credits Sigma 2's Phase as the source, which explains the vestigial S18 import in both files.
// ===== FILE: Spicy, info/spicyclient/modules/movement/NoClip.java =====
package info.spicyclient.modules.movement;
import org.lwjgl.input.Keyboard;
import info.spicyclient.events.Event;
import info.spicyclient.events.listeners.EventGetBlockHitbox;
import info.spicyclient.events.listeners.EventMotion;
import info.spicyclient.events.listeners.EventPacket;
import info.spicyclient.events.listeners.EventUpdate;
import info.spicyclient.modules.Module;
import info.spicyclient.modules.Module.Category;
import info.spicyclient.util.MovementUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockHopper;
import net.minecraft.network.play.client.C03PacketPlayer;
import net.minecraft.network.play.client.C13PacketPlayerAbilities;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.network.play.server.S18PacketEntityTeleport;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MathHelper;
public class NoClip extends Module {
/*
*
* NOTICE: This module's code is taken from the sigma 2 code
* here is the link to that https://gitlab.com/Arithmo/Sigma/-/blob/master/info/sigmaclient/module/impl/movement/Phase.java
*
*/
public NoClip() {
super("NoClip", Keyboard.KEY_NONE, Category.BETA);
}
public void onEnable() {
mc.thePlayer.setPosition(mc.thePlayer.posX, mc.thePlayer.posY + 0.0784001, mc.thePlayer.posZ);
}
public void onDisable() {
}
public void onEvent(Event e) {
if (e instanceof EventMotion && e.isPre()) {
double mx = Math.cos(Math.toRadians((double)(mc.thePlayer.rotationYaw + 90.0F)));
double mz = Math.sin(Math.toRadians((double)(mc.thePlayer.rotationYaw + 90.0F)));
double x = (double)mc.thePlayer.movementInput.moveForward * 0.4 * mx + (double)mc.thePlayer.movementInput.moveStrafe * 0.4 * mz;
double z = (double)mc.thePlayer.movementInput.moveForward * 0.4 * mz - (double)mc.thePlayer.movementInput.moveStrafe * 0.4 * mx;
if (mc.thePlayer.isCollidedHorizontally && !mc.thePlayer.isOnLadder()) {
mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX + x, mc.thePlayer.posY, mc.thePlayer.posZ + z, false));
mc.getNetHandler().getNetworkManager().sendPacketNoEvent(new C03PacketPlayer.C04PacketPlayerPosition(mc.thePlayer.posX, mc.thePlayer.posY + 3.0D, mc.thePlayer.posZ, false));
mc.thePlayer.setPosition(mc.thePlayer.posX + x, mc.thePlayer.posY, mc.thePlayer.posZ + z);
}
}
}
private boolean isInsideBlock() {
for (int x = MathHelper.floor_double(mc.thePlayer.boundingBox.minX); x < MathHelper.floor_double(mc.thePlayer.boundingBox.maxX) + 1; x++) {
for (int y = MathHelper.floor_double(mc.thePlayer.boundingBox.minY); y < MathHelper.floor_double(mc.thePlayer.boundingBox.maxY) + 1; y++) {
for (int z = MathHelper.floor_double(mc.thePlayer.boundingBox.minZ); z < MathHelper.floor_double(mc.thePlayer.boundingBox.maxZ) + 1; z++) {
Block block = mc.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock();
if ((block != null) && (!(block instanceof BlockAir))) {
AxisAlignedBB boundingBox = block.getCollisionBoundingBox(mc.theWorld, new BlockPos(x, y, z), mc.theWorld.getBlockState(new BlockPos(x, y, z)));
if ((block instanceof BlockHopper)) {
boundingBox = new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
}
if (boundingBox != null) {
if (mc.thePlayer.boundingBox.intersectsWith(boundingBox)) {
return true;
}
}
}
}
}
}
return false;
}
}
// NOTE (AI): The S18PacketEntityTeleport import is dead code: the shipped handlers never branch on the
// NOTE (AI): packet. The header comment credits Sigma 2's Phase as the source of this module, which
// NOTE (AI): explains the leftover import. The actual phase movement is driven by C03PacketPlayer
// NOTE (AI): positions sent through sendPacketNoEvent while collided horizontally.
Harden the client against server-side crash and grief exploits; the S18 branch blocks teleport coordinates beyond the world border.
On PacketReceiveEvent, an S18 with any |getX()/getY()/getZ()| above 30,000,000 is cancelled and logged as 'Blocked Exploit: Teleport'. The same handler validates S48 resource pack URIs (http/https/level only, no path traversal), blocks S43 camera outside spectator, rejects particle floods, rate-limits S27 explosions and S11 experience orbs to 1 per millisecond, and caps total incoming packets at 100/second.
// ===== FILE: Tenacity 6.0, dev/tenacity/module/impl/misc/AntiExploit.java =====
package dev.tenacity.module.impl.misc;
import dev.tenacity.event.IEventListener;
import dev.tenacity.event.impl.packet.PacketReceiveEvent;
import dev.tenacity.module.Module;
import dev.tenacity.module.ModuleCategory;
import dev.tenacity.util.misc.ChatUtil;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C19PacketResourcePackStatus;
import net.minecraft.network.play.server.*;
import java.net.URI;
import java.net.URISyntaxException;
public class AntiExploit extends Module {
private long lastExplosion = 0, lastExperience = 0;
private int invalidExperience = 0;
final int PACKET_THRESHOLD = 100;
final long CHECK_INTERVAL = 1000;
int packetCount = 0;
public AntiExploit() {
super("AntiExploit", "Prevents server exploits", ModuleCategory.MISC);
}
private final IEventListener<PacketReceiveEvent> onReceivePacket = event -> {
Packet<?> packet = event.getPacket();
handlePacketCount();
if(packet instanceof S48PacketResourcePackSend) {
S48PacketResourcePackSend resourcePack = (S48PacketResourcePackSend) packet;
try {
URI uri = new URI(resourcePack.getURL());
String scheme = uri.getScheme();
boolean isLevelProtocol = scheme.equalsIgnoreCase("level");
boolean isHttpProtocol = scheme.equalsIgnoreCase("http");
boolean isHttpsProtocol = scheme.equalsIgnoreCase("https");
if(!isHttpProtocol && !isHttpsProtocol && !isLevelProtocol) {
ChatUtil.print("§cBlocked Exploit: Resource Pack");
event.cancel();
} else if(isLevelProtocol && (resourcePack.getURL().contains("..") || !((S48PacketResourcePackSend) packet).getURL().endsWith("/resources.zip"))) {
ChatUtil.print("§cBlocked Exploit: File Access");
event.cancel();
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(((S48PacketResourcePackSend) packet).getHash(), C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
}
} catch (URISyntaxException exception) {
ChatUtil.print("§cBlocked Exploit: Resource Pack");
event.cancel();
mc.getNetHandler().addToSendQueue(new C19PacketResourcePackStatus(((S48PacketResourcePackSend) packet).getHash(), C19PacketResourcePackStatus.Action.FAILED_DOWNLOAD));
}
} else if(packet instanceof S43PacketCamera && !mc.thePlayer.isSpectator()) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
} else if(packet instanceof S2APacketParticles) {
S2APacketParticles particles = (S2APacketParticles) packet;
if(Math.abs(particles.getParticleSpeed()) >= 1) {
ChatUtil.print("§cBlocked Exploit: Particles");
event.cancel();
} else if(((S2APacketParticles) packet).getParticleCount() > 1) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
}
} else if(packet instanceof S27PacketExplosion) {
S27PacketExplosion explosion = (S27PacketExplosion) packet;
if(Math.abs(explosion.getStrength()) > 1) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
} else if(System.currentTimeMillis() - lastExplosion <= 1) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
} else if(packet instanceof S2APacketParticles) {
S2APacketParticles particles = (S2APacketParticles) packet;
if(Math.abs(particles.getParticleSpeed()) > 1) {
ChatUtil.print("§cBlocked Exploit: Particles");
event.cancel();
} else if(particles.getParticleCount() >= 1) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
}
}
lastExplosion = System.currentTimeMillis();
} else if(packet instanceof S18PacketEntityTeleport) {
S18PacketEntityTeleport teleport = (S18PacketEntityTeleport) packet;
double packetX = Math.abs(teleport.getX());
double packetY = Math.abs(teleport.getY());
double packetZ = Math.abs(teleport.getZ());
if(packetX > 30000000 || packetY > 30000000 || packetZ > 30000000) {
ChatUtil.print("§cBlocked Exploit: Teleport");
event.cancel();
}
} else if(packet instanceof S11PacketSpawnExperienceOrb) {
if(System.currentTimeMillis() - lastExperience <= 1) {
invalidExperience++;
if(invalidExperience >= 2) {
ChatUtil.print("§cBlocked Exploit: Crash");
event.cancel();
}
} else {
invalidExperience = 0;
}
lastExperience = System.currentTimeMillis();
}
};
private void triggerKick() {
ChatUtil.print("§cAbnormal packet activity detected. Kicking player...");
}
private void handlePacketCount() {
long currentTime = System.currentTimeMillis();
long lastPacketCheckTime = 0;
if (currentTime - lastPacketCheckTime > CHECK_INTERVAL) {
packetCount = 0;
lastPacketCheckTime = currentTime;
}
packetCount++;
if (packetCount > PACKET_THRESHOLD) {
triggerKick();
packetCount = 0;
}
}
}
// NOTE (AI): The S18 branch sanity-checks the absolute fixed-point coordinates and cancels the packet
// NOTE (AI): when any |coordinate| exceeds 30,000,000, the vanilla world border. The same handler blocks
// NOTE (AI): non-http resource pack URIs (level:// traversal), S43 camera outside spectator, particle
// NOTE (AI): floods, S27 explosion spam and S11 experience orb spam, plus a 100 packets/second cap.
Include the teleport in the backtrack packet set and use it to re-anchor the tracked target's realPosition.
isSpoof2Packet returns true for S18PacketEntityTeleport, so it is cancelled and queued with the S14 subclasses and S19 head look while the backtrack is active, and replayed through PacketUtil.receive on the flush conditions. Separately, an S18 for the target re-anchors realPosition to the absolute coordinates, keeping the distance gating (4.5/2.5 block thresholds) honest across teleports.
// ===== FILE: Rise 6.2.4, Client-release2/Client/src/main/java/com/alan/clients/module/impl/combat/velocity/WatchdogVelocity.java =====
package com.alan.clients.module.impl.combat.velocity;
import com.alan.clients.component.impl.player.PingSpoofComponent;
import com.alan.clients.component.impl.player.TargetComponent;
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.*;
import com.alan.clients.event.impl.packet.PacketReceiveEvent;
import com.alan.clients.event.impl.packet.PacketSendEvent;
import com.alan.clients.event.impl.render.Render3DEvent;
import com.alan.clients.module.impl.combat.Criticals;
import com.alan.clients.module.impl.combat.KillAura;
import com.alan.clients.module.impl.combat.Velocity;
import com.alan.clients.module.impl.movement.Flight;
import com.alan.clients.module.impl.movement.LongJump;
import com.alan.clients.module.impl.movement.Speed;
import com.alan.clients.module.impl.player.Scaffold;
import com.alan.clients.module.impl.render.chat.Chat;
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.player.PlayerUtil;
import com.alan.clients.util.render.ColorUtil;
import com.alan.clients.util.render.RenderUtil;
import com.alan.clients.util.vector.Vector2d;
import com.alan.clients.value.Mode;
import com.alan.clients.value.impl.BooleanValue;
import com.alan.clients.value.impl.NumberValue;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.network.Packet;
import net.minecraft.network.play.client.C0BPacketEntityAction;
import net.minecraft.network.play.server.*;
import net.minecraft.util.Vec3;
import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;
public final class WatchdogVelocity extends Mode<Velocity> {
public WatchdogVelocity(String name, Velocity parent) {
super(name, parent);
}
private long active2StartTime = -1; // Tracks when active2 was set to true
boolean active2 = false;
boolean send = false;
public final BooleanValue stack = new BooleanValue("Stack", this, true);
public final BooleanValue spoof = new BooleanValue("Ping Spoof", this, true);
public final BooleanValue spoof2 = new BooleanValue("Watchdog Backtrack", this, false);
public final BooleanValue boost = new BooleanValue("Damage Boost (not for hypixel)", this, false);
private final NumberValue speed = new NumberValue("Damage Boost Speed", this, 1, 1, 10, .01);
private boolean active, receiving, buffer;
private Vec3 realPosition = new Vec3(0, 0, 0);
public Entity targetEntity;
private int amount;
private final ArrayList<Packet<?>> packets = new ArrayList<>();
private boolean isSpoof2Packet(Packet<?> packet) {
return packet instanceof S14PacketEntity.S16PacketEntityLook ||
packet instanceof S14PacketEntity.S15PacketEntityRelMove ||
packet instanceof S14PacketEntity.S17PacketEntityLookMove ||
packet instanceof S19PacketEntityHeadLook ||
packet instanceof S18PacketEntityTeleport;
}
@EventLink
public final Listener<PacketReceiveEvent> onPacketReceive = event -> {
if (receiving || getModule(LongJump.class).isEnabled() && mc.thePlayer.offGroundTicks<29 || getModule(Flight.class).isEnabled()) return;
switch (event.getPacket()) {
case S12PacketEntityVelocity velocity -> {
if (velocity.getEntityID() == mc.thePlayer.getEntityId()) {
if (stack.getValue() && amount < 1 && (!mc.thePlayer.onGround) && Math.random() < 0.73 && !(mc.thePlayer.offGroundTicks > 13) || mc.thePlayer.inWater || (getModule(Scaffold.class).isEnabled() )) {
amount++;
buffer = true;
// ChatUtil.display("stack");
event.setCancelled();
buffer = false;
}
if (!event.isCancelled() && (!getModule(Scaffold.class).isEnabled() ) && !(mc.thePlayer.offGroundTicks > 11) && ((!mc.thePlayer.onGround ) || (mc.thePlayer.onGround && !MoveUtil.isMoving())) && !(velocity.getMotionY()/800D < .08 && !(getModule(Speed.class).isEnabled() || mc.thePlayer.inWater || !mc.thePlayer.isInLava()) )) {
amount = 0;
active = true;
// ChatUtil.display("Set Active");
packets.add(velocity);
event.setCancelled();
} else if (!event.isCancelled() ) {
if((!getModule(Scaffold.class).isEnabled() )){
mc.thePlayer.motionY = velocity.getMotionY() / 8000.0D;
}
// ChatUtil.display("normal");
event.setCancelled();
}
}
}
case S32PacketConfirmTransaction transaction -> {
if (active && spoof.getValue()) {
packets.add(transaction);
event.setCancelled();
// PingSpoofComponent.spoof(50, true, false, false, false, false, false);
}
}
case S00PacketKeepAlive keepAlive -> {
if (active && spoof.getValue()) {
// packets.add(keepAlive);
event.setCancelled();
}
}
case S14PacketEntity.S16PacketEntityLook s16PacketEntityLook -> {
if ((active2 || active) && spoof2.getValue() && !send) {
packets.add(s16PacketEntityLook);
event.setCancelled();
}
}
case S14PacketEntity.S15PacketEntityRelMove s15PacketEntityRelMove -> {
if ((active2 || active) && spoof2.getValue() && !send) {
packets.add(s15PacketEntityRelMove);
event.setCancelled();
}
}
case S14PacketEntity.S17PacketEntityLookMove s17PacketEntityLookMove -> {
if ((active2 || active) && spoof2.getValue() && !send) {
packets.add(s17PacketEntityLookMove);
event.setCancelled();
}
}
case S19PacketEntityHeadLook s19PacketEntityHeadLook -> {
if ((active2 || active) && spoof2.getValue() && !send) {
packets.add(s19PacketEntityHeadLook);
event.setCancelled();
}
}
default -> {
}
}
List<EntityLivingBase> targets = TargetComponent.getTargets(12);
targets.sort(Comparator.comparingDouble(entity -> entity.hurtTime));
if (targets.isEmpty()) {
targetEntity = null;
// Add logic here to reset or flush your spoof2 states.
// For example:
if (spoof2.getValue()) {
receiving = true;
packets.stream().filter(this::isSpoof2Packet).forEach(PacketUtil::receive);
packets.clear();
receiving = false;
active2 = false;
send = false;
}
return;
}
Entity entity = targets.get(0);
if (spoof2.getValue()) {
if (entity != targetEntity) {
targetEntity = entity;
realPosition.xCoord = entity.posX;
realPosition.yCoord = entity.posY;
realPosition.zCoord = entity.posZ;
}
Vec3 playerEyesPos = mc.thePlayer.getPositionEyes(1.0F);
Vec3 targetEyesPos = new Vec3(realPosition.xCoord, realPosition.yCoord, realPosition.zCoord);
double distance = playerEyesPos.distanceTo(targetEyesPos);
if ((distance > 4.5) && active || mc.thePlayer.offGroundTicks>9 && active) {
send = true;
} else if(active){
send = false;
}
//ChatUtil.display(distance);
active2 = distance < 4.5;
if( mc.thePlayer.isSwingInProgress && distance>3.1&& distance<4.5 && getModule(KillAura.class).isEnabled()){
// ChatUtil.display("reach:" + distance);
}
if (active2) {
// Check if this is the first frame where active2 is true
if (active2StartTime == -1) {
active2StartTime = System.currentTimeMillis(); // Record the starting time
}
// Check if 200ms has passed
if (System.currentTimeMillis() - active2StartTime >= Math.round((Math.random()*150))+100) {
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
// ChatUtil.display(mc.thePlayer.ticksExisted);
// Reset active2 and timer
active2 = false;
active2StartTime = -1;
}
} else {
// Reset the timer if active2 is false
active2StartTime = -1;
}
if (send && active) {
// ChatUtil.display(send);
active2 = false; // If active2 is set to false, reset the timer
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
}
if(mc.thePlayer.ticksExisted<100){
active2 = false; // If active2 is set to false, reset the timer
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
}
if (mc.thePlayer.hurtTime == 9) {
// ChatUtil.display(send);
active2 = false;
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
}
if ((distance < 2.5)) {
active2 = false;
// ChatUtil.display(send);
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
}
if ((distance > 4.5)) {
active2 = false;
// ChatUtil.display(send);
receiving = true;
packets.stream()
.filter(this::isSpoof2Packet)
.forEach(PacketUtil::receive);
packets.clear();
receiving = false;
}
final Packet<?> packet = event.getPacket();
if (packet instanceof S14PacketEntity) {
S14PacketEntity s14PacketEntity = ((S14PacketEntity) packet);
if (s14PacketEntity.entityId == targetEntity.getEntityId()) {
realPosition.xCoord += s14PacketEntity.getPosX() / 32D;
realPosition.yCoord += s14PacketEntity.getPosY() / 32D;
realPosition.zCoord += s14PacketEntity.getPosZ() / 32D;
}
} else if (packet instanceof S18PacketEntityTeleport) {
S18PacketEntityTeleport s18PacketEntityTeleport = ((S18PacketEntityTeleport) packet);
if (s18PacketEntityTeleport.getEntityId() == targetEntity.getEntityId()) {
realPosition = new Vec3(s18PacketEntityTeleport.getX() / 32D, s18PacketEntityTeleport.getY() / 32D, s18PacketEntityTeleport.getZ() / 32D);
}
}
}
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<JumpEvent> onJump = event -> {
if (mc.thePlayer.onGround && active) {
active = false;
// ChatUtil.display("Set Active");
receiving = true;
send = false;
// MoveUtil.strafe(MovdeUtil.getbaseMoveSpeed() + Math.random() / 10);
// mc.thePlayer.jump();
Vector2d motion = new Vector2d(mc.thePlayer.motionX, mc.thePlayer.motionZ);
packets.forEach(PacketUtil::receive);
// ChatUtil.display("jump");
packets.clear();
if (!boost.getValue()) {
mc.thePlayer.motionX = motion.getX();
mc.thePlayer.motionZ = motion.getY();
} else {
MoveUtil.strafe();
mc.thePlayer.motionX *= speed.getValue().doubleValue();
mc.thePlayer.motionZ *= speed.getValue().doubleValue();
}
receiving = false;
}
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<PreUpdateEvent> onPreUpdate = event -> {
if(active2 && !active && spoof2.getValue()){
PingSpoofComponent.spoof(50, true, false, false, false, true, false);
}
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<StrafeEvent> onStrafe = event -> {
if (mc.thePlayer.onGround && active && !mc.thePlayer.isJumping) {
active = false;
receiving = true;
send = false;
// MoveUtil.strafe(MoveUtil.WALK_SPEED);
Vector2d motion = new Vector2d(mc.thePlayer.motionX, mc.thePlayer.motionZ);
double motiony = mc.thePlayer.motionY;
// PingSpoofComponent.dispatch();
packets.forEach(PacketUtil::receive);
// ChatUtil.display("jump");
packets.clear();
mc.thePlayer.jump();
// PingSpoofComponent.dispatch();
mc.thePlayer.motionX = motion.getX();
mc.thePlayer.motionZ = motion.getY();
// active = false;
receiving = false;
// receiving = true;
// Vector2d motion = new Vector2d(mc.thePlayer.motionX, mc.thePlayer.motionZ);
// packets.forEach(PacketUtil::receive);
// ChatUtil.display("normal");
// packets.clear();
// mc.thePlayer.motionX = motion.getX();
// mc.thePlayer.motionZ = motion.getY();
// receiving = false;
}
};
@EventLink(value = Priorities.VERY_HIGH)
public final Listener<PostStrafeEvent> onPostStrafe = event -> {
if (mc.thePlayer.offGroundTicks > 12 && active) {
active = false;
receiving = true;
// MoveUtil.strafe(MoveUtil.getbaseMoveSpeed() + Math.random() / 10);
// mc.thePlayer.jump();
Vector2d motion = new Vector2d(mc.thePlayer.motionX, mc.thePlayer.motionZ);
double motiony = mc.thePlayer.motionY;
// PingSpoofComponent.dispatch();
packets.forEach(PacketUtil::receive);
// ChatUtil.display("jump");
packets.clear();
// PingSpoofComponent.dispatch();
mc.thePlayer.motionX = motion.getX();
mc.thePlayer.motionZ = motion.getY();
// mc.thePlayer.motionY = motiony;
receiving = false;
}
};
@EventLink()
public final Listener<Render3DEvent> onRender3D = event -> {
if (targetEntity == null || !spoof2.getValue() || (!active2 && !active)) {
return;
}
GlStateManager.pushMatrix();
GlStateManager.pushAttrib();
GlStateManager.enableBlend();
GlStateManager.disableTexture2D();
GlStateManager.disableLighting();
GL11.glDepthMask(false);
double expand = -0.14;
RenderUtil.color(Color.red, 45);
RenderUtil.drawBoundingBox(mc.thePlayer.getEntityBoundingBox()
.offset(-mc.thePlayer.posX, -mc.thePlayer.posY, -mc.thePlayer.posZ)
.offset(realPosition.xCoord, realPosition.yCoord, realPosition.zCoord)
.expand(expand, -.3, expand));
GlStateManager.enableTexture2D();
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GL11.glDepthMask(true);
GlStateManager.popAttrib();
GlStateManager.popMatrix();
GlStateManager.resetColor();
};
}
// NOTE (AI): The Watchdog Backtrack path cancels the S14 subclasses plus S19PacketEntityHeadLook and
// NOTE (AI): S18PacketEntityTeleport for the nearest target and replays them through PacketUtil.receive
// NOTE (AI): after 100-250 ms or when the distance to the tracked realPosition crosses the 4.5/2.5
// NOTE (AI): thresholds. Buffering clientbound packets is invisible to the server, which is why the
// NOTE (AI): module can hold the target's movement state without raising flags.
anticheat Anti-Cheat Checks
S18 is the clientbound absolute-position correction for one entity, and server anticheats consume it on the send side as the reset point of entity state. Trackers re-anchor their replicated entity positions on it (Hydro, AntiHaxerman), teleport processors re-sync the player's own movement state when the teleport targets the checked player (Artemis, Frequency, BetterAnticheat), and the same packet is what makes reach verification and phase checks trust the server's entity locations. Because the packet is clientbound, no anticheat validates its contents; they only timestamp and consume it.
Re-anchor the replicated position of a tracked entity when the server sends its absolute teleport, so reach checks keep measuring against the corrected location.
handleEntityTeleport wraps the ENTITY_TELEPORT packet in WrapperPlayServerEntityTeleport, looks up the entity, and applies handleTeleport(x, y, z) inside the transaction tracker's confirm-pre window, with confirm-post advancing all entity queues. The same tracker handles spawn, relative moves and destroy packets, so the entity map mirrors the full server-side entity stream.
// ===== FILE: Incognitolol-Hydro, src/main/java/integral/studios/hydro/model/tracker/impl/EntityTracker.java =====
package integral.studios.hydro.model.tracker.impl;
import com.github.retrooper.packetevents.event.PacketReceiveEvent;
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.*;
import integral.studios.hydro.model.PlayerData;
import integral.studios.hydro.model.tracker.Tracker;
import integral.studios.hydro.util.player.tracker.entity.TrackedEntity;
import integral.studios.hydro.util.packet.PacketUtil;
import lombok.Getter;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Getter
public class EntityTracker extends Tracker {
// Thread-safe entity storage
private final Map<Integer, TrackedEntity> entityMap = new ConcurrentHashMap<>();
public EntityTracker(PlayerData playerData) {
super(playerData);
}
@Override
public void registerOutgoingPreHandler(PacketSendEvent event) {
if (event.getPacketType() == PacketType.Play.Server.SPAWN_LIVING_ENTITY) {
handleSpawnLivingEntity(event);
} else if (event.getPacketType() == PacketType.Play.Server.SPAWN_PLAYER) {
handleSpawnPlayer(event);
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_RELATIVE_MOVE) {
handleEntityRelativeMove(event);
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_RELATIVE_MOVE_AND_ROTATION) {
handleEntityRelativeMoveAndRotation(event);
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_TELEPORT) {
handleEntityTeleport(event);
} else if (event.getPacketType() == PacketType.Play.Server.DESTROY_ENTITIES) {
handleDestroyEntities(event);
}
}
@Override
public void registerIncomingPostHandler(PacketReceiveEvent event) {
if (PacketUtil.isFlying(event.getPacketType())) {
handleFlyingPacket();
}
}
private void handleSpawnLivingEntity(PacketSendEvent event) {
WrapperPlayServerSpawnLivingEntity wrapper = new WrapperPlayServerSpawnLivingEntity(event);
Vector3d position = wrapper.getPosition();
int entityId = wrapper.getEntityId();
TrackedEntity entity = new TrackedEntity(entityId, position.x, position.y, position.z);
entityMap.put(entityId, entity);
}
private void handleSpawnPlayer(PacketSendEvent event) {
WrapperPlayServerSpawnPlayer wrapper = new WrapperPlayServerSpawnPlayer(event);
Vector3d position = wrapper.getPosition();
int entityId = wrapper.getEntityId();
TrackedEntity entity = new TrackedEntity(entityId, position.x, position.y, position.z);
entityMap.put(entityId, entity);
}
private void handleEntityRelativeMove(PacketSendEvent event) {
WrapperPlayServerEntityRelativeMove wrapper = new WrapperPlayServerEntityRelativeMove(event);
TrackedEntity entity = entityMap.get(wrapper.getEntityId());
if (entity == null) {
return;
}
playerData.getTransactionTracker().confirmPre(() -> {
entity.handleMovement(wrapper.getDeltaX(), wrapper.getDeltaY(), wrapper.getDeltaZ());
});
playerData.getTransactionTracker().confirmPost(this::updateAllEntitiesPostTransaction);
}
private void handleEntityRelativeMoveAndRotation(PacketSendEvent event) {
WrapperPlayServerEntityRelativeMoveAndRotation wrapper = new WrapperPlayServerEntityRelativeMoveAndRotation(event);
TrackedEntity entity = entityMap.get(wrapper.getEntityId());
if (entity == null) {
return;
}
playerData.getTransactionTracker().confirmPre(() -> {
entity.handleMovement(wrapper.getDeltaX(), wrapper.getDeltaY(), wrapper.getDeltaZ());
});
playerData.getTransactionTracker().confirmPost(this::updateAllEntitiesPostTransaction);
}
private void handleEntityTeleport(PacketSendEvent event) {
WrapperPlayServerEntityTeleport wrapper = new WrapperPlayServerEntityTeleport(event);
TrackedEntity entity = entityMap.get(wrapper.getEntityId());
if (entity == null) {
return;
}
Vector3d position = wrapper.getPosition();
playerData.getTransactionTracker().confirmPre(() -> {
entity.handleTeleport(position.x, position.y, position.z);
});
playerData.getTransactionTracker().confirmPost(this::updateAllEntitiesPostTransaction);
}
private void handleDestroyEntities(PacketSendEvent event) {
WrapperPlayServerDestroyEntities wrapper = new WrapperPlayServerDestroyEntities(event);
for (int entityId : wrapper.getEntityIds()) {
entityMap.remove(entityId);
}
}
private void handleFlyingPacket() {
entityMap.values().forEach(TrackedEntity::handlePostFlying);
}
private void updateAllEntitiesPostTransaction() {
entityMap.values().forEach(TrackedEntity::handlePostTransaction);
}
public TrackedEntity get(int entityId) {
return entityMap.get(entityId);
}
public boolean isTracking(int entityId) {
return entityMap.containsKey(entityId);
}
public int getTrackedEntityCount() {
return entityMap.size();
}
public TrackedEntity removeEntity(int entityId) {
return entityMap.remove(entityId);
}
public void clearEntities() {
entityMap.clear();
}
public double getDistanceToEntity(int entityId) {
TrackedEntity entity = entityMap.get(entityId);
if (entity == null) {
return -1;
}
double dx = entity.getX() - playerData.getPositionTracker().getX();
double dy = entity.getY() - playerData.getPositionTracker().getY();
double dz = entity.getZ() - playerData.getPositionTracker().getZ();
return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
public TrackedEntity getClosestEntity() {
TrackedEntity closest = null;
double minDistance = Double.MAX_VALUE;
for (Map.Entry<Integer, TrackedEntity> entry : entityMap.entrySet()) {
TrackedEntity entity = entry.getValue();
double distance = getDistanceToEntity(entry.getKey());
if (distance >= 0 && distance < minDistance) {
minDistance = distance;
closest = entity;
}
}
return closest;
}
public Map<Integer, TrackedEntity> getEntitiesWithinDistance(double maxDistance) {
Map<Integer, TrackedEntity> nearbyEntities = new ConcurrentHashMap<>();
for (Map.Entry<Integer, TrackedEntity> entry : entityMap.entrySet()) {
double distance = getDistanceToEntity(entry.getKey());
if (distance >= 0 && distance <= maxDistance) {
nearbyEntities.put(entry.getKey(), entry.getValue());
}
}
return nearbyEntities;
}
public int getEntityId(TrackedEntity entity) {
if (entity == null) return -1;
for (Map.Entry<Integer, TrackedEntity> entry : entityMap.entrySet()) {
if (entry.getValue() == entity) {
return entry.getKey();
}
}
return -1;
}
}
// NOTE (AI): The transaction-confirm wrapping is what distinguishes these trackers from naive packet handlers: the entity position advances only when the player's own connection state confirms the tick.Treat an S18 targeting the checked player as a movement reset: rebuild the player's movement, location and rotation from the teleport coordinates on transaction confirm.
The processor matches GPacketPlayServerEntityTeleport, ignores it unless the entity id equals the player's own id, then schedules a transaction-confirmed action. The pre phase stores the last entity teleport, copies the current velocity into lastVelocity, rebuilds PlayerMovement and PlayerRotation from the teleport values, and sets processedEntityTeleport true; the post phase clears the flag.
// ===== FILE: artemisac-artemis-minecraft-anticheat, ac.artemis.core/src/main/java/ac/artemis/core/v4/processor/teleport/TeleportPreProcessor.java =====
package ac.artemis.core.v4.processor.teleport;
import ac.artemis.core.v4.data.holders.ConnectionHolder;
import ac.artemis.core.v4.processor.AbstractHandler;
import ac.artemis.core.v4.data.PlayerData;
import ac.artemis.core.v4.utils.function.PacketAction;
import cc.ghast.packet.PacketAPI;
import ac.artemis.packet.spigot.wrappers.GPacket;
import ac.artemis.core.v4.utils.position.PlayerMovement;
import ac.artemis.core.v4.utils.position.PlayerRotation;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerEntityTeleport;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerPosition;
import java.util.Map;
import java.util.Random;
import java.util.WeakHashMap;
public class TeleportPreProcessor extends AbstractHandler {
public TeleportPreProcessor(PlayerData data) {
super("Teleport [0x01]", data);
}
@Override
public void handle(final GPacket packet) {
if (packet instanceof GPacketPlayServerPosition) {
final GPacketPlayServerPosition pos = (GPacketPlayServerPosition) packet;
}
else if (packet instanceof GPacketPlayServerEntityTeleport) {
final GPacketPlayServerEntityTeleport pos = (GPacketPlayServerEntityTeleport) packet;
if (pos.getEntityId() != data.getPlayer().getEntityId()) {
return;
}
data.connection.confirmFunction(ConnectionHolder.ConfirmationType.TRANSACTION, new PacketAction() {
@Override
public void pre() {
data.connection.setLastEntityTeleport(pos);
final PlayerMovement movement = new PlayerMovement(
data.getPlayer().getWorld(),
pos.getValueX(),
pos.getValueY(),
pos.getValueZ(),
pos.getValueYaw(),
pos.getValuePitch(),
pos.getTimestamp()
);
if (data.movement.getVelocity() != null)
data.movement.setLastVelocity(data.movement.getVelocity());
data.movement.setMovement(movement.setWorld(data.getPlayer().getWorld()));
data.movement.setLocation(movement.setWorld(data.getPlayer().getWorld()));
data.movement.setRotation(new PlayerRotation(data.getPlayer(),
movement.getYaw(),
movement.getPitch(),
movement.getTimestamp())
);
data.movement.setProcessedEntityTeleport(true);
}
@Override
public void post() {
data.movement.setProcessedEntityTeleport(false);
}
});
}
}
}
// NOTE (AI): The player-position variants (GPacketPlayServerPosition) and the entity-teleport variant share the same processor; only the S18 branch is shown in context here.Detect when the server teleports the checked player and reset the action manager state so movement checks exempt the teleport tick.
On PacketPlayOutEntityTeleport the processor wraps the packet, and when the entity id matches the player it calls playerData.getActionManager().onTeleport(). The same processor feeds S12 velocity into the velocity manager for the self entity, and treats PacketPlayOutPosition as a teleport too.
// ===== 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 S18 branch handles the entity-teleport case only for the self entity; teleports of other entities are ignored, matching the tracker pattern in Hydro and AntiHaxerman.Snap a tracked entity's replicated position to the S18 absolute coordinates so reach and hitbox checks use the corrected server location.
On GPacketPlayServerEntityTeleport the tracker overwrites serverPosX/Y/Z with the absolute fixed-point values and computes the new position by dividing by 32.0, but only if at least one axis differs by more than the vanilla epsilon (0.03125 for x/z, 0.015625 for y); otherwise the current position is kept. The update runs inside a connection-confirm action, so it applies at the player's confirmed tick.
// ===== FILE: Tecnio-AntiHaxerman, src/main/java/me/tecnio/ahm/data/tracker/impl/EntityTracker.java =====
package me.tecnio.ahm.data.tracker.impl;
import ac.artemis.packet.spigot.wrappers.GPacket;
import ac.artemis.packet.wrapper.client.PacketPlayClientFlying;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerEntity;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerEntityDestroy;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerEntityTeleport;
import cc.ghast.packet.wrapper.packet.play.server.GPacketPlayServerSpawnNamedEntity;
import lombok.Getter;
import me.tecnio.ahm.data.PlayerData;
import me.tecnio.ahm.data.tracker.Tracker;
import me.tecnio.ahm.util.player.TrackerEntity;
import java.util.HashMap;
import java.util.Map;
@Getter
public final class EntityTracker extends Tracker {
private final Map<Integer, TrackerEntity> trackerMap = new HashMap<>();
public EntityTracker(final PlayerData data) {
super(data);
}
@Override
public void handle(final GPacket packet) {
if (packet instanceof GPacketPlayServerEntity) {
final GPacketPlayServerEntity wrapper = ((GPacketPlayServerEntity) packet);
final int id = wrapper.getEntityId();
if (this.trackerMap.containsKey(id)) {
final TrackerEntity trackerEntity = this.trackerMap.get(id);
if (trackerEntity == null) return;
data.getConnectionTracker().confirm(() -> {
final double x = wrapper.getX();
final double y = wrapper.getY();
final double z = wrapper.getZ();
trackerEntity.serverPosX += x;
trackerEntity.serverPosY += y;
trackerEntity.serverPosZ += z;
trackerEntity.setPosition2(
trackerEntity.serverPosX / 32.0D,
trackerEntity.serverPosY / 32.0D,
trackerEntity.serverPosZ / 32.0D
);
});
}
} else if (packet instanceof GPacketPlayServerEntityTeleport) {
final GPacketPlayServerEntityTeleport wrapper = ((GPacketPlayServerEntityTeleport) packet);
final int id = wrapper.getEntityId();
if (this.trackerMap.containsKey(id)) {
final TrackerEntity trackerEntity = this.trackerMap.get(id);
if (trackerEntity == null) return;
data.getConnectionTracker().confirm(() -> {
trackerEntity.serverPosX = wrapper.getX();
trackerEntity.serverPosY = wrapper.getY();
trackerEntity.serverPosZ = wrapper.getZ();
final double d0 = (double) trackerEntity.serverPosX / 32.0D;
final double d1 = (double) trackerEntity.serverPosY / 32.0D;
final double d2 = (double) trackerEntity.serverPosZ / 32.0D;
final double deltaX = Math.abs(trackerEntity.getPosX() - d0);
final double deltaY = Math.abs(trackerEntity.getPosY() - d1);
final double deltaZ = Math.abs(trackerEntity.getPosZ() - d2);
if (deltaX < 0.03125D
&& deltaY < 0.015625D
&& deltaZ < 0.03125D) {
trackerEntity.setPosition2(trackerEntity.getPosX(), trackerEntity.getPosY(), trackerEntity.getPosZ());
} else {
trackerEntity.setPosition2(d0, d1, d2);
}
});
}
} else if (packet instanceof GPacketPlayServerSpawnNamedEntity) {
final GPacketPlayServerSpawnNamedEntity wrapper = ((GPacketPlayServerSpawnNamedEntity) packet);
data.getConnectionTracker().confirm(() -> {
final TrackerEntity trackerEntity = new TrackerEntity(wrapper.getEntityId(),
// Thank you artemis packet api for being shit and dividing my shit.
(int) Math.round(wrapper.getX() * 32.0D),
(int) Math.round(wrapper.getY() * 32.0D),
(int) Math.round(wrapper.getZ() * 32.0D)
);
trackerEntity.setPosition(wrapper.getX(), wrapper.getY(), wrapper.getZ());
this.trackerMap.put(wrapper.getEntityId(), trackerEntity);
});
} else if (packet instanceof GPacketPlayServerEntityDestroy) {
final GPacketPlayServerEntityDestroy wrapper = ((GPacketPlayServerEntityDestroy) packet);
for (final int entity : wrapper.getEntities()) {
this.trackerMap.remove(entity);
}
}
}
@Override
public void handlePost(final GPacket packet) {
if (packet instanceof PacketPlayClientFlying) {
this.trackerMap.values().forEach(TrackerEntity::update);
}
}
}
// NOTE (AI): The epsilon check reproduces NetHandlerPlayClient.handleEntityTeleport, which keeps the current position when the entity is already within a 32nd of a block, so the replicated state stays faithful to what the client does.Queue every teleport sent to the player, including S18 self teleports, and verify that the player's next flying packet rejoins the teleported position, rotation and ground state.
handlePacketPlaySend wraps ENTITY_TELEPORT for the player's own entity id into a Teleport record (position, rotation, relative flags, onGround) and adds it to eligibleTeleports when the confirmation begins. On each flying packet, match() compares onGround, then the absolute or relative position coordinate by coordinate, then rotation; a teleport still eligible at tick end sets missedTeleport. The strictness depends on whether the player sent a position in the previous tick (2.0E-4 leniency when not).
// ===== FILE: amnoah-BetterAnticheat, core/src/main/java/better/anticheat/core/player/tracker/impl/teleport/TeleportTracker.java =====
package better.anticheat.core.player.tracker.impl.teleport;
import better.anticheat.core.player.Player;
import better.anticheat.core.player.tracker.Tracker;
import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent;
import com.github.retrooper.packetevents.event.simple.PacketPlaySendEvent;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.teleport.RelativeFlag;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityTeleport;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerPositionAndLook;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerPlayerRotation;
import lombok.Getter;
import wtf.spare.sparej.Pair;
import java.util.ArrayList;
import java.util.List;
/**
* This tracker compensates teleportation packets and checks whether a player's movement matches an eligible teleport.
*/
public class TeleportTracker extends Tracker {
private final List<Teleport> eligibleTeleports = new ArrayList<>(), remove = new ArrayList<>();
@Getter
private boolean teleported = true, positionTeleported = true, rotationTeleported = true, missedTeleport = false;
private boolean positionLastTick = false, positionThisTick = false;
private final boolean supportsTickEnd;
public TeleportTracker(Player player) {
super(player);
this.supportsTickEnd = player.getUser().getClientVersion()
.isNewerThanOrEquals(ClientVersion.V_1_21_2);
}
@Override
public void handlePacketPlayReceive(PacketPlayReceiveEvent event) {
if (event.getPacketType() == PacketType.Play.Client.CLIENT_TICK_END) handleTickEnd();
if (!WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) return;
final var wrapper = new WrapperPlayClientPlayerFlying(event);
if (!supportsTickEnd) handleTickEnd();
if (wrapper.hasPositionChanged()) positionThisTick = true;
for (final var teleport : eligibleTeleports) {
if (match(teleport, wrapper)) {
if (teleport.getPosition() != null) positionTeleported = true;
if (teleport.getRotation() != null) rotationTeleported = true;
teleported = true;
teleport.setHandled(true);
}
/*
* Players receive teleports sequentially, so if they haven't handled this teleport yet then they can't
* handle any future ones.
* Another intended feature: we allow players to potentially qualify for a teleport multiple times. We could
* be wrong and they hadn't actually teleported (such as the scenario a player is standing still, teleports
* to themself, they have a network lag spike after confirming the pre, and then they start moving. Once
* their network resumes they would teleport but we would have already wrongly assumed they had teleported).
* This could allow for potential exploitation of the anticheat, but it can be fixed by lag compensating
* more. The more things we have lag compensated, the more harmful it is for a player to modify this
* behavior.
* This could also be fixed with a prediction system, but that's a long ways out.
*/
// Note: Commented out for now to try to increase handler performance!
//if (!teleport.isHandled()) break;
}
}
/**
* Handle compensating different types of teleport packets.
*/
@Override
public void handlePacketPlaySend(PacketPlaySendEvent event) {
switch (event.getPacketType()) {
case ENTITY_TELEPORT -> {
WrapperPlayServerEntityTeleport wrapper = new WrapperPlayServerEntityTeleport(event);
if (wrapper.getEntityId() != player.getUser().getEntityId()) return;
Teleport teleport = new Teleport(wrapper.getPosition(), new Pair<>(wrapper.getPitch(), wrapper.getYaw()), wrapper.getRelativeFlags(), wrapper.isOnGround());
handleTeleport(teleport);
}
case PLAYER_ROTATION -> {
WrapperPlayServerPlayerRotation wrapper = new WrapperPlayServerPlayerRotation(event);
Teleport teleport = new Teleport(null, new Pair<>(wrapper.getPitch(), wrapper.getYaw()), null, null);
handleTeleport(teleport);
}
case PLAYER_POSITION_AND_LOOK -> {
WrapperPlayServerPlayerPositionAndLook wrapper = new WrapperPlayServerPlayerPositionAndLook(event);
Teleport teleport = new Teleport(wrapper.getPosition(), new Pair<>(wrapper.getPitch(), wrapper.getYaw()), wrapper.getRelativeFlags(), null);
handleTeleport(teleport);
}
}
}
/**
* Handles a tickend. Is a separate method for compatibility so we can support pre 1.21.2.
*/
private void handleTickEnd() {
positionTeleported = rotationTeleported = missedTeleport = teleported = false;
positionLastTick = positionThisTick;
positionThisTick = false;
/*
* Due to the current design of our confirmation system, teleports do not actually resolve within our
* confirmation window. Rather, they resolve in the tick following the post transaction (apart from world
* change teleports! Which resolve in time for some reason?). So, we handle it here in the following tick if
* needed.
*/
for (Teleport teleport : remove) {
eligibleTeleports.remove(teleport);
if (!teleport.isHandled()) missedTeleport = true;
}
remove.clear();
}
/**
* Handle compensating teleports. When the initial confirmation returns, we start including the teleport. When the
* post confirmation returns, we remove the teleport.
*/
private void handleTeleport(Teleport teleport) {
var confirm = player.getConfirmationTracker().confirm();
confirm.onBegin(() -> {
eligibleTeleports.add(teleport);
});
confirm.onAfterConfirm(() -> {
remove.add(teleport);
});
}
/**
* This method checks whether the given Teleport matches the player's current Flying packet. To check this, we see
* if the onGround status, position, and rotation matches. We also account for relative movements,
*/
private boolean match(Teleport teleport, WrapperPlayClientPlayerFlying wrapper) {
/*
* Player Rotations and Player Position and Look packets don't define a ground status.
* Entity Teleport define a ground status.
*/
ground:
{
if (teleport.getOnGround() == null) break ground;
if (!teleport.getOnGround().equals(wrapper.isOnGround())) return false;
}
/*
* Entity Teleport and Player Position and Look define a position.
* Player Rotations don't define a position.
*/
position:
{
if (teleport.getPosition() == null) break position;
if (!wrapper.hasPositionChanged()) return false;
double x = teleport.getPosition().getX(), y = teleport.getPosition().getY(), z = teleport.getPosition().getZ();
boolean relX = false, relY = false, relZ = false;
if (teleport.getRelativeFlags() != null) {
if (teleport.getRelativeFlags().has(RelativeFlag.X)) {
x += player.getPositionTracker().getLastX();
relX = true;
}
if (teleport.getRelativeFlags().has(RelativeFlag.Y)) {
y += player.getPositionTracker().getLastY();
relY = true;
}
if (teleport.getRelativeFlags().has(RelativeFlag.Z)) {
z += player.getPositionTracker().getLastZ();
relZ = true;
}
}
if (!compareCoordinate(x, wrapper.getLocation().getX(), relX)) return false;
if (!compareCoordinate(y, wrapper.getLocation().getY(), relY)) return false;
if (!compareCoordinate(z, wrapper.getLocation().getZ(), relZ)) return false;
}
/*
* Currently no teleport packets don't include a rotation, but I don't trust Mojang so we futureproof!
*/
rotation:
{
if (teleport.getRotation() == null) break rotation;
if (!wrapper.hasRotationChanged()) return false;
float pitch = teleport.getRotation().getX(), yaw = teleport.getRotation().getY();
if (teleport.getRelativeFlags() != null) {
if (teleport.getRelativeFlags().has(RelativeFlag.YAW) || teleport.getRelativeFlags().has(RelativeFlag.PITCH))
break rotation;
/*
// Rotation relatives seems to be messing up a lot right now. So, we don't care about it until we figure
// out.
if (teleport.getRelativeFlags().has(RelativeFlag.PITCH)) {
// Pitch is bounded -90 to 90
if (pitch < 0) {
pitch = Math.max(-90, player.getRotationTracker().getLastPitch() + pitch);
} else {
pitch = Math.min(90, player.getRotationTracker().getLastPitch() + pitch);
}
}
if (teleport.getRelativeFlags().has(RelativeFlag.YAW)) yaw += player.getRotationTracker().getLastYaw();
*/
}
// Verify equality.
if (pitch != wrapper.getLocation().getPitch() || yaw != wrapper.getLocation().getYaw()) return false;
}
return true;
}
/**
* See ArtificialPositionCheck.java for an explanation behind the value used here.
* Check if the player's coordinate is accurate for their teleport.
*/
private boolean compareCoordinate(double first, double second, boolean relative) {
/*
* If the teleport is not a relative, it must be an exact match to the teleport.
* If a teleport is relative, it means that it is based on the previous position.
* If the player did not send a position packet in their last tick, it means they could have desynced and their
* movement could be off by up to 2.0E-4 (see ArtificialPositionCheck.java for an explanation on the value).
*/
if (relative) {
double leniency;
if (positionLastTick) leniency = 0;
else leniency = 2.0E-4;
return Math.abs(first - second) <= leniency;
} else return first == second;
}
}
// NOTE (AI): ENTITY_TELEPORT only counts for the player's own entity id, and the match tolerates relative-flag coordinates by folding in the last confirmed position.Related Packets
Wiki Cross-Reference
The server sends this absolute-position correction when an entity moves far enough that relative deltas cannot represent it, documented in the current protocol as moves of more than 8 blocks.
MCP 1.8.9 S18PacketEntityTeleport implements Packet
1.8.9 callers: EntityTrackerEntry.? sends new S18PacketEntityTeleport (line 221) +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 S18PacketEntityTeleport
Full source walkthroughs of the modules and anti-cheats that use this packet.