> For the complete documentation index, see [llms.txt](https://scripting.breeze.rip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://scripting.breeze.rip/newgen/spoof_manager.md).

# Spoof Manager

The `spoofManager` namespace lets your script intercept, cancel, delay, and release packets in both directions. When several scripts and modules hold packets, a packet only leaves once every one of them has released it.

This manager is mainly meant for making lag based modules. For basic packet manipulation we recommend [PacketSendEvent](/newgen/api/events/packetsendevent.md).

***

### Setup

Optionally set your priority during initialization. Higher priorities decide first; the default is 5.

```javascript
spoofManager.setPriority(10);
```

***

### Intercepting Packets

#### `onPacketSend`

Called for every outbound packet (client → server). Return a `SpoofAction` to decide what happens to it.

```javascript
spoofManager.onPacketSend((packet) => {
    if (packet instanceof ServerboundPlayerCommandPacket && packet.action === "START_SPRINTING") {
        return "CANCEL"; // the server never hears that we started sprinting
    }
    return "PROCESS"; // let everything else through
});
```

***

#### `onPacketReceive`

Called for every inbound packet (server → client). Same `SpoofAction` return values apply.

```javascript
spoofManager.onPacketReceive((packet) => {
    if (packet instanceof ClientboundPlayerPositionPacket) {
        return "DELAY"; // hold the teleport until we're ready
    }
    return "PROCESS";
});
```

{% hint style="info" %}
Every packet has an `id` like `"minecraft:swing"`. Ids stay the same across Minecraft versions, so `packet.id === "minecraft:swing"` keeps working even for packets that have no object of their own in the API.
{% endhint %}

***

### SpoofAction Values

| Value       | Description                                           |
| ----------- | ----------------------------------------------------- |
| `"PROCESS"` | Do nothing, let the packet continue as normal         |
| `"CANCEL"`  | Drop the packet entirely — it will never be processed |
| `"DELAY"`   | Hold the packet until you manually release it         |

### Releasing Delayed Packets

#### `onUpdate`

Called every frame with the packets your script is holding. Use this to decide when to release them.

```javascript
spoofManager.onUpdate((packets) => {
    for (const held of packets) {
        if (held.hasAged(1000)) { // release after 1 second
            spoofManager.release(held);
        }
    }
});
```

Each `DelayedPacket` exposes:

| Property / Method | Description                                                       |
| ----------------- | ----------------------------------------------------------------- |
| `packet`          | The original `Packet` object                                      |
| `time`            | Epoch ms timestamp of when it was delayed                         |
| `direction()`     | `"IN"` or `"OUT"`                                                 |
| `hasAged(ms)`     | `true` if the packet has been held for at least `ms` milliseconds |

### Flushing Packets

If you need to release everything at once, use the flush helpers.

```javascript
spoofManager.flushAll();      // release all delayed packets
spoofManager.flushIncoming(); // release only inbound packets
spoofManager.flushOutgoing(); // release only outbound packets
```

{% hint style="success" %}
You don't have to flush when your script turns off: a disabled script's packets are released on the next update, and unloading or reloading the script releases them too.
{% endhint %}

***

### Sending Packets Manually

You can also send your own packets to the server. The second argument decides whether other modules and scripts see it in `PacketSendEvent`.

```javascript
spoofManager.sendPacket(new ServerboundSwingPacket("MAIN_HAND"), true);
```

{% hint style="warning" %}
Sending packets the vanilla client never would is the fastest way to get banned.
{% endhint %}
