Skip to main content

PlaceProvider

Trait PlaceProvider 

pub trait PlaceProvider:
    Send
    + Sync
    + 'static {
    // Required methods
    fn stack(&self, host: &mut dyn ServerHost, key: u64) -> Option<ItemStack>;
    fn insert(
        &self,
        host: &mut dyn ServerHost,
        tx: &Transaction,
        key: u64,
        resource: &ItemResource,
        amount: u32,
    ) -> u32;
    fn extract(
        &self,
        host: &mut dyn ServerHost,
        tx: &Transaction,
        key: u64,
        resource: &ItemResource,
        amount: u32,
    ) -> u32;
}
Expand description

A mod’s own places (ItemPlace::Mod), registered with Registrar::place_provider: NeoForge’s own ItemAccesss. Like a handler, it holds no borrow: its stacks live where the mod keeps them (a player’s attachments). While its mod is disabled, lookups refuse both reads and writes through its places; re-enabling the mod makes the same registrations available again.

Required Methods§

fn stack(&self, host: &mut dyn ServerHost, key: u64) -> Option<ItemStack>

The stack at key, if any.

fn insert( &self, host: &mut dyn ServerHost, tx: &Transaction, key: u64, resource: &ItemResource, amount: u32, ) -> u32

Puts up to amount of resource at key, in transaction tx: how much went. What doesn’t stack with what is there may go where the mod puts it, such as the player’s inventory (ItemAccess.insert); none where key is no longer a place.

fn extract( &self, host: &mut dyn ServerHost, tx: &Transaction, key: u64, resource: &ItemResource, amount: u32, ) -> u32

Takes up to amount of resource from key, in transaction tx: how much came.

Trait Implementations§

§

impl Wire for Box<dyn PlaceProvider>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Box<dyn PlaceProvider>, WireError>

Decodes one value, leaving any following bytes for the caller.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§