kyori-component-json
Minecraft text formatting made easy
A simple Rust library for creating and working with Minecraft's JSON text components (Java Edition 1.21.5+). This is the same system used in commands like /tellraw, books, signs, and more!
What can you do with this?
Mainly:
- Create tooling around Minecraft clients and servers easily
- Easier interop between Rust objects and Minecraft's text component format
But it also empowers you to:
- Create colorful chat messages with formatting (bold, italic, etc.)
- Add clickable text that runs commands when clicked
- Make hover text that shows extra information
When would you use this?
- Command Generators: Create
/tellrawor/titlecommands programmatically - Custom UIs: Make interactive books or signs
- Data Packs: Generate dynamic text components
Simple Examples
Basic Colored Text
use *;
let message = text
.color
.decoration;
// Use in /tellraw command:
// /tellraw @a {"text":"Hello Minecraft!","color":"red","bold":true}
Clickable Text
let clickable = text
.click_event
.hover_event;
Combining Components
let combined = text
.append
More Advanced Example
// Create a formatted message with multiple parts
let message = text
.color
.append
Learning More
- Minecraft Wiki: Raw JSON Text
- Library documentation: https://docs.rs/kyori-component-json or
cargo doc --open --no-deps
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Contributions are welcome! Please feel free to submit a pull request.