Network (rnet)
Inspection
Traffic statistics, aliases and field schemas.
Traffic information
rnet.known()
Returns every packet type seen so far, most frequent first. Each entry has fields such as name, dir, count and rate.
rnet.top(count = 5, dir)
Returns the busiest packet types right now (those with a rate above 0), highest rate first. dir limits it to "out" or "in".
for _, k in ipairs(rnet.top(5, "in")) do
print(k.name, k.rate)
end
rnet.rate(dir)
Returns the total packet rate for a direction (or both if dir is nil).
rnet.stats()
Returns the library's overall statistics. Alias: rnet.status().
rnet.watch()
Does nothing. Kept so that old scripts still run. Subscriptions decide what is captured.
Aliases
rnet.alias(name, pattern)
Adds a friendly name for a pattern.
rnet.alias("Heal", "set_health")
rnet.on("Heal", function(p) print(p.health) end, "in")
rnet.resolve(name)
Returns name unchanged. Kept for compatibility.
Built-in aliases
| Alias | Pattern |
|---|---|
Move | move_player_* |
MovePos | move_player_pos |
MoveRot | move_player_rot |
MovePosRot | move_player_pos_rot |
MoveGround | move_player_status_only |
Command | chat_command* |
Interact | interact |
UseItem | use_item |
UseItemOn | use_item_on |
PlayerAction | player_action |
PlayerCommand | player_command |
Input | player_input |
HeldItem | set_carried_item |
ClickSlot | container_click |
CloseScreen | container_close |
ClientTick | client_tick_end |
Respawn | client_command |
EntitySpawn | add_entity |
EntityMove | move_entity_* |
EntityTeleport | teleport_entity |
EntityVelocity | set_entity_motion |
EntityRemove | remove_entities |
EntityStatus | entity_event |
Damage | damage_event |
Hurt | hurt_animation |
Health | set_health |
PlayerChat | player_chat |
SystemChat | system_chat |
Sound | sound* |
Chunk | level_chunk_with_light |
BlockUpdate | block_update |
Time | set_time |
Position | player_position |
Title | set_title_text |
Particle | level_particles |
Explosion | explode |
Experience | set_experience |
Schemas
A schema gives names to a packet's fields. It is a pattern, a type signature (one letter per field, see Packets) and a list of names.
rnet.schema(pattern, signature, names)
Registers a schema. It is only used when the packet's real field types match the signature.
rnet.schema("my_packet", "dds", { "a", "b", "label" })
Built-in schemas
| Pattern | Field names |
|---|---|
move_player_* | x, y, z, yaw, pitch, onGround, horizontalCollision (and hasPos, hasRot for the long form) |
chat_command | command |
chat | message, timestamp, salt, signature, lastSeen |
set_carried_item | slot |
keep_alive | id |
swing | hand |
set_health | health, food, saturation |
set_experience | progress, level, total |
set_time | gameTime, dayTime, tickDayTime |
move_entity_* | id, dx, dy, dz, yaw, pitch, onGround, hasRot, hasPos |
teleport_entity | id, change, relatives, onGround |
add_entity | id, uuid, type, x, y, z, movement, pitch, yaw, headYaw, data (or the older form with vx, vy, vz) |