add development command for opening a global enderchest
This commit is contained in:
parent
f34a483118
commit
909943bb5d
31
pumpkin/src/commands/cmd_echest.rs
Normal file
31
pumpkin/src/commands/cmd_echest.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use pumpkin_inventory::OpenContainer;
|
||||
|
||||
use crate::commands::tree::CommandTree;
|
||||
|
||||
const NAMES: [&str; 2] = ["echest", "enderchest"];
|
||||
|
||||
const DESCRIPTION: &str =
|
||||
"Show your personal enderchest (this command is used for testing container behaviour)";
|
||||
|
||||
pub(crate) fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, server, _| {
|
||||
if let Some(player) = sender.as_mut_player() {
|
||||
if let Some(container) = server
|
||||
.open_containers
|
||||
.entry(0)
|
||||
.or_insert(OpenContainer::empty(player.entity_id()))
|
||||
.try_open(player.entity_id())
|
||||
{
|
||||
player.open_container(
|
||||
container.window_type(),
|
||||
"minecraft:generic_9x3",
|
||||
Some("Ender Chest"),
|
||||
Some(container.all_slots_ref()),
|
||||
None,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
@ -6,6 +6,7 @@ use crate::commands::dispatcher::CommandDispatcher;
|
||||
use crate::entity::player::Player;
|
||||
use crate::server::Server;
|
||||
mod arg_player;
|
||||
mod cmd_echest;
|
||||
mod cmd_gamemode;
|
||||
mod cmd_help;
|
||||
mod cmd_pumpkin;
|
||||
@ -80,6 +81,7 @@ fn dispatcher_init<'a>() -> CommandDispatcher<'a> {
|
||||
dispatcher.register(cmd_gamemode::init_command_tree());
|
||||
dispatcher.register(cmd_stop::init_command_tree());
|
||||
dispatcher.register(cmd_help::init_command_tree());
|
||||
dispatcher.register(cmd_echest::init_command_tree());
|
||||
|
||||
dispatcher
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user