add development command for opening a global enderchest

This commit is contained in:
Edvin Bryntesson 2024-08-31 11:57:13 +02:00
parent f34a483118
commit 909943bb5d
No known key found for this signature in database
2 changed files with 33 additions and 0 deletions

View 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(())
})
}

View File

@ -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
}