diff --git a/Cargo.lock b/Cargo.lock index ce1e60d14..28e90afa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1203,11 +1203,11 @@ dependencies = [ "num-bigint", "num-derive", "num-traits", + "pumpkin-core", "pumpkin-entity", "pumpkin-inventory", "pumpkin-protocol", "pumpkin-registry", - "pumpkin-text", "pumpkin-world", "rand", "rayon", @@ -1225,6 +1225,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "pumpkin-core" +version = "0.1.0" +dependencies = [ + "fastnbt", + "serde", + "uuid", +] + [[package]] name = "pumpkin-entity" version = "0.1.0" @@ -1264,8 +1273,8 @@ dependencies = [ "log", "num-derive", "num-traits", + "pumpkin-core", "pumpkin-macros", - "pumpkin-text", "pumpkin-world", "serde", "serde_json", @@ -1280,20 +1289,11 @@ version = "0.1.0" dependencies = [ "fastnbt", "fastsnbt", + "pumpkin-core", "pumpkin-protocol", - "pumpkin-text", "serde", ] -[[package]] -name = "pumpkin-text" -version = "0.1.0" -dependencies = [ - "fastnbt", - "serde", - "uuid", -] - [[package]] name = "pumpkin-world" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index c6564f7a0..26b8f75a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = [ "pumpkin-entity", "pumpkin-inventory", "pumpkin-macros/", "pumpkin-protocol/", "pumpkin-registry/", "pumpkin-world", "pumpkin/" ] +members = [ "pumpkin-core", "pumpkin-entity", "pumpkin-inventory", "pumpkin-macros/", "pumpkin-protocol/", "pumpkin-registry/", "pumpkin-world", "pumpkin/"] [workspace.package] version = "0.1.0" diff --git a/pumpkin-text/Cargo.toml b/pumpkin-core/Cargo.toml similarity index 90% rename from pumpkin-text/Cargo.toml rename to pumpkin-core/Cargo.toml index 727d06ccd..34ad5239d 100644 --- a/pumpkin-text/Cargo.toml +++ b/pumpkin-core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pumpkin-text" +name = "pumpkin-core" version.workspace = true edition.workspace = true diff --git a/pumpkin-core/src/lib.rs b/pumpkin-core/src/lib.rs new file mode 100644 index 000000000..481c63acc --- /dev/null +++ b/pumpkin-core/src/lib.rs @@ -0,0 +1 @@ +pub mod text; diff --git a/pumpkin-text/README.md b/pumpkin-core/src/text/_README.md similarity index 100% rename from pumpkin-text/README.md rename to pumpkin-core/src/text/_README.md diff --git a/pumpkin-text/src/click.rs b/pumpkin-core/src/text/click.rs similarity index 100% rename from pumpkin-text/src/click.rs rename to pumpkin-core/src/text/click.rs diff --git a/pumpkin-text/src/color.rs b/pumpkin-core/src/text/color.rs similarity index 100% rename from pumpkin-text/src/color.rs rename to pumpkin-core/src/text/color.rs diff --git a/pumpkin-text/src/hover.rs b/pumpkin-core/src/text/hover.rs similarity index 98% rename from pumpkin-text/src/hover.rs rename to pumpkin-core/src/text/hover.rs index 73bafd178..f01d8f30b 100644 --- a/pumpkin-text/src/hover.rs +++ b/pumpkin-core/src/text/hover.rs @@ -2,7 +2,7 @@ use std::borrow::Cow; use serde::{Deserialize, Serialize}; -use crate::Text; +use super::Text; #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(tag = "action", content = "contents", rename_all = "snake_case")] diff --git a/pumpkin-text/src/lib.rs b/pumpkin-core/src/text/mod.rs similarity index 100% rename from pumpkin-text/src/lib.rs rename to pumpkin-core/src/text/mod.rs diff --git a/pumpkin-text/src/style.rs b/pumpkin-core/src/text/style.rs similarity index 99% rename from pumpkin-text/src/style.rs rename to pumpkin-core/src/text/style.rs index 41a251243..f24bc8bea 100644 --- a/pumpkin-text/src/style.rs +++ b/pumpkin-core/src/text/style.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::{ +use super::{ click::ClickEvent, color::{self, Color}, hover::HoverEvent, diff --git a/pumpkin-protocol/Cargo.toml b/pumpkin-protocol/Cargo.toml index e9805fecb..f35275d96 100644 --- a/pumpkin-protocol/Cargo.toml +++ b/pumpkin-protocol/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true [dependencies] pumpkin-macros = { path = "../pumpkin-macros" } pumpkin-world = { path = "../pumpkin-world" } -pumpkin-text = { path = "../pumpkin-text" } +pumpkin-core = { path = "../pumpkin-core" } bytes = "1.7" diff --git a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs index ae8212aba..50f349886 100644 --- a/pumpkin-protocol/src/client/config/c_add_resource_pack.rs +++ b/pumpkin-protocol/src/client/config/c_add_resource_pack.rs @@ -1,5 +1,5 @@ use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; use crate::uuid::UUID; diff --git a/pumpkin-protocol/src/client/play/c_actionbar.rs b/pumpkin-protocol/src/client/play/c_actionbar.rs index fb8fe68ba..7c68ce805 100644 --- a/pumpkin-protocol/src/client/play/c_actionbar.rs +++ b/pumpkin-protocol/src/client/play/c_actionbar.rs @@ -1,5 +1,5 @@ +use pumpkin_core::text::TextComponent; use pumpkin_macros::packet; -use pumpkin_text::TextComponent; use serde::Serialize; #[derive(Serialize)] diff --git a/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs b/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs index 65b43b9b8..3647e2f64 100644 --- a/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_disguised_chat_message.rs @@ -1,5 +1,5 @@ use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; use crate::VarInt; diff --git a/pumpkin-protocol/src/client/play/c_open_screen.rs b/pumpkin-protocol/src/client/play/c_open_screen.rs index 7c5b07a22..5081d0b52 100644 --- a/pumpkin-protocol/src/client/play/c_open_screen.rs +++ b/pumpkin-protocol/src/client/play/c_open_screen.rs @@ -1,5 +1,5 @@ use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; use crate::VarInt; diff --git a/pumpkin-protocol/src/client/play/c_play_disconnect.rs b/pumpkin-protocol/src/client/play/c_play_disconnect.rs index dd861d732..7140e3f63 100644 --- a/pumpkin-protocol/src/client/play/c_play_disconnect.rs +++ b/pumpkin-protocol/src/client/play/c_play_disconnect.rs @@ -1,5 +1,5 @@ +use pumpkin_core::text::TextComponent; use pumpkin_macros::packet; -use pumpkin_text::TextComponent; use serde::Serialize; #[derive(Serialize)] diff --git a/pumpkin-protocol/src/client/play/c_player_chat_message.rs b/pumpkin-protocol/src/client/play/c_player_chat_message.rs index 03f2160b5..712538615 100644 --- a/pumpkin-protocol/src/client/play/c_player_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_player_chat_message.rs @@ -1,7 +1,7 @@ use num_derive::{FromPrimitive, ToPrimitive}; use num_traits::FromPrimitive; use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; use crate::{bytebuf::ByteBuffer, uuid::UUID, BitSet, ClientPacket, VarInt}; diff --git a/pumpkin-protocol/src/client/play/c_set_title.rs b/pumpkin-protocol/src/client/play/c_set_title.rs index 4e043da0f..b18b46ded 100644 --- a/pumpkin-protocol/src/client/play/c_set_title.rs +++ b/pumpkin-protocol/src/client/play/c_set_title.rs @@ -1,5 +1,5 @@ use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; #[derive(Serialize)] diff --git a/pumpkin-protocol/src/client/play/c_subtitle.rs b/pumpkin-protocol/src/client/play/c_subtitle.rs index 10f86d1ef..0d8fed039 100644 --- a/pumpkin-protocol/src/client/play/c_subtitle.rs +++ b/pumpkin-protocol/src/client/play/c_subtitle.rs @@ -1,5 +1,5 @@ use pumpkin_macros::packet; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use serde::Serialize; #[derive(Serialize)] diff --git a/pumpkin-protocol/src/client/play/c_system_chat_message.rs b/pumpkin-protocol/src/client/play/c_system_chat_message.rs index fd88e622a..a0f2342d1 100644 --- a/pumpkin-protocol/src/client/play/c_system_chat_message.rs +++ b/pumpkin-protocol/src/client/play/c_system_chat_message.rs @@ -1,5 +1,5 @@ +use pumpkin_core::text::TextComponent; use pumpkin_macros::packet; -use pumpkin_text::TextComponent; use serde::Serialize; #[derive(Serialize)] diff --git a/pumpkin-protocol/src/slot.rs b/pumpkin-protocol/src/slot.rs index 22223f3b4..6685ec207 100644 --- a/pumpkin-protocol/src/slot.rs +++ b/pumpkin-protocol/src/slot.rs @@ -1,7 +1,7 @@ use crate::VarInt; use pumpkin_world::item::Item; use serde::{ - de::{self, SeqAccess, Visitor}, + de::{self, SeqAccess}, Deserialize, }; @@ -21,8 +21,8 @@ impl<'de> Deserialize<'de> for Slot { where D: de::Deserializer<'de>, { - struct VarIntVisitor; - impl<'de> Visitor<'de> for VarIntVisitor { + struct Visitor; + impl<'de> de::Visitor<'de> for Visitor { type Value = Slot; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -72,9 +72,10 @@ impl<'de> Deserialize<'de> for Slot { } } - deserializer.deserialize_seq(VarIntVisitor) + deserializer.deserialize_seq(Visitor) } } + impl Slot { pub fn to_item(self) -> Option { let item_id = self.item_id?.0.try_into().unwrap(); diff --git a/pumpkin-registry/Cargo.toml b/pumpkin-registry/Cargo.toml index 3087a0ec3..f1e53cba3 100644 --- a/pumpkin-registry/Cargo.toml +++ b/pumpkin-registry/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true [dependencies] pumpkin-protocol = { path = "../pumpkin-protocol"} -pumpkin-text = { path = "../pumpkin-text"} +pumpkin-core = { path = "../pumpkin-core"} # nbt fastnbt = { git = "https://github.com/owengage/fastnbt.git" } diff --git a/pumpkin-registry/src/chat_type.rs b/pumpkin-registry/src/chat_type.rs index e5d533527..647c89dd1 100644 --- a/pumpkin-registry/src/chat_type.rs +++ b/pumpkin-registry/src/chat_type.rs @@ -1,4 +1,4 @@ -use pumpkin_text::style::Style; +use pumpkin_core::text::style::Style; use serde::Serialize; #[derive(Debug, Clone, Serialize)] diff --git a/pumpkin/Cargo.toml b/pumpkin/Cargo.toml index bbbced5c3..c6d12a44c 100644 --- a/pumpkin/Cargo.toml +++ b/pumpkin/Cargo.toml @@ -13,7 +13,7 @@ dhat-heap = ["dhat"] dhat = { version = "0.3.3", optional = true } # pumpkin -pumpkin-text = { path = "../pumpkin-text" } +pumpkin-core = { path = "../pumpkin-core"} pumpkin-inventory = { path = "../pumpkin-inventory"} pumpkin-world = { path = "../pumpkin-world"} pumpkin-entity = { path = "../pumpkin-entity"} diff --git a/pumpkin/src/client/client_packet.rs b/pumpkin/src/client/client_packet.rs index 7be9a4d1d..a9e4f4928 100644 --- a/pumpkin/src/client/client_packet.rs +++ b/pumpkin/src/client/client_packet.rs @@ -13,7 +13,7 @@ use pumpkin_protocol::{ }, ConnectionState, KnownPack, CURRENT_MC_PROTOCOL, }; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use rsa::Pkcs1v15Encrypt; use sha1::{Digest, Sha1}; diff --git a/pumpkin/src/client/mod.rs b/pumpkin/src/client/mod.rs index 837976873..339ea3856 100644 --- a/pumpkin/src/client/mod.rs +++ b/pumpkin/src/client/mod.rs @@ -36,7 +36,7 @@ use pumpkin_protocol::{ }, ClientPacket, ConnectionState, PacketError, RawPacket, ServerPacket, }; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use std::io::Read; use thiserror::Error; diff --git a/pumpkin/src/client/player_packet.rs b/pumpkin/src/client/player_packet.rs index bd040469d..d5d29539f 100644 --- a/pumpkin/src/client/player_packet.rs +++ b/pumpkin/src/client/player_packet.rs @@ -22,7 +22,7 @@ use pumpkin_protocol::{ SUseItemOn, Status, }, }; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use pumpkin_world::block::BlockFace; use pumpkin_world::global_registry; diff --git a/pumpkin/src/commands/cmd_gamemode.rs b/pumpkin/src/commands/cmd_gamemode.rs index b054fdc24..526ac9e56 100644 --- a/pumpkin/src/commands/cmd_gamemode.rs +++ b/pumpkin/src/commands/cmd_gamemode.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use num_traits::FromPrimitive; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use crate::commands::arg_player::{consume_arg_player, parse_arg_player}; diff --git a/pumpkin/src/commands/cmd_help.rs b/pumpkin/src/commands/cmd_help.rs index 7ffa733c1..893f19568 100644 --- a/pumpkin/src/commands/cmd_help.rs +++ b/pumpkin/src/commands/cmd_help.rs @@ -3,7 +3,7 @@ use crate::commands::dispatcher::{CommandDispatcher, InvalidTreeError}; use crate::commands::tree::{CommandTree, ConsumedArgs, RawArgs}; use crate::commands::tree_builder::argument; use crate::commands::{dispatcher_init, CommandSender, DISPATCHER}; -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; pub(crate) const NAME: &str = "help"; pub(crate) const ALIAS: &str = "?"; diff --git a/pumpkin/src/commands/cmd_pumpkin.rs b/pumpkin/src/commands/cmd_pumpkin.rs index cbbac0680..25d515791 100644 --- a/pumpkin/src/commands/cmd_pumpkin.rs +++ b/pumpkin/src/commands/cmd_pumpkin.rs @@ -1,6 +1,6 @@ use crate::server::CURRENT_MC_VERSION; +use pumpkin_core::text::{color::NamedColor, TextComponent}; use pumpkin_protocol::CURRENT_MC_PROTOCOL; -use pumpkin_text::{color::NamedColor, TextComponent}; use crate::commands::tree::CommandTree; diff --git a/pumpkin/src/commands/mod.rs b/pumpkin/src/commands/mod.rs index c622691d6..0dfa5483f 100644 --- a/pumpkin/src/commands/mod.rs +++ b/pumpkin/src/commands/mod.rs @@ -1,4 +1,4 @@ -use pumpkin_text::TextComponent; +use pumpkin_core::text::TextComponent; use std::collections::HashMap; use std::sync::OnceLock; @@ -86,7 +86,7 @@ pub fn handle_command(sender: &mut CommandSender, cmd: &str) { if let Err(err) = dispatcher.dispatch(sender, cmd) { sender.send_message( - TextComponent::text(&err).color_named(pumpkin_text::color::NamedColor::Red), + TextComponent::text(&err).color_named(pumpkin_core::text::color::NamedColor::Red), ) } }