Files
satistaskory/docs/03-Architecture/🔌 Recipe Provider.md
T
Stephen Fasciani 149e3619bf
Build / build (push) Failing after 27s
Record one-level resolution: the player walks the tree with Add.
A turtle names a computer. The next layer is another hover, not recursion.
2026-09-08 05:23:32 -04:00

91 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 🔌 Recipe Provider
Port used by [[🧾 Recipe Resolution]].
The domain asks: *what materials produce this many of this item?*
Infrastructure answers. The domain never imports a recipe **viewer** (EMI/JEI/REI). Lookup is Minecraft’s `RecipeManager`.
---
## Shape
```text
RecipeProvider
resolve(ItemId target, int quantity)
→ list of MaterialRequirement
```
`ItemId` is `namespace:path` (e.g. `minecraft:furnace`). Not `net.minecraft.world.item.Item`.
`MaterialRequirement` is `(ItemId, quantity)`.
---
## Contract
| Case | Result |
|------|--------|
| `quantity < 1` | Empty list |
| Item has a recipe | **One crafting level** of ingredients, already scaled for `quantity` (including recipe output count) |
| Item has no recipe | One requirement: `(target, quantity)` — a gather |
| Several recipes exist | Provider picks **one**. Recipe choice is not in the slice |
| Ingredient is a tag | Provider returns **concrete** ItemIds. Tags are not a domain type yet |
Not a recipe tree. Not a recipe browser.
**One level is the product.** A turtle resolves to a computer, not to the stone that made the computer. The player who wants the next layer hovers that computer (craft book, inventory, or whatever already shows the item) and presses Add. That is another [[▶️ Create Goal]], not recursion in this port.
Dependency chains as an auto-expanded tree remain an expanded view, not this port.
Lookup is **by output item**, across **every** `RecipeType` in `RecipeManager`, not only `minecraft:crafting`. Custom types (`computercraft:…`, `ae2:inscriber`, …) still live in `RecipeManager` if the mod registered them. Prefer a crafting-table recipe when several types match; otherwise pick one (ADR-014).
Acceptance when `VanillaRecipeProvider` ships:
- A **CC:Tweaked turtle** resolves to its registered ingredients (computer, chest, ingots — one level, not the computer’s own recipe).
- An **AE2** item that has a `RecipeManager` entry (crafting *or* inscriber) resolves to those ingredients. Processors are inscriber recipes, still in `RecipeManager`, not in EMI.
Catalysts (AE2 press not consumed) are not modelled yet. The adapter may list them as requirements until the domain grows a “not consumed” flag. That is honesty, not a viewer dependency.
---
## First implementation: stub
`StubRecipeProvider` in `infrastructure.recipe` — three shaped recipes plus gather. Shipped.
Next: `VanillaRecipeProvider` over `RecipeManager` (vanilla and modded recipes registered with Minecraft). See ADR-016.
EMI / JEI / REI are not implementations and not Gradle dependencies.
---
## Who calls it
[[📈 Progress Calculation]] (via [[🧾 Recipe Resolution]]):
```text
remaining = max(0, goal.quantity − available(goal.item))
requirements = RecipeProvider.resolve(goal.item, remaining)
```
Then aggregate. Then `Missing = Required − Available`.
Owned finished goods reduce **how many to resolve**. They are not subtracted again from ingredients.
---
## Related Documents
[[🧾 Recipe Resolution]]
[[🧱 Material Requirement]]
[[📈 Progress Calculation]]
[[🏛️ Architecture]]
[[📦 Packages]]
[[📝 Decisions]]
[[🎯 Goal]]