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

AliasPattern
Movemove_player_*
MovePosmove_player_pos
MoveRotmove_player_rot
MovePosRotmove_player_pos_rot
MoveGroundmove_player_status_only
Commandchat_command*
Interactinteract
UseItemuse_item
UseItemOnuse_item_on
PlayerActionplayer_action
PlayerCommandplayer_command
Inputplayer_input
HeldItemset_carried_item
ClickSlotcontainer_click
CloseScreencontainer_close
ClientTickclient_tick_end
Respawnclient_command
EntitySpawnadd_entity
EntityMovemove_entity_*
EntityTeleportteleport_entity
EntityVelocityset_entity_motion
EntityRemoveremove_entities
EntityStatusentity_event
Damagedamage_event
Hurthurt_animation
Healthset_health
PlayerChatplayer_chat
SystemChatsystem_chat
Soundsound*
Chunklevel_chunk_with_light
BlockUpdateblock_update
Timeset_time
Positionplayer_position
Titleset_title_text
Particlelevel_particles
Explosionexplode
Experienceset_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

PatternField names
move_player_*x, y, z, yaw, pitch, onGround, horizontalCollision (and hasPos, hasRot for the long form)
chat_commandcommand
chatmessage, timestamp, salt, signature, lastSeen
set_carried_itemslot
keep_aliveid
swinghand
set_healthhealth, food, saturation
set_experienceprogress, level, total
set_timegameTime, dayTime, tickDayTime
move_entity_*id, dx, dy, dz, yaw, pitch, onGround, hasRot, hasPos
teleport_entityid, change, relatives, onGround
add_entityid, uuid, type, x, y, z, movement, pitch, yaw, headYaw, data (or the older form with vx, vy, vz)