-
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
162 additions
and
141 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "pumpkin-text" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
fastnbt = { git = "https://github.com/owengage/fastnbt.git" } | ||
uuid = "1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Action to take on click of the text. | ||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)] | ||
#[serde(tag = "action", content = "value", rename_all = "snake_case")] | ||
pub enum ClickEvent { | ||
/// Opens an URL | ||
OpenUrl(String), | ||
/// Works in signs, but only on the root text component | ||
RunCommand(String), | ||
/// Replaces the contents of the chat box with the text, not necessarily a | ||
/// command. | ||
SuggestCommand(String), | ||
/// Only usable within written books. Changes the page of the book. Indexing | ||
/// starts at 1. | ||
ChangePage(i32), | ||
/// Copies the given text to system clipboard | ||
CopyToClipboard(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Text color | ||
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize)] | ||
#[serde(untagged)] | ||
pub enum Color { | ||
/// The default color for the text will be used, which varies by context | ||
/// (in some cases, it's white; in others, it's black; in still others, it | ||
/// is a shade of gray that isn't normally used on text). | ||
#[default] | ||
Reset, | ||
/// One of the 16 named Minecraft colors | ||
Named(NamedColor), | ||
} | ||
|
||
/// Named Minecraft color | ||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum NamedColor { | ||
Black = 0, | ||
DarkBlue, | ||
DarkGreen, | ||
DarkAqua, | ||
DarkRed, | ||
DarkPurple, | ||
Gold, | ||
Gray, | ||
DarkGray, | ||
Blue, | ||
Green, | ||
Aqua, | ||
Red, | ||
LightPurple, | ||
Yellow, | ||
White, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::Text; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
#[serde(tag = "action", content = "contents", rename_all = "snake_case")] | ||
#[allow(clippy::enum_variant_names)] | ||
pub enum HoverEvent { | ||
/// Displays a tooltip with the given text. | ||
ShowText(Text), | ||
/// Shows an item. | ||
ShowItem { | ||
/// Resource identifier of the item | ||
id: String, | ||
/// Number of the items in the stack | ||
count: Option<i32>, | ||
/// NBT information about the item (sNBT format) | ||
tag: String, | ||
}, | ||
/// Shows an entity. | ||
ShowEntity { | ||
/// The entity's UUID | ||
id: uuid::Uuid, | ||
/// Resource identifier of the entity | ||
#[serde(rename = "type")] | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
kind: Option<String>, | ||
/// Optional custom name for the entity | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
name: Option<Text>, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.