Skip to main content

Module pattern_provider

Module pattern_provider 

Source
Expand description

The Computer Pattern Provider: autocrafting patterns for Applied Energistics 2 that a program fulfils.

The block exists when AE2 is installed alongside the wackasm mod. It’s an ME network device and an OpenComputers component (pattern_provider) at once:

  1. The program declares processing patterns (PatternProvider::set_patterns). AE2 sees them as ordinary processing patterns: they show up as craftable, and the crafting planner uses them.
  2. When a crafting job needs one, AE2 hands the block the inputs. The block holds them as a Job and sends Signal::PatternRequest.
  3. The program moves the inputs out (PatternProvider::push_inputs), does the work, and gets the outputs imported into the ME network: through an ME Interface, an import bus, or by inserting them into this block (with a transposer, say), which forwards them. AE2’s crafting CPUs claim them as they arrive, the same as for any processing pattern.

Nothing creates items: the outputs have to come from somewhere real.

use wackasm_opencomputers::prelude::*;
use wackasm_opencomputers::pattern_provider::{Pattern, PatternProvider, Stack};

let provider = PatternProvider::first().expect("no pattern provider");
provider.set_patterns(&[Pattern::new(
    vec![Stack::item("minecraft:cobblestone", 1)],
    vec![Stack::item("minecraft:stone", 1)],
)])?;
loop {
    // Jobs from before this program started are waiting too.
    for job in provider.jobs()? {
        provider.push_inputs(job.id, Side::Top)?; // into a furnace, say
    }
    signal::pull_filtered(None, |s| matches!(s, Signal::PatternRequest { .. }));
}

Structs§

Job
One use of a pattern that AE2 handed over.
Pattern
A processing pattern: AE2 hands over inputs and expects outputs back. It needs at least one input (AE2 requires it) and at least one output; the first output is the one AE2 lists it under.
PatternProvider
The pattern_provider component.
Stack
An item or fluid and an amount.