Skip to main content

Module builder

Module builder 

Source
Expand description

A declarative builder for assembling MenuBehaviors.

use steel_registry::{vanilla_items, vanilla_menu_types};
use steel_core::{inventory::menu::kinds::BasicKind, player::player_inventory::PlayerInventory};

use steel_core::inventory::prelude::*;

fn example(container_id: u8, inventory: Shared<PlayerInventory>) -> Menu {
    let mut builder = MenuBuilder::new(&vanilla_menu_types::GENERIC_9X1, container_id);

    let items = vec![ItemStack::new(&vanilla_items::FLINT_AND_STEEL); 9];
    let container = SimpleContainer::from_items(items).into_shared();

    let section = builder.section_all(container);

    let player = builder.player_inventory(&inventory);
    let level_cost = builder.data_slot(0);

    builder.route(section, player.all(), FillDirection::Backward);
    builder.route(player.all(), section, FillDirection::Forward);

    builder.build(BasicKind)
}

Structs§

ContainerSlots
The not-yet-carved slots of a container being split across multiple sections.
DataSlot
A data slot handle created by the MenuBuilder::data_slot, to use for easy access instead of a bare index.
MenuBuilder
Builds a Menu.
MenuInstanceId 🔒
Identity of one built menu.
PlayerInventorySections
The sections that cover the player’s inventory.
Route 🔒
A shift clicking Route that goes from a single Range to a Vec of Ranges.
Section
A handle to a contiguous range of slots added to a MenuBuilder.

Enums§

FakeResultRemainderPolicy
What to do with fake result output that cannot fit during a shift-click.
FillDirection
The direction in which a slot range is walked when distributing items.
SectionKind
How a section lowers container indices into menu slots.

Traits§

IntoSections
Converts different types into an Iterator of sections so they can be passed into MenuBuilder::route
SectionSource
A supplier for ranges of slots in a ContainerRef. Allowing either making the whole Container a Section or splitting one Container into multiple Sections.

Functions§

deny_all_rules 🔒
Rules that reject both placement and pickup, shared process-wide.
deny_place_rules 🔒
Rules that reject placement and allow pickup, shared process-wide.

Type Aliases§

SlotFactory
Produces the slot for one container index of a section.