chore: bit of crate decouple

This commit is contained in:
Alexander Medvedev 2026-09-08 21:38:39 +02:00
parent 23542ea9d1
commit a83f6b7c66
136 changed files with 1115 additions and 505 deletions

36
Cargo.lock generated
View File

@ -3355,6 +3355,7 @@ dependencies = [
"num-bigint 0.5.1",
"ordered-float",
"postcard",
"pumpkin-auth",
"pumpkin-command",
"pumpkin-config",
"pumpkin-data",
@ -3395,6 +3396,7 @@ dependencies = [
"wasmtime-wasi",
"wasmtime-wasi-http",
"webrtc",
"xxhash-rust",
]
[[package]]
@ -3407,6 +3409,27 @@ dependencies = [
"syn 3.0.5",
]
[[package]]
name = "pumpkin-auth"
version = "0.1.0+26.2-26.45"
dependencies = [
"base64 0.23.1",
"crypto-bigint 0.7.5",
"ecdsa 0.17.0",
"md5",
"p384 0.14.0",
"pumpkin-util",
"reqwest",
"rsa",
"rustls",
"serde",
"serde_json",
"sha2 0.11.0",
"thiserror 2.0.20",
"uuid",
"webpki-root-certs",
]
[[package]]
name = "pumpkin-codecs"
version = "0.1.0+26.2-26.45"
@ -3507,7 +3530,6 @@ dependencies = [
"pumpkin-nbt",
"pumpkin-protocol",
"pumpkin-util",
"pumpkin-world",
"rand",
"rustc-hash",
"thiserror 2.0.20",
@ -3521,7 +3543,6 @@ dependencies = [
"heck",
"proc-macro-error2",
"proc-macro2",
"pumpkin-data",
"quote",
"syn 3.0.5",
]
@ -3585,6 +3606,7 @@ version = "0.1.0+26.2-26.45"
dependencies = [
"aes 0.9.3",
"async-compression",
"base64 0.23.1",
"bitflags 2.13.1",
"bytes",
"cesu8",
@ -3595,7 +3617,6 @@ dependencies = [
"pumpkin-macros",
"pumpkin-nbt",
"pumpkin-util",
"pumpkin-world",
"serde",
"serde_json",
"thiserror 2.0.20",
@ -3608,31 +3629,22 @@ dependencies = [
name = "pumpkin-util"
version = "0.1.0+26.2-26.45"
dependencies = [
"base64 0.23.1",
"bytes",
"colored",
"criterion",
"crypto-bigint 0.7.5",
"dashmap",
"ecdsa 0.17.0",
"md5",
"num-derive",
"num-traits",
"p384 0.14.0",
"proc-macro2",
"pumpkin-codecs",
"pumpkin-nbt",
"quote",
"reqwest",
"rsa",
"rustls",
"serde",
"serde_json",
"sha2 0.11.0",
"syn 3.0.5",
"thiserror 2.0.20",
"uuid",
"webpki-root-certs",
]
[[package]]

View File

@ -3,6 +3,7 @@ resolver = "3"
members = [
"crates/pumpkin",
"crates/pumpkin-api-macros",
"crates/pumpkin-auth",
"crates/pumpkin-codecs",
"crates/pumpkin-command",
"crates/pumpkin-config",
@ -176,6 +177,8 @@ num-traits = { version = "0.2", default-features = false, features = ["std"] }
p384 = { version = "0.14.0", default-features = false, features = ["std", "arithmetic", "pkcs8"] }
phf = { version = "0.14.0", default-features = false, features = ["std"] }
proc-macro2 = { version = "1.0", default-features = false, features = ["proc-macro"] }
pumpkin-api-macros = { path = "crates/pumpkin-api-macros", default-features = false }
pumpkin-auth = { path = "crates/pumpkin-auth", default-features = false }
pumpkin-codecs = { path = "crates/pumpkin-codecs", default-features = false }
pumpkin-command = { path = "crates/pumpkin-command", default-features = false }
pumpkin-config = { path = "crates/pumpkin-config", default-features = false }

View File

@ -0,0 +1,29 @@
[package]
name = "pumpkin-auth"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
[dependencies]
pumpkin-util.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
base64.workspace = true
uuid.workspace = true
md5.workspace = true
p384 = { workspace = true, features = ["ecdsa"] }
ecdsa.workspace = true
rsa.workspace = true
sha2.workspace = true
crypto-bigint.workspace = true
reqwest.workspace = true
rustls.workspace = true
webpki-root-certs.workspace = true
[lints]
workspace = true

View File

@ -0,0 +1,10 @@
//! Authentication and HTTP client utilities for Pumpkin.
#![deny(clippy::unwrap_used)]
#![cfg_attr(test, allow(clippy::unwrap_used, clippy::panic))]
pub mod client;
pub mod jwt;
pub use client::{client, client_builder};
pub use p384;

View File

@ -12,6 +12,8 @@ pub struct ProxyConfig {
pub velocity: VelocityConfig,
/// Configuration for `BungeeCord` proxy integration.
pub bungeecord: BungeeCordConfig,
/// Configuration for Vine modern proxy integration with Ed25519 authentication.
pub vine: VineConfig,
}
/// Configuration for `BungeeCord` proxy integration.
@ -37,3 +39,17 @@ pub struct VelocityConfig {
/// Shared secret for authenticating connections from the Velocity proxy.
pub secret: String,
}
/// Configuration for Vine proxy integration with Ed25519 authentication and replay protection.
#[derive(Deserialize, Serialize, Default, Clone)]
#[serde(default)]
pub struct VineConfig {
/// Whether Vine support is enabled.
pub enabled: bool,
/// Ed25519 public key (64 hex characters) of the Vine proxy.
/// Backend only needs this public key to verify forwarded player identities.
pub public_key: String,
/// Optional shared secret string. If provided and `public_key` is empty,
/// the public key is automatically derived from this secret.
pub secret: String,
}

View File

@ -361,6 +361,20 @@ impl From<BlockId> for u16 {
}
}
impl From<Block> for BlockId {
#[inline]
fn from(value: Block) -> Self {
value.id
}
}
impl From<&Block> for BlockId {
#[inline]
fn from(value: &Block) -> Self {
value.id
}
}
impl Default for BlockId {
#[inline]
fn default() -> Self {

View File

@ -19,7 +19,6 @@ pumpkin-data = { workspace = true, features = [
"statistic",
] }
pumpkin-world.workspace = true
pumpkin-util.workspace = true
pumpkin-nbt.workspace = true

View File

@ -3,13 +3,13 @@ use std::borrow::Cow;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicI32, AtomicU8, Ordering};
use crate::inventory::Inventory;
use pumpkin_data::Enchantment;
use pumpkin_data::data_component::DataComponent;
use pumpkin_data::data_component_impl::{EnchantmentsImpl, StoredEnchantmentsImpl};
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::screen::WindowType;
use pumpkin_world::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,
@ -559,11 +559,11 @@ impl ScreenHandler for AnvilScreenHandler {
mod tests {
use super::*;
use crate::entity_equipment::EntityEquipment;
use crate::inventory::SimpleInventory;
use pumpkin_protocol::java::client::play::{
CSetContainerContent, CSetContainerProperty, CSetContainerSlot, CSetCursorItem,
CSetPlayerInventory, CSetSelectedSlot,
};
use pumpkin_world::inventory::SimpleInventory;
use std::sync::Mutex;
use std::sync::atomic::AtomicI32;

View File

@ -1,7 +1,7 @@
use std::{any::Any, sync::Arc};
use crate::inventory::Inventory;
use pumpkin_data::{item_stack::ItemStack, screen::WindowType};
use pumpkin_world::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,

View File

@ -2,13 +2,13 @@ use std::any::Any;
use std::sync::Arc;
use std::sync::atomic::{AtomicU8, Ordering};
use crate::inventory::Inventory;
use crate::window_property::PropertyDelegate;
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::potion_brewing::{ITEM_RECIPES, POTION_RECIPES};
use pumpkin_data::screen::WindowType;
use pumpkin_data::tag::{self, Taggable};
use pumpkin_world::block::entities::PropertyDelegate;
use pumpkin_world::inventory::Inventory;
use crate::player::player_inventory::PlayerInventory;
use crate::screen_handler::{

View File

@ -6,14 +6,14 @@ use crate::player::player_inventory::PlayerInventory;
use crate::screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour};
use crate::slot::Slot;
use crate::inventory::Inventory;
use crate::inventory::SimpleInventory;
use pumpkin_data::data_component_impl::{MapIdImpl, MapPostProcessingImpl};
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::screen::WindowType;
use pumpkin_data::statistic::StatisticCategory;
use pumpkin_protocol::java::server::play::SlotActionType;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::inventory::SimpleInventory;
#[must_use]
pub fn is_map_item(stack: &ItemStack) -> bool {

View File

@ -12,8 +12,8 @@
use std::any::Any;
use std::sync::RwLock;
use crate::inventory::{Clearable, Inventory};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::{Clearable, Inventory};
use super::recipes::RecipeInputInventory;

View File

@ -27,6 +27,7 @@ use crate::screen_handler::{
};
use crate::slot::{NormalSlot, Slot};
use crate::inventory::Inventory;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::recipes::{CraftingRecipeTypes, RECIPES_CRAFTING};
use pumpkin_data::screen::WindowType;
@ -34,7 +35,6 @@ use pumpkin_data::statistic::StatisticCategory;
use pumpkin_data::tag;
use pumpkin_data::tag::Taggable;
use pumpkin_protocol::codec::recipe::{DynamicRecipe, OwnedCraftingRecipe};
use pumpkin_world::inventory::Inventory;
/// The result slot in a crafting screen.
pub struct ResultSlot {

View File

@ -12,7 +12,7 @@
//! - [`RecipeMatcher`] - Helper for matching items to recipes
//! - [`RecipeFinder`] - Helper for finding recipes
use pumpkin_world::inventory::Inventory;
use crate::inventory::Inventory;
/// Helper struct for matching recipe ingredients.
// RecipeMatcher.java

View File

@ -10,8 +10,8 @@
use std::{any::Any, sync::Arc};
use crate::inventory::{Clearable, Inventory};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::{Clearable, Inventory};
/// A composite inventory combining two inventories.
///

View File

@ -1,6 +1,7 @@
use std::any::Any;
use std::sync::Arc;
use crate::inventory::Inventory;
use pumpkin_data::Enchantment;
use pumpkin_data::data_component_impl::EnchantableImpl;
use pumpkin_data::item::Item;
@ -10,7 +11,6 @@ use pumpkin_data::sound::Sound;
use pumpkin_data::statistic::{CustomStatistic, StatisticCategory};
use pumpkin_data::tag::{Enchantment as EnchantmentTag, Taggable};
use pumpkin_util::random::{RandomImpl, legacy_rand::LegacyRand};
use pumpkin_world::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,

View File

@ -1,14 +1,14 @@
use std::any::Any;
use std::sync::Arc;
use crate::{
inventory::Inventory,
window_property::{ExperienceContainer, PropertyDelegate},
};
use pumpkin_data::fuels::is_fuel;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::recipes::{CookingRecipeKind, CookingRecipeType};
use pumpkin_data::screen::WindowType;
use pumpkin_world::{
block::entities::{ExperienceContainer, PropertyDelegate},
inventory::Inventory,
};
use crate::{
player::player_inventory::PlayerInventory,

View File

@ -8,8 +8,8 @@
use std::sync::{Arc, atomic::AtomicU8};
use crate::{inventory::Inventory, window_property::ExperienceContainer};
use pumpkin_data::{fuels::is_fuel, item::Item, statistic::StatisticCategory};
use pumpkin_world::{block::entities::ExperienceContainer, inventory::Inventory};
use tracing::debug;

View File

@ -11,8 +11,8 @@
use std::{any::Any, sync::Arc};
use crate::inventory::Inventory;
use pumpkin_data::{item_stack::ItemStack, screen::WindowType};
use pumpkin_world::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,

View File

@ -3,6 +3,7 @@ use std::borrow::Cow;
use std::sync::Arc;
use std::sync::atomic::{AtomicU8, Ordering};
use crate::inventory::Inventory;
use pumpkin_data::data_component::DataComponent;
use pumpkin_data::data_component_impl::{EnchantmentsImpl, MaxDamageImpl, StoredEnchantmentsImpl};
use pumpkin_data::enchantment::Enchantment;
@ -12,7 +13,6 @@ use pumpkin_data::screen::WindowType;
use pumpkin_data::tag::Enchantment as EnchantmentTag;
use pumpkin_data::tag::Taggable;
use pumpkin_protocol::java::server::play::SlotActionType;
use pumpkin_world::inventory::Inventory;
use crate::{
anvil::anvil_screen_handler::calculate_increased_repair_cost,

View File

@ -1,10 +1,10 @@
use crate::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,
screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour},
slot::NormalSlot,
};
use pumpkin_data::{item_stack::ItemStack, screen::WindowType};
use pumpkin_world::inventory::Inventory;
use std::{any::Any, sync::Arc};
/// Builder for custom GUIs.

View File

@ -6,10 +6,10 @@ use crate::screen_handler::{
};
use crate::slot::NormalSlot;
use crate::inventory::Inventory;
use crate::window_property::PropertyDelegate;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::screen::WindowType;
use pumpkin_world::block::entities::PropertyDelegate;
use pumpkin_world::inventory::Inventory;
/// Callbacks into the lectern block so page turns and book removal can drive
/// block-state changes (redstone pulse, `has_book`) that live outside this crate.

View File

@ -27,7 +27,7 @@
//! - [`sync_handler`] - Client-server inventory synchronization
//! - [`window_property`] - Container UI properties (furnace progress, enchantment levels, etc.)
//!
//! [`Inventory`]: pumpkin_world::inventory::Inventory
//! [`Inventory`]: inventory::Inventory
//! [`ScreenHandler`]: screen_handler::ScreenHandler
//! [`Slot`]: slot::Slot
//! [`PlayerInventory`]: PlayerInventory
@ -48,6 +48,7 @@ pub mod furnace_like;
pub mod generic_container_screen_handler;
pub mod grindstone_screen_handler;
pub mod gui_builder;
pub mod inventory;
pub mod lectern_screen_handler;
pub mod loom_screen_handler;
pub mod merchant;
@ -58,12 +59,19 @@ pub mod slot;
pub mod smithing_table_screen_handler;
pub mod stonecutter_screen_handler;
pub mod sync_handler;
pub mod viewer;
pub mod window_property;
use rustc_hash::FxHashMap;
pub use error::InventoryError;
pub use inventory::{
Clearable, ComparableInventory, Inventory, SimpleInventory, split_stack_slice,
sync_read_items_from_nbt, sync_write_items_to_nbt,
};
use pumpkin_data::data_component_impl::EquipmentSlot;
pub use viewer::ViewerCountTracker;
pub use window_property::{ExperienceContainer, PropertyDelegate};
use crate::player::player_inventory::PlayerInventory;

View File

@ -8,6 +8,9 @@ use crate::screen_handler::{
};
use crate::slot::Slot;
use crate::inventory::Inventory;
use crate::inventory::SimpleInventory;
use crate::window_property::PropertyDelegate;
use pumpkin_data::data_component_impl::{BannerPatternLayer, BannerPatternsImpl};
use pumpkin_data::dye_color::DyeColor;
use pumpkin_data::item::Item;
@ -16,9 +19,6 @@ use pumpkin_data::screen::WindowType;
use pumpkin_data::statistic::StatisticCategory;
use pumpkin_data::tag::{BannerPattern, RegistryKey, get_tag_values};
use pumpkin_protocol::java::server::play::SlotActionType;
use pumpkin_world::block::entities::PropertyDelegate;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::inventory::SimpleInventory;
pub const NO_ITEM_REQUIRED_PATTERNS: &[&str] = BannerPattern::MINECRAFT_NO_ITEM_REQUIRED.0;

View File

@ -6,12 +6,12 @@ use std::{
},
};
use crate::inventory::Inventory;
use pumpkin_data::{
item_stack::ItemStack,
screen::WindowType,
statistic::{CustomStatistic, StatisticCategory},
};
use pumpkin_world::inventory::Inventory;
use crate::{
player::player_inventory::PlayerInventory,
@ -495,6 +495,7 @@ mod tests {
sync::atomic::{AtomicI32, AtomicUsize, Ordering},
};
use crate::inventory::SimpleInventory;
use pumpkin_data::{data_component_impl::EquipmentSlot, item::Item};
use pumpkin_protocol::{
codec::item_stack_seralizer::ItemStackSerializer,
@ -506,7 +507,6 @@ mod tests {
server::play::SlotActionType,
},
};
use pumpkin_world::inventory::SimpleInventory;
use std::sync::Mutex;
use crate::{entity_equipment::EntityEquipment, screen_handler::InventoryPlayer};

View File

@ -1,9 +1,9 @@
use std::any::Any;
use std::sync::Arc;
use crate::inventory::Inventory;
use pumpkin_data::data_component_impl::EquipmentSlot;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::Inventory;
use crate::player::player_inventory::PlayerInventory;
use crate::screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour};

View File

@ -13,11 +13,11 @@
use std::any::Any;
use std::sync::{Arc, Mutex, RwLock};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::{
block::viewer::ViewerCountTracker,
use crate::{
inventory::{Clearable, Inventory},
viewer::ViewerCountTracker,
};
use pumpkin_data::item_stack::ItemStack;
/// A player's ender chest inventory.
///

View File

@ -10,12 +10,12 @@
use crate::entity_equipment::EntityEquipment;
use crate::screen_handler::InventoryPlayer;
use crate::inventory::{Clearable, Inventory};
use pumpkin_data::data_component_impl::EquipmentSlot;
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_protocol::java::client::play::CSetPlayerInventory;
use pumpkin_util::Hand;
use pumpkin_world::inventory::{Clearable, Inventory};
use rustc_hash::FxHashMap;
use std::any::Any;
use std::sync::atomic::{AtomicU8, Ordering};

View File

@ -22,12 +22,12 @@ use super::player_inventory::PlayerInventory;
use crate::crafting::crafting_inventory::CraftingInventory;
use crate::crafting::crafting_screen_handler::CraftingScreenHandler;
use crate::crafting::recipes::{RecipeFinderScreenHandler, RecipeInputInventory};
use crate::inventory::Inventory;
use crate::screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour};
use crate::slot::{ArmorSlot, NormalSlot, Slot};
use pumpkin_data::data_component_impl::{EquipmentSlot, EquipmentType, EquippableImpl};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::screen::WindowType;
use pumpkin_world::inventory::Inventory;
use std::any::Any;
use std::sync::Arc;

View File

@ -31,6 +31,10 @@ use crate::{
slot::{NormalSlot, Slot},
sync_handler::{SyncHandler, TrackedStack},
};
use crate::{
inventory::{ComparableInventory, Inventory},
window_property::PropertyDelegate,
};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::{
Enchantment,
@ -50,10 +54,6 @@ use pumpkin_protocol::{
},
};
use pumpkin_util::text::TextComponent;
use pumpkin_world::{
block::entities::PropertyDelegate,
inventory::{ComparableInventory, Inventory},
};
use std::cmp::max;
use std::sync::Mutex;
use std::sync::atomic::{AtomicU32, Ordering};

View File

@ -25,10 +25,10 @@ use std::sync::{
use crate::screen_handler::InventoryPlayer;
use crate::inventory::Inventory;
use pumpkin_data::data_component_impl::EquipmentSlot;
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::Inventory;
/// A slot in an inventory.
///

View File

@ -6,6 +6,8 @@ use crate::player::player_inventory::PlayerInventory;
use crate::screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour};
use crate::slot::{NormalSlot, Slot};
use crate::inventory::Inventory;
use crate::inventory::SimpleInventory;
use pumpkin_data::data_component_impl::TrimImpl;
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
@ -16,8 +18,6 @@ use pumpkin_data::screen::WindowType;
use pumpkin_data::statistic::StatisticCategory;
use pumpkin_nbt::tag::NbtTag;
use pumpkin_protocol::java::server::play::SlotActionType;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::inventory::SimpleInventory;
pub struct SmithingTableScreenHandler {
behaviour: ScreenHandlerBehaviour,

View File

@ -6,14 +6,14 @@ use crate::player::player_inventory::PlayerInventory;
use crate::screen_handler::{InventoryPlayer, ScreenHandler, ScreenHandlerBehaviour};
use crate::slot::{NormalSlot, Slot};
use crate::inventory::Inventory;
use crate::inventory::SimpleInventory;
use pumpkin_data::item::Item;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::recipes::{RECIPES_STONECUTTING, StonecutterRecipe};
use pumpkin_data::screen::WindowType;
use pumpkin_data::statistic::StatisticCategory;
use pumpkin_protocol::java::server::play::SlotActionType;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::inventory::SimpleInventory;
pub struct StonecutterScreenHandler {
behaviour: ScreenHandlerBehaviour,

View File

@ -141,3 +141,15 @@ pub enum Lectern {
/// Current page number being viewed.
PageNumber,
}
pub trait PropertyDelegate: Sync + Send {
fn get_property(&self, index: i32) -> i32;
fn set_property(&self, index: i32, value: i32);
fn get_properties_size(&self) -> i32;
}
/// Trait for extracting smelting experience from cooking block entities.
pub trait ExperienceContainer: Send + Sync {
/// Extract and reset accumulated experience, returning the total as an integer
fn extract_experience(&self) -> i32;
}

View File

@ -10,7 +10,6 @@ proc-macro = true
[dependencies]
proc-macro-error2.workspace = true
pumpkin-data = { workspace = true, features = ["block", "tag", "translation"] }
heck.workspace = true
proc-macro2 = "1.0"

View File

@ -3,11 +3,10 @@
use heck::ToShoutySnakeCase;
use proc_macro::TokenStream;
use proc_macro_error2::{abort, abort_call_site};
use pumpkin_data::tag::{RegistryKey, get_tag_ids};
use pumpkin_data::{Block, BlockId};
use quote::{format_ident, quote};
use quote::{format_ident, quote, quote_spanned};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::{self, Attribute, DeriveInput, LitStr, Type, parse_quote};
use syn::{self, Attribute, DeriveInput, Token, Type, parse_quote};
use syn::{Block as SynBlock, Expr, Field, Fields, ItemStruct, Stmt, parse_macro_input};
/// Derives the `Payload` trait for an event struct, enabling it to be used in the plugin system.
@ -314,25 +313,51 @@ pub fn java_packet(args: TokenStream, item: TokenStream) -> TokenStream {
.into()
}
/// Marks a struct as representing a specific block by its name.
fn block_expr_to_id(expr: &Expr) -> proc_macro2::TokenStream {
match expr {
Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit_str),
..
}) => {
let val = lit_str.value();
let name = val.strip_prefix("minecraft:").unwrap_or(&val);
let const_ident = format_ident!("{}", name.to_shouty_snake_case());
quote_spanned! { lit_str.span() => pumpkin_data::BlockId::#const_ident }
}
Expr::Path(syn::ExprPath { path, .. }) => {
if path.segments.len() == 1 {
let ident = &path.segments[0].ident;
quote_spanned! { expr.span() => pumpkin_data::BlockId::#ident }
} else if path.segments.len() == 2
&& (path.segments[0].ident == "Block" || path.segments[0].ident == "BlockId")
{
let ident = &path.segments[1].ident;
quote_spanned! { expr.span() => pumpkin_data::BlockId::#ident }
} else {
quote_spanned! { expr.span() => pumpkin_data::BlockId::from(#expr) }
}
}
_ => {
quote_spanned! { expr.span() => pumpkin_data::BlockId::from(#expr) }
}
}
}
/// Marks a struct as representing a specific block (or blocks) by name, expression, or constant.
///
/// # Arguments
/// - `args` – The `TokenStream` representing the block name literal.
/// - `args` – One or more block names (e.g. `"stone"`, `"minecraft:stone"`), constants (e.g. `Block::STONE`, `BlockId::STONE`, `STONE`), or expressions.
/// - `item` – The input `TokenStream` representing the struct to implement `BlockMetadata` for.
#[proc_macro_attribute]
pub fn pumpkin_block(args: TokenStream, item: TokenStream) -> TokenStream {
let input_item = item.clone();
let arg_lit = parse_macro_input!(args as LitStr);
let arg_value = arg_lit.value();
let args = parse_macro_input!(args with Punctuated<Expr, Token![,]>::parse_terminated);
if args.is_empty() {
abort_call_site!("expected at least one block argument");
}
let block_name = arg_value.strip_prefix("minecraft:").unwrap_or(&arg_value);
let Some(block) = Block::from_name(block_name) else {
return syn::Error::new(arg_lit.span(), "Invalid block name")
.to_compile_error()
.into();
};
let const_ident = format_ident!("{}", block.name.to_shouty_snake_case());
let id_tokens: Vec<_> = args.iter().map(block_expr_to_id).collect();
let ast = parse_macro_input!(item as DeriveInput);
let name = &ast.ident;
@ -341,7 +366,7 @@ pub fn pumpkin_block(args: TokenStream, item: TokenStream) -> TokenStream {
let generated = quote! {
impl #impl_generics crate::block::BlockMetadata for #name #ty_generics #where_clause {
fn ids() -> Box<[pumpkin_data::BlockId]> {
[pumpkin_data::BlockId::#const_ident].into()
Box::new([ #(#id_tokens),* ])
}
}
};
@ -355,37 +380,27 @@ pub fn pumpkin_block(args: TokenStream, item: TokenStream) -> TokenStream {
/// Marks a struct as representing a set of blocks from a given tag.
///
/// # Arguments
/// - `args` – The `TokenStream` representing the block tag literal.
/// - `args` – The `TokenStream` representing the block tag literal or expression.
/// - `item` – The input `TokenStream` representing the struct to implement `BlockMetadata` for.
#[proc_macro_attribute]
pub fn pumpkin_block_from_tag(args: TokenStream, item: TokenStream) -> TokenStream {
let original_item = item.clone();
let arg_lit = parse_macro_input!(args as LitStr);
let arg_expr = parse_macro_input!(args as Expr);
let ast = parse_macro_input!(item as DeriveInput);
let name = &ast.ident;
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
let full_tag = arg_lit.value();
let Some(values) = get_tag_ids(RegistryKey::Block, &full_tag) else {
return syn::Error::new(arg_lit.span(), format!("Failed to get tag IDs: {full_tag}"))
.to_compile_error()
.into();
};
let const_values: Vec<_> = values
.iter()
.map(|v| {
let block = BlockId::new_or_air(*v).to_block();
format_ident!("{}", block.name.to_shouty_snake_case())
})
.collect();
let expanded = quote! {
impl #impl_generics crate::block::BlockMetadata for #name #ty_generics #where_clause {
fn ids() -> Box<[pumpkin_data::BlockId]> {
Box::new([ #(pumpkin_data::BlockId::#const_values),* ])
pumpkin_data::tag::get_tag_ids(pumpkin_data::tag::RegistryKey::Block, #arg_expr)
.unwrap_or_else(|| panic!("Failed to get tag IDs for: {}", #arg_expr))
.iter()
.copied()
.map(pumpkin_data::BlockId::new_or_air)
.collect()
}
}
};
@ -804,33 +819,6 @@ impl syn::parse::Parse for TranslateCrossInput {
fn eval_translation_key_expr(expr: &syn::Expr) -> Option<(&'static str, proc_macro2::Span)> {
match expr {
syn::Expr::Path(expr_path) => {
let segments: Vec<String> = expr_path
.path
.segments
.iter()
.map(|s| s.ident.to_string())
.collect();
let seg_refs: Vec<&str> = segments.iter().map(String::as_str).collect();
let (is_java, const_ident) = match seg_refs.as_slice() {
["translation", "java", ident]
| ["pumpkin_data" | "crate", "translation", "java", ident] => (true, *ident),
["translation", "bedrock", ident]
| ["pumpkin_data" | "crate", "translation", "bedrock", ident] => (false, *ident),
_ => return None,
};
let key = if is_java {
pumpkin_data::translation::java::get(const_ident)
.and_then(pumpkin_data::translation::java::get_value)
} else {
pumpkin_data::translation::bedrock::get(const_ident)
.and_then(pumpkin_data::translation::bedrock::get_value)
};
key.map(|k| (k, expr.span()))
}
syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit_str),
..

View File

@ -13,9 +13,8 @@ query = []
[dependencies]
pumpkin-nbt.workspace = true
pumpkin-data = { workspace = true, features = ["packet", "item_id_remap", "entity_id_remap", "sound_id_remap", "particle_id_remap", "menu_id_remap", "recipe_serializer_id_remap", "argument_type_id_remap", "attribute_id_remap", "block_entity_type_id_remap", "custom_stat_id_remap", "data_component_type_id_remap", "enchantment_id_remap", "environment_attribute_id_remap", "painting_variant_id_remap", "slot_display_id_remap", "recipes", "bedrock_creative", "bedrock_biome"] }
pumpkin-data = { workspace = true, features = ["default", "item_id_remap", "entity_id_remap", "sound_id_remap", "particle_id_remap", "menu_id_remap", "recipe_serializer_id_remap", "argument_type_id_remap", "attribute_id_remap", "block_entity_type_id_remap", "custom_stat_id_remap", "data_component_type_id_remap", "enchantment_id_remap", "environment_attribute_id_remap", "painting_variant_id_remap", "slot_display_id_remap", "bedrock_creative", "bedrock_biome"] }
pumpkin-macros.workspace = true
pumpkin-world.workspace = true
pumpkin-util.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
@ -23,7 +22,7 @@ cesu8.workspace = true
uuid.workspace = true
thiserror.workspace = true
tokio = { workspace = true, features = ["net"] }
tokio = { workspace = true, features = ["net", "io-util"] }
bytes.workspace = true
# encryption
@ -36,9 +35,11 @@ async-compression = { workspace = true, features = ["tokio", "zlib", "deflate"]
flate2.workspace = true
bitflags.workspace = true
base64.workspace = true
xxhash-rust.workspace = true
[dev-dependencies]
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
# Validate correctness
[lints]

View File

@ -20,7 +20,6 @@ pub mod inventory_content;
pub mod inventory_slot;
pub mod item_registry;
pub mod item_stack_response;
pub mod level_chunk;
pub mod level_event;
pub mod level_sound_event;
pub mod mob_effect;
@ -80,7 +79,6 @@ pub use inventory_content::*;
pub use inventory_slot::*;
pub use item_registry::*;
pub use item_stack_response::*;
pub use level_chunk::*;
pub use level_event::*;
pub use level_sound_event::*;
pub use mob_effect::*;

View File

@ -0,0 +1,153 @@
use std::io::Write;
use crate::ClientPacket;
use crate::codec::var_int::VarInt;
use crate::packet::MultiVersionJavaPacket;
use crate::ser::{NetworkWriteExt, WritingError};
use pumpkin_data::packet::clientbound::play::LEVEL_CHUNK_WITH_LIGHT;
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_nbt::tag::NbtTag;
use pumpkin_util::version::JavaMinecraftVersion;
use super::light_update::LightData;
/// Heightmap data accompanying a chunk packet.
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub struct ChunkHeightmaps {
pub world_surface: Option<Vec<i64>>,
pub motion_blocking: Option<Vec<i64>>,
pub motion_blocking_no_leaves: Option<Vec<i64>>,
}
impl ChunkHeightmaps {
pub fn write_to(
&self,
mut write: impl Write,
version: &JavaMinecraftVersion,
) -> Result<(), WritingError> {
if *version >= JavaMinecraftVersion::V_1_21_5 {
write.write_var_int(&VarInt(3))?; // Map size
let mut write_heightmap = |index: i32, data: &[i64]| -> Result<(), WritingError> {
write.write_var_int(&VarInt(index))?;
write.write_var_int(&VarInt(data.len() as i32))?;
for val in data {
write.write_i64_be(*val)?;
}
Ok(())
};
write_heightmap(1, self.world_surface.as_deref().unwrap_or(&[0; 37]))?;
write_heightmap(4, self.motion_blocking.as_deref().unwrap_or(&[0; 37]))?;
write_heightmap(
5,
self.motion_blocking_no_leaves
.as_deref()
.unwrap_or(&[0; 37]),
)?;
} else {
let mut comp = NbtCompound::new();
if let Some(ref ws) = self.world_surface {
comp.put("WORLD_SURFACE", NbtTag::LongArray(ws.clone()));
}
if let Some(ref mb) = self.motion_blocking {
comp.put("MOTION_BLOCKING", NbtTag::LongArray(mb.clone()));
}
if let Some(ref mbnl) = self.motion_blocking_no_leaves {
comp.put("MOTION_BLOCKING_NO_LEAVES", NbtTag::LongArray(mbnl.clone()));
}
write.write_compound_nbt_with_version(Some(&comp), version)?;
}
Ok(())
}
}
/// Block entity metadata serialized in chunk packets.
#[derive(Clone, Debug, PartialEq)]
pub struct ChunkBlockEntity {
pub packed_xz: u8,
pub y: i16,
pub type_id: VarInt,
pub data: NbtCompound,
}
impl ChunkBlockEntity {
#[must_use]
pub const fn new(packed_xz: u8, y: i16, type_id: VarInt, data: NbtCompound) -> Self {
Self {
packed_xz,
y,
type_id,
data,
}
}
}
/// The chunk data and light packet sent to clients (`LEVEL_CHUNK_WITH_LIGHT`).
///
/// Contains chunk position, heightmaps, pre-encoded section and biome payload,
/// block entities, and lighting data.
#[derive(Clone, Debug, PartialEq)]
pub struct CChunkData<'a> {
pub chunk_x: i32,
pub chunk_z: i32,
pub heightmaps: ChunkHeightmaps,
pub data: &'a [u8],
pub block_entities: Vec<ChunkBlockEntity>,
pub light_data: LightData,
}
impl MultiVersionJavaPacket for CChunkData<'_> {
fn to_id(version: JavaMinecraftVersion) -> i32 {
LEVEL_CHUNK_WITH_LIGHT.to_id(version)
}
}
impl<'a> CChunkData<'a> {
#[must_use]
pub const fn new(
chunk_x: i32,
chunk_z: i32,
heightmaps: ChunkHeightmaps,
data: &'a [u8],
block_entities: Vec<ChunkBlockEntity>,
light_data: LightData,
) -> Self {
Self {
chunk_x,
chunk_z,
heightmaps,
data,
block_entities,
light_data,
}
}
}
impl ClientPacket for CChunkData<'_> {
fn write_packet_data(
&self,
mut write: impl Write,
version: &JavaMinecraftVersion,
) -> Result<(), WritingError> {
write.write_i32_be(self.chunk_x)?;
write.write_i32_be(self.chunk_z)?;
self.heightmaps.write_to(&mut write, version)?;
write.write_var_int(&VarInt(self.data.len() as i32))?;
write.write_slice(self.data)?;
write.write_var_int(&VarInt(self.block_entities.len() as i32))?;
for be in &self.block_entities {
write.write_u8(be.packed_xz)?;
write.write_i16_be(be.y)?;
write.write_var_int(&be.type_id)?;
write.write_compound_nbt_with_version(Some(&be.data), version)?;
}
self.light_data.write(&mut write, version)?;
Ok(())
}
}

View File

@ -7,8 +7,6 @@ use crate::{ClientPacket, ServerPacket};
use pumpkin_data::packet::clientbound::play::LIGHT_UPDATE;
use pumpkin_macros::java_packet;
use pumpkin_util::version::JavaMinecraftVersion;
use pumpkin_world::chunk::ChunkData;
use pumpkin_world::chunk::format::LightContainer;
/// Sent by the server to update light levels (block light and sky light) for a chunk.
///
@ -44,18 +42,6 @@ impl CLightUpdate {
light_data,
}
}
pub fn from_chunk(
chunk: &ChunkData,
version: JavaMinecraftVersion,
) -> Result<Self, WritingError> {
let light_data = LightData::from_chunk(chunk, version)?;
Ok(Self {
chunk_x: VarInt(chunk.x),
chunk_z: VarInt(chunk.z),
light_data,
})
}
}
impl LightData {
@ -80,197 +66,6 @@ impl LightData {
}
}
#[expect(clippy::too_many_lines)]
pub fn from_chunk(
chunk: &ChunkData,
version: JavaMinecraftVersion,
) -> Result<Self, WritingError> {
let light_engine = chunk
.light_engine
.lock()
.map_err(|_| WritingError::Message("light_engine lock poisoned".into()))?;
if version < JavaMinecraftVersion::V_1_18 {
let base_section = (0 - chunk.section.min_y).max(0) as usize / 16;
let mut sky_light_mask = 0u64;
let mut block_light_mask = 0u64;
let mut sky_light_empty_mask = 0u64;
let mut block_light_empty_mask = 0u64;
let mut sky_light_arrays = Vec::new();
let mut block_light_arrays = Vec::new();
// Bit 0: Y = -1 (below world section 0)
if base_section > 0 && base_section - 1 < light_engine.sky_light.len() {
match &light_engine.sky_light[base_section - 1] {
LightContainer::Full(data) => {
sky_light_mask |= 1 << 0;
sky_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
sky_light_mask |= 1 << 0;
sky_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
sky_light_empty_mask |= 1 << 0;
}
}
} else {
sky_light_empty_mask |= 1 << 0;
}
if base_section > 0 && base_section - 1 < light_engine.block_light.len() {
match &light_engine.block_light[base_section - 1] {
LightContainer::Full(data) => {
block_light_mask |= 1 << 0;
block_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
block_light_mask |= 1 << 0;
block_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
block_light_empty_mask |= 1 << 0;
}
}
} else {
block_light_empty_mask |= 1 << 0;
}
// Bits 1..=16: world sections (Y = 0..15)
for i in 0..16 {
let bit_index = i + 1;
let sec_idx = base_section + i;
if sec_idx < light_engine.sky_light.len() {
match &light_engine.sky_light[sec_idx] {
LightContainer::Full(data) => {
sky_light_mask |= 1 << bit_index;
sky_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
sky_light_mask |= 1 << bit_index;
sky_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
sky_light_empty_mask |= 1 << bit_index;
}
}
} else {
sky_light_empty_mask |= 1 << bit_index;
}
if sec_idx < light_engine.block_light.len() {
match &light_engine.block_light[sec_idx] {
LightContainer::Full(data) => {
block_light_mask |= 1 << bit_index;
block_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
block_light_mask |= 1 << bit_index;
block_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
block_light_empty_mask |= 1 << bit_index;
}
}
} else {
block_light_empty_mask |= 1 << bit_index;
}
}
// Bit 17: Y = 16 (above world section 15)
let top_sec = base_section + 16;
if top_sec < light_engine.sky_light.len() {
match &light_engine.sky_light[top_sec] {
LightContainer::Full(data) => {
sky_light_mask |= 1 << 17;
sky_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
sky_light_mask |= 1 << 17;
sky_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
sky_light_empty_mask |= 1 << 17;
}
}
} else {
sky_light_empty_mask |= 1 << 17;
}
if top_sec < light_engine.block_light.len() {
match &light_engine.block_light[top_sec] {
LightContainer::Full(data) => {
block_light_mask |= 1 << 17;
block_light_arrays.push(data.to_vec());
}
LightContainer::Empty(val) if *val > 0 => {
block_light_mask |= 1 << 17;
block_light_arrays.push(vec![*val << 4 | *val; 2048]);
}
LightContainer::Empty(_) => {
block_light_empty_mask |= 1 << 17;
}
}
} else {
block_light_empty_mask |= 1 << 17;
}
Ok(Self {
trust_edges: true,
sky_light_mask: BitSet::from_u64(sky_light_mask),
block_light_mask: BitSet::from_u64(block_light_mask),
empty_sky_light_mask: BitSet::from_u64(sky_light_empty_mask),
empty_block_light_mask: BitSet::from_u64(block_light_empty_mask),
sky_light_arrays,
block_light_arrays,
})
} else {
let num_sections = light_engine.sky_light.len();
let mut sky_light_empty_mask = 0u64;
let mut block_light_empty_mask = 0u64;
let mut sky_light_mask = 0u64;
let mut block_light_mask = 0u64;
let mut sky_light_arrays = Vec::new();
let mut block_light_arrays = Vec::new();
sky_light_empty_mask |= 1 << 0;
block_light_empty_mask |= 1 << 0;
for section_index in 0..num_sections {
let bit_index = section_index + 1;
if let LightContainer::Full(data) = &light_engine.sky_light[section_index] {
sky_light_mask |= 1 << bit_index;
sky_light_arrays.push(data.to_vec());
} else {
sky_light_empty_mask |= 1 << bit_index;
}
if let LightContainer::Full(data) = &light_engine.block_light[section_index] {
block_light_mask |= 1 << bit_index;
block_light_arrays.push(data.to_vec());
} else {
block_light_empty_mask |= 1 << bit_index;
}
}
sky_light_empty_mask |= 1 << (num_sections + 1);
block_light_empty_mask |= 1 << (num_sections + 1);
Ok(Self {
trust_edges: true,
sky_light_mask: BitSet::from_u64(sky_light_mask),
block_light_mask: BitSet::from_u64(block_light_mask),
empty_sky_light_mask: BitSet::from_u64(sky_light_empty_mask),
empty_block_light_mask: BitSet::from_u64(block_light_empty_mask),
sky_light_arrays,
block_light_arrays,
})
}
}
pub fn write(
&self,
mut write: impl Write,

View File

@ -16,7 +16,7 @@ mod center_chunk;
mod change_difficulty;
mod chunk_batch_end;
mod chunk_batch_start;
mod chunk_data;
pub mod chunk_data;
mod clear_dialog;
mod clear_title;
mod close_container;

View File

@ -29,7 +29,9 @@ impl ClientPacket for CServerData<'_> {
if let Some(icon) = self.icon_base64 {
write.write_bool(true)?;
let raw_b64 = icon.strip_prefix("data:image/png;base64,").unwrap_or(icon);
if let Ok(bytes) = pumpkin_util::jwt::decode_b64_standard(raw_b64) {
if let Ok(bytes) =
base64::Engine::decode(&base64::engine::general_purpose::STANDARD, raw_b64)
{
write.write_slice(&bytes)?;
} else {
write.write_slice(&[])?;

View File

@ -23,16 +23,7 @@ proc-macro2 = { workspace = true, optional = true }
uuid.workspace = true
dashmap.workspace = true
base64.workspace = true
p384 = { workspace = true, features = ["ecdsa"] }
thiserror.workspace = true
ecdsa.workspace = true
rsa.workspace = true
sha2.workspace = true
crypto-bigint.workspace = true
reqwest.workspace = true
rustls.workspace = true
webpki-root-certs.workspace = true
[dev-dependencies]
criterion = { workspace = true, features = ["html_reports"] }

View File

@ -6,7 +6,6 @@
use serde::{Deserialize, Serialize};
use std::ops::{Index, IndexMut};
pub use p384;
pub use serde_json;
pub use difficulty::Difficulty;
@ -32,14 +31,10 @@ pub mod version;
pub mod world_seed;
pub mod y_offset;
pub mod client;
pub mod identifier;
pub mod jwt;
pub mod resource;
pub mod uuid;
pub use client::{client, client_builder};
/// Represents the different types of height maps used for terrain generation and collision checks.
#[derive(Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]

View File

@ -1,11 +0,0 @@
pub trait PropertyDelegate: Sync + Send {
fn get_property(&self, _index: i32) -> i32;
fn set_property(&self, _index: i32, _value: i32);
fn get_properties_size(&self) -> i32;
}
/// Trait for extracting smelting experience from cooking block entities.
pub trait ExperienceContainer: Send + Sync {
/// Extract and reset accumulated experience, returning the total as an integer
fn extract_experience(&self) -> i32;
}

View File

@ -1,6 +1,3 @@
pub mod entities;
pub mod viewer;
use std::collections::HashMap;
use pumpkin_data::{Block, BlockState, BlockStateId};

View File

@ -11,7 +11,6 @@ pub mod cylindrical_chunk_iterator;
pub mod data;
pub mod dimension;
pub mod generation;
pub mod inventory;
pub mod level;
pub mod lighting;
pub mod poi;

View File

@ -22,6 +22,7 @@ doctest = false
arc-swap.workspace = true
rayon.workspace = true
pumpkin-util.workspace = true
pumpkin-auth.workspace = true
pumpkin-nbt.workspace = true
pumpkin-config.workspace = true
pumpkin-command.workspace = true
@ -127,6 +128,8 @@ bitflags = { workspace = true }
image = { version = "0.25.10", default-features = false, features = ["png"] }
indexmap.workspace = true
xxhash-rust.workspace = true
[dev-dependencies]
tempfile.workspace = true

View File

@ -8,6 +8,7 @@ use crate::block::{
use pumpkin_data::block_properties::WallTorchLikeProperties;
use pumpkin_data::translation;
use pumpkin_data::{Block, BlockState, BlockStateId};
use pumpkin_inventory::SimpleInventory;
use pumpkin_inventory::anvil::AnvilScreenHandler;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -15,7 +16,6 @@ use pumpkin_inventory::screen_handler::{
};
use pumpkin_macros::pumpkin_block_from_tag;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::SimpleInventory;
use std::sync::Arc;
use std::sync::Mutex;

View File

@ -12,6 +12,7 @@ use crate::entity::EntityBase;
use pumpkin_data::BlockStateId;
use pumpkin_data::block_properties::BarrelLikeProperties;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::generic_container_screen_handler::create_generic_9x3;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -19,7 +20,6 @@ use pumpkin_inventory::screen_handler::{
};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
struct BarrelScreenFactory(Arc<dyn Inventory>);

View File

@ -2,6 +2,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::beacon_screen_handler::create_beacon_handler;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -9,7 +10,6 @@ use pumpkin_inventory::screen_handler::{
};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use crate::block::registry::BlockActionResult;
use crate::block::{BlockBehaviour, GetScreenHandlerFactoryArgs, NormalUseArgs};

View File

@ -8,13 +8,13 @@ use crate::block::entities::{
use pumpkin_data::{
BlockStateId, block_properties::FurnaceLikeProperties, screen::WindowType, translation,
};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::{
furnace_like::furnace_like_screen_handler::FurnaceLikeScreenHandler,
player::player_inventory::PlayerInventory,
screen_handler::{InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler},
};
use pumpkin_macros::pumpkin_block;
use pumpkin_world::inventory::Inventory;
use crate::{
block::{

View File

@ -12,13 +12,13 @@ use crate::block::{
use crate::block::entities::brewing_stand::BrewingStandBlockEntity;
use pumpkin_data::BlockState;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler,
};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
struct BrewingScreenFactory(
Arc<dyn Inventory>,

View File

@ -7,6 +7,7 @@ use pumpkin_data::block_properties::{ChestLikeProperties, ChestType, HorizontalF
use pumpkin_data::entity::EntityPose;
use pumpkin_data::loot_table::get_loot_table;
use pumpkin_data::{Block, BlockDirection, translation};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::double::DoubleInventory;
use pumpkin_inventory::generic_container_screen_handler::{create_generic_9x3, create_generic_9x6};
use pumpkin_inventory::player::player_inventory::PlayerInventory;
@ -17,7 +18,6 @@ use pumpkin_macros::{pumpkin_block, pumpkin_block_from_tag};
use pumpkin_util::GameMode;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::world::BlockFlags;
use std::sync::Mutex;

View File

@ -4,7 +4,7 @@ use pumpkin_data::effect::StatusEffect;
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::vector3::Vector3;
#[pumpkin_block("minecraft:cobweb")]
#[pumpkin_block(Block::COBWEB)]
pub struct CobwebBlock;
impl BlockBehaviour for CobwebBlock {

View File

@ -12,10 +12,10 @@ use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler,
};
use pumpkin_inventory::{Inventory, SimpleInventory};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::{Inventory, SimpleInventory};
#[pumpkin_block("minecraft:enchanting_table")]
pub struct EnchantingTableBlock;

View File

@ -9,6 +9,7 @@ use crate::block::{
use crate::world::World;
use pumpkin_data::block_properties::LadderLikeProperties;
use pumpkin_data::{BlockState, BlockStateId, translation};
use pumpkin_inventory::ViewerCountTracker;
use pumpkin_inventory::{
generic_container_screen_handler::create_generic_9x3,
player::ender_chest_inventory::EnderChestInventory,
@ -18,7 +19,6 @@ use pumpkin_inventory::{
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::text::TextComponent;
use pumpkin_world::block::viewer::ViewerCountTracker;
pub struct EnderChestScreenFactory {
pub inventory: Arc<EnderChestInventory>,

View File

@ -7,13 +7,13 @@ use crate::block::entities::{
use pumpkin_data::{
BlockStateId, block_properties::FurnaceLikeProperties, screen::WindowType, translation,
};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::{
furnace_like::furnace_like_screen_handler::FurnaceLikeScreenHandler,
player::player_inventory::PlayerInventory,
screen_handler::{InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler},
};
use pumpkin_macros::pumpkin_block;
use pumpkin_world::inventory::Inventory;
use crate::{
block::{

View File

@ -6,6 +6,7 @@ use pumpkin_data::{
Block, BlockDirection, BlockStateId, HorizontalFacingExt,
block_properties::{AttachFace, GrindstoneLikeProperties},
};
use pumpkin_inventory::SimpleInventory;
use pumpkin_inventory::grindstone_screen_handler::GrindstoneScreenHandler;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -14,7 +15,6 @@ use pumpkin_inventory::screen_handler::{
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::SimpleInventory;
use pumpkin_world::world::BlockAccessor;
use crate::block::registry::BlockActionResult;

View File

@ -15,6 +15,7 @@ use crate::world::World;
use crate::block::entities::hopper::HopperBlockEntity;
use pumpkin_data::block_properties::FacingHopper;
use pumpkin_data::{Block, BlockDirection, BlockState, BlockStateId, translation};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::generic_container_screen_handler::create_hopper;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -23,7 +24,6 @@ use pumpkin_inventory::screen_handler::{
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::world::BlockFlags;
struct HopperBlockScreenFactory(Arc<dyn Inventory>);

View File

@ -17,6 +17,7 @@ use pumpkin_data::sound::{Sound, SoundCategory};
use pumpkin_data::tag::Taggable;
use pumpkin_data::world::WorldEvent;
use pumpkin_data::{Block, BlockDirection, BlockState, BlockStateId, tag, translation};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::lectern_screen_handler::{LecternController, LecternScreenHandler};
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -26,7 +27,6 @@ use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::tick::TickPriority;
use pumpkin_world::world::BlockFlags;
use std::sync::Mutex;

View File

@ -21,6 +21,7 @@ use pumpkin_data::recipe_remainder::get_recipe_remainder_id;
use pumpkin_data::translation;
use pumpkin_data::world::WorldEvent;
use pumpkin_data::{Block, BlockDirection, BlockStateId};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::crafting::crafting_screen_handler::match_crafting_recipe;
use pumpkin_inventory::generic_container_screen_handler::create_crafter_3x3;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
@ -31,7 +32,6 @@ use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::tick::TickPriority;
use pumpkin_world::world::BlockFlags;

View File

@ -47,6 +47,7 @@ use pumpkin_data::sound::{Sound, SoundCategory};
use pumpkin_data::translation;
use pumpkin_data::world::WorldEvent;
use pumpkin_data::{Block, BlockStateId, FacingExt};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::generic_container_screen_handler::create_generic_3x3;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -58,7 +59,6 @@ use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::math::wrap_degrees;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::tick::TickPriority;
use pumpkin_world::world::BlockFlags;

View File

@ -18,6 +18,7 @@ use pumpkin_data::block_properties::Facing;
use pumpkin_data::entity::EntityType;
use pumpkin_data::world::WorldEvent;
use pumpkin_data::{FacingExt, translation};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::generic_container_screen_handler::create_generic_3x3;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -26,7 +27,6 @@ use pumpkin_inventory::screen_handler::{
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
use pumpkin_world::tick::TickPriority;
use pumpkin_world::world::BlockFlags;

View File

@ -1,7 +1,7 @@
use pumpkin_data::block_properties::AcaciaShelfLikeProperties;
use pumpkin_data::{BlockState, BlockStateId};
use pumpkin_inventory::Inventory;
use pumpkin_macros::pumpkin_block_from_tag;
use pumpkin_world::inventory::Inventory;
use crate::block::entities::shelf::ShelfBlockEntity;
use crate::block::{

View File

@ -13,6 +13,7 @@ use crate::block::{
use crate::block::entities::shulker_box::ShulkerBoxBlockEntity;
use pumpkin_data::BlockStateId;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::generic_container_screen_handler::create_generic_9x3;
use pumpkin_inventory::player::player_inventory::PlayerInventory;
use pumpkin_inventory::screen_handler::{
@ -20,7 +21,6 @@ use pumpkin_inventory::screen_handler::{
};
use pumpkin_macros::pumpkin_block_from_tag;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::Inventory;
struct ShulkerBoxScreenFactory(Arc<dyn Inventory>);

View File

@ -7,13 +7,13 @@ use crate::block::entities::{
use pumpkin_data::{
BlockStateId, block_properties::FurnaceLikeProperties, screen::WindowType, translation,
};
use pumpkin_inventory::Inventory;
use pumpkin_inventory::{
furnace_like::furnace_like_screen_handler::FurnaceLikeScreenHandler,
player::player_inventory::PlayerInventory,
screen_handler::{InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler},
};
use pumpkin_macros::pumpkin_block;
use pumpkin_world::inventory::Inventory;
use crate::{
block::{

View File

@ -18,7 +18,7 @@ use std::{
use crate::block::viewer::{ViewerCountListener, ViewerCountTracker, ViewerCountTrackerExt};
use crate::world::{BlockFlags, World};
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use super::BlockEntity;
@ -51,7 +51,7 @@ impl BlockEntity for BarrelBlockEntity {
viewers: ViewerCountTracker::new(),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
barrel
.items

View File

@ -12,7 +12,7 @@ use pumpkin_util::math::position::BlockPos;
use crate::block::entities::BlockEntity;
use crate::world::World;
use pumpkin_world::inventory::{Clearable, Inventory};
use pumpkin_inventory::{Clearable, Inventory};
pub struct BeaconBlockEntity {
pub position: BlockPos,

View File

@ -1,5 +1,5 @@
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::Inventory;
use pumpkin_inventory::Inventory;
use std::{
array::from_fn,

View File

@ -11,10 +11,10 @@ use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::potion_brewing::{ITEM_RECIPES, POTION_RECIPES};
use pumpkin_data::sound::{Sound, SoundCategory};
use pumpkin_data::tag::{self, Taggable};
use pumpkin_inventory::{Inventory, sync_read_items_from_nbt, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_world::inventory::{Inventory, sync_read_items_from_nbt, sync_write_items_to_nbt};
pub struct BrewingStandBlockEntity {
pub position: BlockPos,
@ -276,7 +276,7 @@ impl BrewingStandBlockEntity {
}
}
impl pumpkin_world::inventory::Inventory for BrewingStandBlockEntity {
impl pumpkin_inventory::Inventory for BrewingStandBlockEntity {
fn size(&self) -> usize {
Self::INVENTORY_SIZE
}
@ -376,7 +376,7 @@ impl pumpkin_world::inventory::Inventory for BrewingStandBlockEntity {
}
}
impl pumpkin_world::inventory::Clearable for BrewingStandBlockEntity {
impl pumpkin_inventory::Clearable for BrewingStandBlockEntity {
fn clear(&self) {
let mut items = self
.items

View File

@ -40,7 +40,7 @@ macro_rules! impl_block_entity_for_chest {
.unwrap_or_else(std::sync::PoisonError::into_inner)
.is_some();
if !has_loot_table {
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
chest
.items
@ -53,7 +53,7 @@ macro_rules! impl_block_entity_for_chest {
}
fn write_nbt(&self, nbt: &mut pumpkin_nbt::compound::NbtCompound) {
use pumpkin_world::inventory::Inventory;
use pumpkin_inventory::Inventory;
let loot_table_key = {
let guard = self
@ -84,9 +84,7 @@ macro_rules! impl_block_entity_for_chest {
);
}
fn get_inventory(
self: Arc<Self>,
) -> Option<Arc<dyn pumpkin_world::inventory::Inventory>> {
fn get_inventory(self: Arc<Self>) -> Option<Arc<dyn pumpkin_inventory::Inventory>> {
Some(self)
}
@ -108,7 +106,7 @@ macro_rules! impl_block_entity_for_chest {
.is_some();
if !has_loot_table {
if let Ok(items) = self.items.try_read() {
pumpkin_world::inventory::sync_write_items_to_nbt(&*items, &mut nbt);
pumpkin_inventory::sync_write_items_to_nbt(&*items, &mut nbt);
}
}
Some(nbt)
@ -140,7 +138,7 @@ macro_rules! impl_block_entity_for_chest {
#[macro_export]
macro_rules! impl_inventory_for_chest {
($struct_name:ty) => {
impl pumpkin_world::inventory::Inventory for $struct_name {
impl pumpkin_inventory::Inventory for $struct_name {
fn size(&self) -> usize {
Self::INVENTORY_SIZE
}
@ -217,14 +215,14 @@ macro_rules! impl_inventory_for_chest {
#[macro_export]
macro_rules! impl_clearable_for_chest {
($struct_name:ty) => {
impl pumpkin_world::inventory::Clearable for $struct_name {
impl pumpkin_inventory::Clearable for $struct_name {
fn clear(&self) {
let mut items = self
.items
.write()
.unwrap_or_else(std::sync::PoisonError::into_inner);
items.fill_with(|| ItemStack::EMPTY.clone());
<$struct_name as pumpkin_world::inventory::Inventory>::mark_dirty(self);
<$struct_name as pumpkin_inventory::Inventory>::mark_dirty(self);
}
}
};

View File

@ -18,7 +18,7 @@ use crate::{
block::entities::BlockEntity,
world::{BlockFlags, World},
};
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
pub struct ChiseledBookshelfBlockEntity {
pub position: BlockPos,
@ -48,7 +48,7 @@ impl BlockEntity for ChiseledBookshelfBlockEntity {
last_interacted_slot: AtomicI8::new(-1),
dirty: AtomicBool::new(false),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
bookshelf
.items

View File

@ -3,12 +3,10 @@ use crate::world::World;
use pumpkin_data::block_properties::CrafterLikeProperties;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_inventory::crafting::recipes::RecipeInputInventory;
use pumpkin_inventory::{Clearable, Inventory, sync_read_items_from_nbt, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_nbt::tag::NbtTag;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::inventory::{
Clearable, Inventory, sync_read_items_from_nbt, sync_write_items_to_nbt,
};
use pumpkin_world::world::BlockFlags;
use std::any::Any;
use std::array::from_fn;

View File

@ -1,8 +1,8 @@
use crate::block::entities::BlockEntity;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use rand::{RngExt, rng};
use std::any::Any;
use std::array::from_fn;
@ -31,7 +31,7 @@ impl BlockEntity for DispenserBlockEntity {
dirty: AtomicBool::new(false),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
dispenser
.items

View File

@ -1,8 +1,8 @@
use crate::block::entities::BlockEntity;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use rand::{RngExt, rng};
use std::any::Any;
use std::array::from_fn;
@ -31,7 +31,7 @@ impl BlockEntity for DropperBlockEntity {
dirty: AtomicBool::new(false),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
dropper
.items

View File

@ -1,4 +1,4 @@
use pumpkin_world::inventory::Inventory;
use pumpkin_inventory::Inventory;
use std::{
array::from_fn,

View File

@ -1,8 +1,8 @@
use pumpkin_data::{item_stack::ItemStack, recipes::CookingRecipe};
use crate::block::entities::{BlockEntity, PropertyDelegate};
pub use pumpkin_world::block::entities::ExperienceContainer;
use pumpkin_world::inventory::{Clearable, Inventory};
pub use pumpkin_inventory::ExperienceContainer;
use pumpkin_inventory::{Clearable, Inventory};
/// Trait for extracting smelting experience from cooking block entities.
pub trait CookingBlockEntityBase:
@ -239,7 +239,7 @@ macro_rules! impl_property_delegate_for_cooking {
#[macro_export]
macro_rules! impl_clearable_for_cooking {
($struct_name:ty) => {
impl pumpkin_world::inventory::Clearable for $struct_name {
impl pumpkin_inventory::Clearable for $struct_name {
fn clear(&self) {
let mut items = self
.items
@ -269,7 +269,7 @@ macro_rules! impl_experience_container_for_cooking {
#[macro_export]
macro_rules! impl_inventory_for_cooking {
($struct_name:ty) => {
impl pumpkin_world::inventory::Inventory for $struct_name {
impl pumpkin_inventory::Inventory for $struct_name {
fn size(&self) -> usize {
Self::INVENTORY_SIZE
}
@ -567,7 +567,7 @@ macro_rules! impl_block_entity_for_cooking {
lit_time_remaining,
recipes_used: std::sync::Mutex::new(recipes_used_map),
};
pumpkin_world::inventory::sync_read_items_from_nbt(nbt, furnace.items.get_mut().unwrap_or_else(std::sync::PoisonError::into_inner));
pumpkin_inventory::sync_read_items_from_nbt(nbt, furnace.items.get_mut().unwrap_or_else(std::sync::PoisonError::into_inner));
furnace
}
@ -604,7 +604,7 @@ macro_rules! impl_block_entity_for_cooking {
fn get_inventory(
self: Arc<Self>,
) -> Option<Arc<dyn pumpkin_world::inventory::Inventory>> {
) -> Option<Arc<dyn pumpkin_inventory::Inventory>> {
Some(self)
}
@ -636,7 +636,7 @@ macro_rules! impl_block_entity_for_cooking {
}
if let Ok(guard) = self.items.try_read() {
pumpkin_world::inventory::sync_write_items_to_nbt(&*guard, &mut nbt);
pumpkin_inventory::sync_write_items_to_nbt(&*guard, &mut nbt);
}
Some(nbt)
}

View File

@ -6,11 +6,11 @@ use pumpkin_data::block_properties::{FacingHopper, HopperLikeProperties};
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::tag;
use pumpkin_data::tag::Taggable;
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_nbt::tag::NbtTag;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use std::any::Any;
use std::array::from_fn;
use std::sync::Arc;
@ -61,7 +61,7 @@ impl BlockEntity for HopperBlockEntity {
ticked_game_time: AtomicI64::new(0),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
hopper
.items

View File

@ -9,7 +9,7 @@ use pumpkin_util::math::position::BlockPos;
use crate::block::entities::BlockEntity;
use crate::world::World;
use pumpkin_world::inventory::{Clearable, Inventory};
use pumpkin_inventory::{Clearable, Inventory};
/// Matches vanilla's `JukeboxBlockEntity`
pub struct JukeboxBlockEntity {

View File

@ -12,7 +12,7 @@ use std::{
};
use crate::block::entities::BlockEntity;
use pumpkin_world::inventory::{Clearable, Inventory};
use pumpkin_inventory::{Clearable, Inventory};
pub struct LecternBlockEntity {
pub position: BlockPos,

View File

@ -6,7 +6,7 @@ use pumpkin_util::math::position::BlockPos;
use crate::world::World;
use pumpkin_data::BlockStateId;
use pumpkin_world::inventory::Inventory;
use pumpkin_inventory::Inventory;
pub mod barrel;
pub mod beacon;
@ -64,7 +64,7 @@ pub mod trial_spawner;
pub mod vault;
pub use furnace_like_block_entity::ExperienceContainer;
pub use pumpkin_world::block::entities::PropertyDelegate;
pub use pumpkin_inventory::PropertyDelegate;
//TODO: We need a mark_dirty for chests
pub trait BlockEntity: Any + Send + Sync {
@ -429,9 +429,9 @@ pub fn create_block_entity(
mod test {
use super::{BlockEntity, block_entity_from_nbt, furnace::FurnaceBlockEntity};
use pumpkin_data::{item::Item, item_stack::ItemStack};
use pumpkin_inventory::Inventory;
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::inventory::Inventory;
use std::sync::Arc;
/// A loaded block entity is serialized back into its chunk with

View File

@ -1,8 +1,8 @@
use crate::block::entities::BlockEntity;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use std::any::Any;
use std::array::from_fn;
use std::sync::Arc;
@ -36,7 +36,7 @@ impl BlockEntity for ShelfBlockEntity {
dirty: AtomicBool::new(false),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
shelf
.items

View File

@ -10,7 +10,7 @@ use std::{array::from_fn, sync::Arc};
use crate::block::entities::BlockEntity;
use crate::block::viewer::{ViewerCountListener, ViewerCountTracker, ViewerCountTrackerExt};
use crate::world::World;
use pumpkin_world::inventory::{Clearable, Inventory, sync_write_items_to_nbt};
use pumpkin_inventory::{Clearable, Inventory, sync_write_items_to_nbt};
pub struct ShulkerBoxBlockEntity {
pub position: BlockPos,
@ -41,7 +41,7 @@ impl BlockEntity for ShulkerBoxBlockEntity {
viewers: ViewerCountTracker::new(),
};
pumpkin_world::inventory::sync_read_items_from_nbt(
pumpkin_inventory::sync_read_items_from_nbt(
nbt,
shulker_box
.items

View File

@ -1,5 +1,5 @@
use pumpkin_data::item_stack::ItemStack;
use pumpkin_world::inventory::Inventory;
use pumpkin_inventory::Inventory;
use std::{
array::from_fn,

View File

@ -548,7 +548,7 @@ impl BlockIsReplacing {
}
}
pub fn calculate_comparator_output(inventory: &dyn pumpkin_world::inventory::Inventory) -> u8 {
pub fn calculate_comparator_output(inventory: &dyn pumpkin_inventory::Inventory) -> u8 {
let size = inventory.size();
if size == 0 {
return 0;

View File

@ -4,7 +4,7 @@ use pumpkin_util::math::position::BlockPos;
use crate::{block::entities::BlockEntity, world::World};
pub use pumpkin_world::block::viewer::ViewerCountTracker;
pub use pumpkin_inventory::ViewerCountTracker;
pub trait ViewerCountTrackerExt {
fn update_viewer_count<T>(&self, entity: &T, world: &Arc<World>, position: &BlockPos)

View File

@ -7,8 +7,8 @@ use crate::command::context::command_context::CommandContext;
use crate::command::errors::error_types::CommandErrorType;
use crate::command::node::dispatcher::CommandDispatcher;
use crate::command::node::{CommandExecutor, CommandExecutorResult};
use crate::net::java::chunk_data::CChunkData;
use pumpkin_data::translation;
use pumpkin_protocol::java::client::play::CChunkData;
use pumpkin_util::PermissionLvl;
use pumpkin_util::math::vector2::Vector2;
use pumpkin_util::permission::{Permission, PermissionDefault, PermissionRegistry};

View File

@ -1,5 +1,6 @@
use pumpkin_data::data_component_impl::EquipmentSlot;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::screen_handler::InventoryPlayer;
use pumpkin_protocol::codec::item_stack_seralizer::ItemStackSerializer;
use pumpkin_protocol::java::client::play::CSetContainerSlot;
@ -7,7 +8,6 @@ use pumpkin_util::PermissionLvl;
use pumpkin_util::permission::{Permission, PermissionDefault, PermissionRegistry};
use pumpkin_util::text::TextComponent;
use pumpkin_util::text::hover::HoverEvent;
use pumpkin_world::inventory::Inventory;
use crate::command::argument_builder::{
ArgumentBuilder, RequiredArgumentBuilder, argument, command, literal,

View File

@ -1,6 +1,7 @@
use pumpkin_data::data_component_impl::EquipmentSlot;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::translation;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::screen_handler::InventoryPlayer;
use pumpkin_protocol::codec::item_stack_seralizer::ItemStackSerializer;
use pumpkin_protocol::java::client::play::CSetContainerSlot;
@ -10,7 +11,6 @@ use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::permission::{Permission, PermissionDefault, PermissionRegistry};
use pumpkin_util::text::TextComponent;
use pumpkin_util::text::hover::HoverEvent;
use pumpkin_world::inventory::Inventory;
use crate::command::argument_builder::{
ArgumentBuilder, LiteralArgumentBuilder, argument, command, literal,

View File

@ -81,7 +81,7 @@ fn fetch_all_contributors_cached() -> Vec<Contributor> {
}
async fn fetch_all_contributors() -> Vec<Contributor> {
let client = pumpkin_util::client_builder()
let client = pumpkin_auth::client_builder()
.user_agent("Pumpkin-MC")
.build()
.unwrap_or_default();
@ -196,7 +196,7 @@ fn tier_color(tier_slug: &str, tier_name: &str) -> NamedColor {
async fn fetch_donators_hover() -> TextComponent {
let url = "https://market.pumpkinmc.org/api/v1/rest/donators";
let client = pumpkin_util::client_builder()
let client = pumpkin_auth::client_builder()
.user_agent("Pumpkin-MC")
.build()
.unwrap_or_default();

View File

@ -14,6 +14,7 @@ use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::potion::Effect;
use pumpkin_data::tag::{Enchantment as EnchantmentTag, Taggable};
use pumpkin_data::tracked_data;
use pumpkin_inventory::SimpleInventory;
use pumpkin_inventory::merchant::merchant_screen_handler::MerchantScreenHandler;
use pumpkin_inventory::screen_handler::{
InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler,
@ -29,7 +30,6 @@ use pumpkin_protocol::java::client::play::{CMerchantOffers, Metadata};
use pumpkin_util::math::{boundingbox::BoundingBox, position::BlockPos, vector3::Vector3};
use pumpkin_util::text::TextComponent;
use pumpkin_util::version::JavaMinecraftVersion;
use pumpkin_world::inventory::SimpleInventory;
use crate::entity::player::Player;
use crate::entity::{

View File

@ -15,6 +15,7 @@ use pumpkin_data::villager::{
TRADES_WANDERING_TRADER_BUYING, TRADES_WANDERING_TRADER_COMMON,
TRADES_WANDERING_TRADER_UNCOMMON, VillagerTrade, VillagerTradeModifier,
};
use pumpkin_inventory::SimpleInventory;
use pumpkin_inventory::merchant::merchant_screen_handler::MerchantScreenHandler;
use pumpkin_inventory::screen_handler::{
InventoryPlayer, ScreenHandlerFactory, SharedScreenHandler,
@ -26,7 +27,6 @@ use pumpkin_protocol::java::client::play::CMerchantOffers;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use pumpkin_util::text::TextComponent;
use pumpkin_world::inventory::SimpleInventory;
use rand::RngExt;
use rand::seq::IndexedRandom;

View File

@ -19,6 +19,7 @@ use crossbeam::atomic::AtomicCell;
use crossbeam::channel::Receiver;
use crossbeam::queue::SegQueue;
use pumpkin_data::dimension::Dimension;
use pumpkin_inventory::Inventory;
use pumpkin_inventory::merchant::merchant_screen_handler::MerchantScreenHandler;
use pumpkin_inventory::player::ender_chest_inventory::EnderChestInventory;
use pumpkin_protocol::RawPacket;
@ -43,7 +44,6 @@ use pumpkin_protocol::codec::item_stack_seralizer::ItemStackSerializer;
use pumpkin_util::translation::Locale;
use pumpkin_util::version::JavaMinecraftVersion;
use pumpkin_world::chunk::ChunkData;
use pumpkin_world::inventory::Inventory;
use tokio::task::JoinHandle;
use tracing::{debug, warn};
use uuid::Uuid;
@ -575,13 +575,13 @@ impl Player {
let bytes = if let Ok(handle) = tokio::runtime::Handle::try_current() {
tokio::task::block_in_place(|| {
handle.block_on(async {
let client = pumpkin_util::client();
let client = pumpkin_auth::client();
client.get(&url).send().await.ok()?.bytes().await.ok()
})
})?
} else {
tokio::runtime::Runtime::new().ok()?.block_on(async {
let client = pumpkin_util::client();
let client = pumpkin_auth::client();
client.get(&url).send().await.ok()?.bytes().await.ok()
})?
};

Some files were not shown because too many files have changed in this diff Show More