Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Implement all packets for protocol 757 #3

@Iapetus-11

Description

@Iapetus-11

Once base packet class is done, start creating all the packets. These packets should go under pymine_net/packets/757/<state> and should be subclasses of src.types.packet.ServerBoundPacket or src.types.packet.ClientBoundPacket. For a list of all the packets, look here: https://wiki.vg/Protocol (Important: this link displays the most recent versions protocol, to view a specific version go here)

Packet Making Guide

Naming

  • Packets are named by their state and name on wiki.vg
    Examples: class PlayUpdateLight or class HandshakeHandshake or class PlayPlayerPosition

Creation

  • Packets should have one class attribute (id), a docstring describing them and any other instance variables, an __init__, and an unpack or pack method (or both)
  • Packets need to subclass ServerBoundPacket or ClientBoundPacket and call super().__init__()
    Example:
class TestExample(ServerBoundPacket, ClientBoundPacket):
  """This is an example packet, not used at all. (Client <-> Server)

  :param str dummy_payload: The payload of the packet.
  :attr int id: Unique packet ID.
  :attr dummy_payload:
  """

  id = 0x00  # ID of the packet, found on wiki.vg in the section where there's info on the packet

  def __init__(self, dummy_payload: str):
    super().__init__()

    self.dummy_payload = dummy_payload

  def encode(self) -> Buffer:
    return Buffer().write_string(self.dummy_payload)

  @classmethod
  def decode(cls, buf: Buffer) -> TestExample:
    return cls(buf.read_string())

Additional Info:

  • Packet docstrings should be in the sphinx format, they can be generated via a plugin for atom or vscode.
  • Docstrings, on the first line, should contain the short summary, any additional links/info, and in parentheses the direction(s) of the packet.
  • Remember to add the name of the packet to the file's __all__ (located near the top of the file, after imports)
  • If you can't find the right file to place your packet, you can create a new one. Remember to add from __future__ import annotations to allow for return typehints to be the class itself, and to add an __all__.
  • Make sure the packet name and ID are correct before commiting, as some have changed since 754.

Progress Checklist (By States)

  • handshake packets
  • status packets
  • login packets
  • play packets

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions