-
Notifications
You must be signed in to change notification settings - Fork 65
Craft.Net Networking
Craft.Net can be used to parse the Minecraft protocol and handle a few related tasks.
All packets are defined in Packets.cs and inherit from IPacket (defined in the same file). Packets include ReadPacket(MinecraftStream)
for reading them (does not include packet ID), as well as WritePacket(MinecraftStream)
for writing them (includes packet ID). You can use PacketReader to read and produce fully populated packet objects. Additionally, various streams are included. MinecraftStream is split into two files - MinecraftStream.cs, which only includes methods to read/write Minecraft data types, and MinecraftStream.Stream.cs, which includes abstract members of System.IO.Stream.
Various streams are included to make things easier, and they are intended to be nested.
- MinecraftStream: Used to read/write Minecraft data types. Used by all packets.
- BufferedStream: Unlike System.IO.BufferedStream, this simply queues up all writes until Flush() is called.
- AesStream: Encrypts on write and decrypts on read with AES/CFB.
Crypto utilities are included:
- Cryptography.JavaHexDigest for getting Minecraft-style SHA-1 hex digests, which are used for communicating with minecraft.net for authentication
- AsnKeyBuilder and AsnKeyParser for working with ASN X.509 certificates
- AesStream for encrypting or decrypting streams
ItemStacks hold some amount of the same item. They include an ID, count, metadata, and NBT. These represent things like items in an inventory, or item entities.
MetadataDictionary is used to represent entity metadata for network communication in the Entity Metadata Format.