> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selvut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Packet Helpers

> Send common packets without raw packet construction.

Save as `packet_helpers.lua`.

```lua theme={null}
Script.meta({
  name = "Packet Helpers",
  category = "Misc",
  description = "Small packet helper commands"
})

Script.command("swingmain", {
  description = "Send a main-hand swing packet"
}, function()
  Packet.swing("main")
  Chat.log("Sent swing packet")
end)

Script.command("useoff", {
  description = "Send an offhand use packet"
}, function()
  Packet.useItem({
    hand = "offhand",
    yaw = Player.yaw() or 0,
    pitch = Player.pitch() or 0
  })
end)

Script.command("markblock", {
  description = "Use the targeted block face"
}, function()
  local block = World.rayTraceBlock()
  if block == nil then
    Chat.log("No block targeted")
    return
  end

  Packet.useBlock({
    pos = block,
    face = "up",
    hand = "main"
  })
end)

Script.command("hit", {
  description = "Attack the targeted entity"
}, function()
  local entity = Player.rayTraceEntity(4.5)
  if entity == nil then
    Chat.log("No entity targeted")
    return
  end

  Packet.attack(entity)
end)
```
