Some Refactors
This commit is contained in:
parent
97065617b6
commit
466d4380cf
@ -1,7 +1,7 @@
|
|||||||
use pumpkin_registry::{
|
use pumpkin_registry::{
|
||||||
flatten_3x3, get_tag_values, IngredientSlot, IngredientType, RecipeResult, TagCategory, RECIPES,
|
flatten_3x3, get_tag_values, IngredientSlot, IngredientType, RecipeResult, TagCategory, RECIPES,
|
||||||
};
|
};
|
||||||
use pumpkin_world::item::item_registry::get_item;
|
use pumpkin_world::item::registry::get_item;
|
||||||
use pumpkin_world::item::ItemStack;
|
use pumpkin_world::item::ItemStack;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use crate::crafting::check_if_matches_crafting;
|
|||||||
use crate::Container;
|
use crate::Container;
|
||||||
use pumpkin_data::screen::WindowType;
|
use pumpkin_data::screen::WindowType;
|
||||||
use pumpkin_util::math::position::BlockPos;
|
use pumpkin_util::math::position::BlockPos;
|
||||||
use pumpkin_world::block::block_registry::Block;
|
use pumpkin_world::block::registry::Block;
|
||||||
use pumpkin_world::item::ItemStack;
|
use pumpkin_world::item::ItemStack;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|||||||
@ -78,7 +78,7 @@ pub fn client_packet(input: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
let gen = quote! {
|
let gen = quote! {
|
||||||
#item
|
#item
|
||||||
impl #impl_generics crate::bytebuf::packet_id::Packet for #name #ty_generics {
|
impl #impl_generics crate::bytebuf::packet::Packet for #name #ty_generics {
|
||||||
const PACKET_ID: i32 = #input;
|
const PACKET_ID: i32 = #input;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -97,7 +97,7 @@ pub fn server_packet(input: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
|
|
||||||
let gen = quote! {
|
let gen = quote! {
|
||||||
#item
|
#item
|
||||||
impl #impl_generics crate::bytebuf::packet_id::Packet for #name #ty_generics {
|
impl #impl_generics crate::bytebuf::packet::Packet for #name #ty_generics {
|
||||||
const PACKET_ID: i32 = #input;
|
const PACKET_ID: i32 = #input;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -131,6 +131,32 @@ pub fn pumpkin_block(input: TokenStream, item: TokenStream) -> TokenStream {
|
|||||||
gen.into()
|
gen.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[proc_macro_attribute]
|
||||||
|
pub fn pumpkin_item(input: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
|
let ast: syn::DeriveInput = syn::parse(item.clone()).unwrap();
|
||||||
|
let name = &ast.ident;
|
||||||
|
let (impl_generics, ty_generics, _) = ast.generics.split_for_impl();
|
||||||
|
|
||||||
|
let input_string = input.to_string();
|
||||||
|
let packet_name = input_string.trim_matches('"');
|
||||||
|
let packet_name_split: Vec<&str> = packet_name.split(":").collect();
|
||||||
|
|
||||||
|
let namespace = packet_name_split[0];
|
||||||
|
let id = packet_name_split[1];
|
||||||
|
|
||||||
|
let item: proc_macro2::TokenStream = item.into();
|
||||||
|
|
||||||
|
let gen = quote! {
|
||||||
|
#item
|
||||||
|
impl #impl_generics crate::block::pumpkin_block::BlockMetadata for #name #ty_generics {
|
||||||
|
const NAMESPACE: &'static str = #namespace;
|
||||||
|
const ID: &'static str = #id;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
gen.into()
|
||||||
|
}
|
||||||
|
|
||||||
mod block_state;
|
mod block_state;
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn block_state(item: TokenStream) -> TokenStream {
|
pub fn block_state(item: TokenStream) -> TokenStream {
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use bytes::{Buf, BufMut};
|
|||||||
|
|
||||||
mod deserializer;
|
mod deserializer;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
pub mod packet_id;
|
pub mod packet;
|
||||||
mod serializer;
|
mod serializer;
|
||||||
|
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
mod c_add_resource_pack;
|
mod add_resource_pack;
|
||||||
mod c_config_disconnect;
|
mod config_disconnect;
|
||||||
mod c_cookie_request;
|
mod cookie_request;
|
||||||
mod c_finish_config;
|
mod finish_config;
|
||||||
mod c_known_packs;
|
mod known_packs;
|
||||||
mod c_plugin_message;
|
mod plugin_message;
|
||||||
mod c_registry_data;
|
mod registry_data;
|
||||||
mod c_server_links;
|
mod server_links;
|
||||||
mod c_store_cookie;
|
mod store_cookie;
|
||||||
mod c_transfer;
|
mod transfer;
|
||||||
|
|
||||||
pub use c_add_resource_pack::*;
|
pub use add_resource_pack::*;
|
||||||
pub use c_config_disconnect::*;
|
pub use config_disconnect::*;
|
||||||
pub use c_cookie_request::*;
|
pub use cookie_request::*;
|
||||||
pub use c_finish_config::*;
|
pub use finish_config::*;
|
||||||
pub use c_known_packs::*;
|
pub use known_packs::*;
|
||||||
pub use c_plugin_message::*;
|
pub use plugin_message::*;
|
||||||
pub use c_registry_data::*;
|
pub use registry_data::*;
|
||||||
pub use c_server_links::*;
|
pub use server_links::*;
|
||||||
pub use c_store_cookie::*;
|
pub use store_cookie::*;
|
||||||
pub use c_transfer::*;
|
pub use transfer::*;
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
mod c_cookie_request;
|
mod cookie_request;
|
||||||
mod c_encryption_request;
|
mod encryption_request;
|
||||||
mod c_login_disconnect;
|
mod login_disconnect;
|
||||||
mod c_login_success;
|
mod login_success;
|
||||||
mod c_plugin_request;
|
mod plugin_request;
|
||||||
mod c_set_compression;
|
mod set_compression;
|
||||||
|
|
||||||
pub use c_cookie_request::*;
|
pub use cookie_request::*;
|
||||||
pub use c_encryption_request::*;
|
pub use encryption_request::*;
|
||||||
pub use c_login_disconnect::*;
|
pub use login_disconnect::*;
|
||||||
pub use c_login_success::*;
|
pub use login_success::*;
|
||||||
pub use c_plugin_request::*;
|
pub use plugin_request::*;
|
||||||
pub use c_set_compression::*;
|
pub use set_compression::*;
|
||||||
|
|||||||
@ -1,147 +1,147 @@
|
|||||||
|
mod acknowledge_block;
|
||||||
|
mod actionbar;
|
||||||
|
mod block_destroy_stage;
|
||||||
|
mod block_event;
|
||||||
|
mod block_update;
|
||||||
|
mod boss_event;
|
||||||
mod bossevent_action;
|
mod bossevent_action;
|
||||||
mod c_acknowledge_block;
|
mod center_chunk;
|
||||||
mod c_actionbar;
|
mod change_difficulty;
|
||||||
mod c_block_destroy_stage;
|
mod chunk_data;
|
||||||
mod c_block_event;
|
mod clear_title;
|
||||||
mod c_block_update;
|
mod close_container;
|
||||||
mod c_boss_event;
|
mod combat_death;
|
||||||
mod c_center_chunk;
|
mod command_suggestions;
|
||||||
mod c_change_difficulty;
|
mod commands;
|
||||||
mod c_chunk_data;
|
mod cookie_request;
|
||||||
mod c_clear_title;
|
mod damage_event;
|
||||||
mod c_close_container;
|
mod disconnect;
|
||||||
mod c_combat_death;
|
mod disguised_chat_message;
|
||||||
mod c_command_suggestions;
|
mod display_objective;
|
||||||
mod c_commands;
|
mod entity_animation;
|
||||||
mod c_cookie_request;
|
mod entity_metadata;
|
||||||
mod c_damage_event;
|
mod entity_sound_effect;
|
||||||
mod c_disguised_chat_message;
|
mod entity_status;
|
||||||
mod c_display_objective;
|
mod entity_velocity;
|
||||||
mod c_entity_animation;
|
mod game_event;
|
||||||
mod c_entity_metadata;
|
mod head_rot;
|
||||||
mod c_entity_sound_effect;
|
mod hurt_animation;
|
||||||
mod c_entity_status;
|
mod initialize_world_border;
|
||||||
mod c_entity_velocity;
|
mod keep_alive;
|
||||||
mod c_game_event;
|
mod level_event;
|
||||||
mod c_head_rot;
|
mod login;
|
||||||
mod c_hurt_animation;
|
mod open_screen;
|
||||||
mod c_initialize_world_border;
|
mod particle;
|
||||||
mod c_keep_alive;
|
mod ping_response;
|
||||||
mod c_level_event;
|
mod player_abilities;
|
||||||
mod c_login;
|
|
||||||
mod c_open_screen;
|
|
||||||
mod c_particle;
|
|
||||||
mod c_ping_response;
|
|
||||||
mod c_play_disconnect;
|
|
||||||
mod c_player_abilities;
|
|
||||||
mod c_player_chat_message;
|
|
||||||
mod c_player_info_update;
|
|
||||||
mod c_player_position;
|
|
||||||
mod c_player_remove;
|
|
||||||
mod c_remove_entities;
|
|
||||||
mod c_reset_score;
|
|
||||||
mod c_respawn;
|
|
||||||
mod c_server_links;
|
|
||||||
mod c_set_border_center;
|
|
||||||
mod c_set_border_lerp_size;
|
|
||||||
mod c_set_border_size;
|
|
||||||
mod c_set_border_warning_delay;
|
|
||||||
mod c_set_border_warning_distance;
|
|
||||||
mod c_set_container_content;
|
|
||||||
mod c_set_container_property;
|
|
||||||
mod c_set_container_slot;
|
|
||||||
mod c_set_experience;
|
|
||||||
mod c_set_health;
|
|
||||||
mod c_set_held_item;
|
|
||||||
mod c_set_time;
|
|
||||||
mod c_set_title;
|
|
||||||
mod c_sound_effect;
|
|
||||||
mod c_spawn_entity;
|
|
||||||
mod c_store_cookie;
|
|
||||||
mod c_subtitle;
|
|
||||||
mod c_system_chat_message;
|
|
||||||
mod c_take_item;
|
|
||||||
mod c_teleport_entity;
|
|
||||||
mod c_transfer;
|
|
||||||
mod c_unload_chunk;
|
|
||||||
mod c_update_entity_pos;
|
|
||||||
mod c_update_entity_pos_rot;
|
|
||||||
mod c_update_entity_rot;
|
|
||||||
mod c_update_objectives;
|
|
||||||
mod c_update_score;
|
|
||||||
mod c_worldevent;
|
|
||||||
mod player_action;
|
mod player_action;
|
||||||
|
mod player_chat_message;
|
||||||
|
mod player_info_update;
|
||||||
|
mod player_position;
|
||||||
|
mod player_remove;
|
||||||
|
mod remove_entities;
|
||||||
|
mod reset_score;
|
||||||
|
mod respawn;
|
||||||
|
mod server_links;
|
||||||
|
mod set_border_center;
|
||||||
|
mod set_border_lerp_size;
|
||||||
|
mod set_border_size;
|
||||||
|
mod set_border_warning_delay;
|
||||||
|
mod set_border_warning_distance;
|
||||||
|
mod set_container_content;
|
||||||
|
mod set_container_property;
|
||||||
|
mod set_container_slot;
|
||||||
|
mod set_experience;
|
||||||
|
mod set_health;
|
||||||
|
mod set_held_item;
|
||||||
|
mod set_time;
|
||||||
|
mod set_title;
|
||||||
|
mod sound_effect;
|
||||||
|
mod spawn_entity;
|
||||||
|
mod store_cookie;
|
||||||
|
mod subtitle;
|
||||||
|
mod system_chat_message;
|
||||||
|
mod take_item;
|
||||||
|
mod teleport_entity;
|
||||||
|
mod transfer;
|
||||||
|
mod unload_chunk;
|
||||||
|
mod update_entity_pos;
|
||||||
|
mod update_entity_pos_rot;
|
||||||
|
mod update_entity_rot;
|
||||||
|
mod update_objectives;
|
||||||
|
mod update_score;
|
||||||
|
mod worldevent;
|
||||||
|
|
||||||
|
pub use acknowledge_block::*;
|
||||||
|
pub use actionbar::*;
|
||||||
|
pub use block_destroy_stage::*;
|
||||||
|
pub use block_event::*;
|
||||||
|
pub use block_update::*;
|
||||||
|
pub use boss_event::*;
|
||||||
pub use bossevent_action::*;
|
pub use bossevent_action::*;
|
||||||
pub use c_acknowledge_block::*;
|
pub use center_chunk::*;
|
||||||
pub use c_actionbar::*;
|
pub use change_difficulty::*;
|
||||||
pub use c_block_destroy_stage::*;
|
pub use chunk_data::*;
|
||||||
pub use c_block_event::*;
|
pub use clear_title::*;
|
||||||
pub use c_block_update::*;
|
pub use close_container::*;
|
||||||
pub use c_boss_event::*;
|
pub use combat_death::*;
|
||||||
pub use c_center_chunk::*;
|
pub use command_suggestions::*;
|
||||||
pub use c_change_difficulty::*;
|
pub use commands::*;
|
||||||
pub use c_chunk_data::*;
|
pub use cookie_request::*;
|
||||||
pub use c_clear_title::*;
|
pub use damage_event::*;
|
||||||
pub use c_close_container::*;
|
pub use disconnect::*;
|
||||||
pub use c_combat_death::*;
|
pub use disguised_chat_message::*;
|
||||||
pub use c_command_suggestions::*;
|
pub use display_objective::*;
|
||||||
pub use c_commands::*;
|
pub use entity_animation::*;
|
||||||
pub use c_cookie_request::*;
|
pub use entity_metadata::*;
|
||||||
pub use c_damage_event::*;
|
pub use entity_sound_effect::*;
|
||||||
pub use c_disguised_chat_message::*;
|
pub use entity_status::*;
|
||||||
pub use c_display_objective::*;
|
pub use entity_velocity::*;
|
||||||
pub use c_entity_animation::*;
|
pub use game_event::*;
|
||||||
pub use c_entity_metadata::*;
|
pub use head_rot::*;
|
||||||
pub use c_entity_sound_effect::*;
|
pub use hurt_animation::*;
|
||||||
pub use c_entity_status::*;
|
pub use initialize_world_border::*;
|
||||||
pub use c_entity_velocity::*;
|
pub use keep_alive::*;
|
||||||
pub use c_game_event::*;
|
pub use level_event::*;
|
||||||
pub use c_head_rot::*;
|
pub use login::*;
|
||||||
pub use c_hurt_animation::*;
|
pub use open_screen::*;
|
||||||
pub use c_initialize_world_border::*;
|
pub use particle::*;
|
||||||
pub use c_keep_alive::*;
|
pub use ping_response::*;
|
||||||
pub use c_level_event::*;
|
pub use player_abilities::*;
|
||||||
pub use c_login::*;
|
|
||||||
pub use c_open_screen::*;
|
|
||||||
pub use c_particle::*;
|
|
||||||
pub use c_ping_response::*;
|
|
||||||
pub use c_play_disconnect::*;
|
|
||||||
pub use c_player_abilities::*;
|
|
||||||
pub use c_player_chat_message::*;
|
|
||||||
pub use c_player_info_update::*;
|
|
||||||
pub use c_player_position::*;
|
|
||||||
pub use c_player_remove::*;
|
|
||||||
pub use c_remove_entities::*;
|
|
||||||
pub use c_reset_score::*;
|
|
||||||
pub use c_respawn::*;
|
|
||||||
pub use c_server_links::*;
|
|
||||||
pub use c_set_border_center::*;
|
|
||||||
pub use c_set_border_lerp_size::*;
|
|
||||||
pub use c_set_border_size::*;
|
|
||||||
pub use c_set_border_warning_delay::*;
|
|
||||||
pub use c_set_border_warning_distance::*;
|
|
||||||
pub use c_set_container_content::*;
|
|
||||||
pub use c_set_container_property::*;
|
|
||||||
pub use c_set_container_slot::*;
|
|
||||||
pub use c_set_experience::*;
|
|
||||||
pub use c_set_health::*;
|
|
||||||
pub use c_set_held_item::*;
|
|
||||||
pub use c_set_time::*;
|
|
||||||
pub use c_set_title::*;
|
|
||||||
pub use c_sound_effect::*;
|
|
||||||
pub use c_spawn_entity::*;
|
|
||||||
pub use c_store_cookie::*;
|
|
||||||
pub use c_subtitle::*;
|
|
||||||
pub use c_system_chat_message::*;
|
|
||||||
pub use c_take_item::*;
|
|
||||||
pub use c_teleport_entity::*;
|
|
||||||
pub use c_transfer::*;
|
|
||||||
pub use c_unload_chunk::*;
|
|
||||||
pub use c_update_entity_pos::*;
|
|
||||||
pub use c_update_entity_pos_rot::*;
|
|
||||||
pub use c_update_entity_rot::*;
|
|
||||||
pub use c_update_objectives::*;
|
|
||||||
pub use c_update_score::*;
|
|
||||||
pub use c_worldevent::*;
|
|
||||||
pub use player_action::*;
|
pub use player_action::*;
|
||||||
|
pub use player_chat_message::*;
|
||||||
|
pub use player_info_update::*;
|
||||||
|
pub use player_position::*;
|
||||||
|
pub use player_remove::*;
|
||||||
|
pub use remove_entities::*;
|
||||||
|
pub use reset_score::*;
|
||||||
|
pub use respawn::*;
|
||||||
|
pub use server_links::*;
|
||||||
|
pub use set_border_center::*;
|
||||||
|
pub use set_border_lerp_size::*;
|
||||||
|
pub use set_border_size::*;
|
||||||
|
pub use set_border_warning_delay::*;
|
||||||
|
pub use set_border_warning_distance::*;
|
||||||
|
pub use set_container_content::*;
|
||||||
|
pub use set_container_property::*;
|
||||||
|
pub use set_container_slot::*;
|
||||||
|
pub use set_experience::*;
|
||||||
|
pub use set_health::*;
|
||||||
|
pub use set_held_item::*;
|
||||||
|
pub use set_time::*;
|
||||||
|
pub use set_title::*;
|
||||||
|
pub use sound_effect::*;
|
||||||
|
pub use spawn_entity::*;
|
||||||
|
pub use store_cookie::*;
|
||||||
|
pub use subtitle::*;
|
||||||
|
pub use system_chat_message::*;
|
||||||
|
pub use take_item::*;
|
||||||
|
pub use teleport_entity::*;
|
||||||
|
pub use transfer::*;
|
||||||
|
pub use unload_chunk::*;
|
||||||
|
pub use update_entity_pos::*;
|
||||||
|
pub use update_entity_pos_rot::*;
|
||||||
|
pub use update_entity_rot::*;
|
||||||
|
pub use update_objectives::*;
|
||||||
|
pub use update_score::*;
|
||||||
|
pub use worldevent::*;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
mod c_ping_response;
|
mod ping_response;
|
||||||
mod c_status_response;
|
mod status_response;
|
||||||
|
|
||||||
pub use c_ping_response::*;
|
pub use ping_response::*;
|
||||||
pub use c_status_response::*;
|
pub use status_response::*;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use std::num::NonZeroU16;
|
use std::num::NonZeroU16;
|
||||||
|
|
||||||
use bytebuf::{packet_id::Packet, ReadingError};
|
use bytebuf::{packet::Packet, ReadingError};
|
||||||
use bytes::{Buf, BufMut, Bytes};
|
use bytes::{Buf, BufMut, Bytes};
|
||||||
use codec::{identifier::Identifier, var_int::VarInt};
|
use codec::{identifier::Identifier, var_int::VarInt};
|
||||||
use pumpkin_util::text::{style::Style, TextComponent};
|
use pumpkin_util::text::{style::Style, TextComponent};
|
||||||
|
|||||||
@ -216,7 +216,7 @@ pub enum PacketEncodeError {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::client::status::CStatusResponse;
|
use crate::client::status::CStatusResponse;
|
||||||
use crate::{bytebuf::packet_id::Packet, codec::DecodeError};
|
use crate::{bytebuf::packet::Packet, codec::DecodeError};
|
||||||
use aes::Aes128;
|
use aes::Aes128;
|
||||||
use cfb8::cipher::AsyncStreamCipher;
|
use cfb8::cipher::AsyncStreamCipher;
|
||||||
use cfb8::Decryptor as Cfb8Decryptor;
|
use cfb8::Decryptor as Cfb8Decryptor;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user