Skip to content

Commit

Permalink
Create pumpkin-core, and move pumpkin-text
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas0008 committed Aug 21, 2024
1 parent 5d023e6 commit 8eb894e
Show file tree
Hide file tree
Showing 31 changed files with 43 additions and 41 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-text/Cargo.toml → pumpkin-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "pumpkin-text"
name = "pumpkin-core"
version.workspace = true
edition.workspace = true

Expand Down
1 change: 1 addition & 0 deletions pumpkin-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod text;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize};

use crate::{
use super::{
click::ClickEvent,
color::{self, Color},
hover::HoverEvent,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/config/c_add_resource_pack.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use serde::Serialize;

use crate::uuid::UUID;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_actionbar.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_core::text::TextComponent;
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use serde::Serialize;

use crate::VarInt;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_open_screen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use serde::Serialize;

use crate::VarInt;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_play_disconnect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_core::text::TextComponent;
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_player_chat_message.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_set_title.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_subtitle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_system_chat_message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use pumpkin_core::text::TextComponent;
use pumpkin_macros::packet;
use pumpkin_text::TextComponent;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
9 changes: 5 additions & 4 deletions pumpkin-protocol/src/slot.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::VarInt;
use pumpkin_world::item::Item;
use serde::{
de::{self, SeqAccess, Visitor},
de::{self, SeqAccess},
Deserialize,
};

Expand All @@ -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 {
Expand Down Expand Up @@ -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<Item> {
let item_id = self.item_id?.0.try_into().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-registry/src/chat_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pumpkin_text::style::Style;
use pumpkin_core::text::style::Style;
use serde::Serialize;

#[derive(Debug, Clone, Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/client/client_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/commands/cmd_gamemode.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/commands/cmd_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "?";
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/commands/cmd_pumpkin.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 2 additions & 2 deletions pumpkin/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pumpkin_text::TextComponent;
use pumpkin_core::text::TextComponent;
use std::collections::HashMap;
use std::sync::OnceLock;

Expand Down Expand Up @@ -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),
)
}
}

0 comments on commit 8eb894e

Please sign in to comment.