valence

repository·main·Indexed 25 days ago

https://github.com/valence-rs/valence

A Rust framework built on top of Bevy ECS for creating Minecraft: Java Edition servers from scratch. It acts as a game engine for Minecraft servers, providing a modular way to build custom experiences. The ecosystem includes crates for handling the anvil file format (valence_anvil), boss bars (valence_boss_bar), NBT encoding/decoding (valence_nbt), inventories (valence_inventory), and a command system with derive macros (valence_command_macros).

Tokens
27.2K
Snippets
58
Records
218
Agent score
85%

What's inside valence

  1. Understand the purpose of valence_generated

    main

    The valence_generated crate contains the majority of Valence's generated Rust code used for handling Minecraft's protocol and entity data.

    Note: This crate is currently intended to be an implementation detail of the valence_protocol and valence_entity crates. End-users should generally interact with those higher-level crates rather than using valence_generated directly.

  2. Use `java_string` for Java-compatible string handling

    main

    The java_string crate provides an implementation of Java strings that is tolerant of invalid UTF-16 encoding. This is specifically designed to allow for round-trip serialization of all Java strings, including those containing invalid UTF-16, while still permitting standard string operations.

    Key technical details:

    • Encoding: Uses a modified UTF-8 encoding called "semi-UTF-8". This encoding allows surrogate code points (U+D800 to U+DFFF inclusive), enabling zero-cost conversion from Rust strings to Java strings.
    • JavaCodePoint type: An analogue to Rust's char, but explicitly allows surrogate code points.
    • API Parity: Most methods are designed to be entirely analogous to the Rust standard library (std) string methods. For detailed documentation on specific method behaviors, refer to the Rust std documentation.
  3. Understand the role of `valence_network`

    main

    The valence_network crate is the plugin responsible for accepting network connections and spawning clients. It manages the initial stages of the protocol, specifically:

    • Handshaking
    • Status
    • Login

    It handles everything that occurs before the main Play stage begins. It also includes built-in support for proxies such as Velocity and BungeeCord.

    Note: valence_network is optional. You may choose to exclude it if you are using Valence for testing purposes or if you are integrating Valence as a server within a client.

  4. Use the playground for testing and bug reproduction

    main
    The playground tool provides an environment designed for testing code snippets or reproducing bugs within the Valence ecosystem. For detailed instructions on how to contribute or use this environment for development purposes, refer to the CONTRIBUTING.md file in the repository.