VanillaRecipeProvider scans every RecipeType by output, prefers crafting-table recipes, and falls back to gather. Stub stays in unit tests. Overlay still HUD; persistence still RAM.
This commit is contained in:
@@ -40,7 +40,7 @@ Read [[🧠 Philosophy]] before changing the vault. The Bookshelf Principle, Pre
|
|||||||
|
|
||||||
## Code
|
## Code
|
||||||
|
|
||||||
The first slice is in code and has been played (ADRs 012–015): [[▶️ Create Goal]], stub [[🔌 Recipe Provider]], overlay HUD, capture = tooltip + rebindable Add key.
|
The first slice is in code and has been played (ADRs 012–016): [[▶️ Create Goal]], [[🔌 Recipe Provider]] via `RecipeManager`, overlay HUD, capture = tooltip + rebindable Add key.
|
||||||
|
|
||||||
Do not start EMI/JEI/REI. Recipe source is `RecipeManager` (ADR-016). Persistence and Project wait until settled. Do not rewrite the overlay as a `Screen` unless the HUD path fails.
|
Do not start EMI/JEI/REI. Recipe source is `RecipeManager` (ADR-016). Persistence and Project wait until settled. Do not rewrite the overlay as a `Screen` unless the HUD path fails.
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ Those may be integrated with later. They are not owned by Satistaskory.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
First slice is in `src/` and has been played: domain, stub recipes, in-memory plan, overlay on the right, hover + Add key (default `=`).
|
First slice is in `src/` and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, one level), in-memory plan, overlay on the right, hover + Add key (default `=`).
|
||||||
|
|
||||||
`/satistaskory add minecraft:furnace` is a debug command. The plan is RAM-only. Not EMI. Template example block/item is gone.
|
`/satistaskory add minecraft:furnace` is a debug command. The plan is RAM-only. Not EMI. Template example block/item is gone.
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ Examples:
|
|||||||
- Save data storage
|
- Save data storage
|
||||||
- Inventory scanning
|
- Inventory scanning
|
||||||
|
|
||||||
Shipped this slice: `StubRecipeProvider`, player-inventory snapshot, HUD overlay, tooltip+key capture. No save adapter yet. EMI/JEI/REI are not dependencies.
|
Shipped this slice: `VanillaRecipeProvider` (`RecipeManager`, all types, one level), player-inventory snapshot, HUD overlay, tooltip+key capture. `StubRecipeProvider` is unit tests only. No save adapter yet. EMI/JEI/REI are not dependencies.
|
||||||
|
|
||||||
Infrastructure is never the source of domain truth.
|
Infrastructure is never the source of domain truth.
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ The domain should never import a recipe viewer.
|
|||||||
|
|
||||||
Port: [[🔌 Recipe Provider]] — `resolve(ItemId, quantity) → list of MaterialRequirement`.
|
Port: [[🔌 Recipe Provider]] — `resolve(ItemId, quantity) → list of MaterialRequirement`.
|
||||||
|
|
||||||
Shipped: `StubRecipeProvider`. Next: `VanillaRecipeProvider` on `RecipeManager`. EMI/JEI/REI are not required. See ADR-016.
|
Shipped: `VanillaRecipeProvider` on `RecipeManager`. EMI/JEI/REI are not required. See ADR-016.
|
||||||
|
|
||||||
Recipe viewing is out of scope. This port exists so the domain can resolve requirements, not so Satistaskory can become a recipe browser.
|
Recipe viewing is out of scope. This port exists so the domain can resolve requirements, not so Satistaskory can become a recipe browser.
|
||||||
|
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ A button next to the slot vanishes when the cursor leaves the item. A `Screen` r
|
|||||||
|
|
||||||
**Decision:** Satistaskory does **not** depend on EMI, JEI, or REI.
|
**Decision:** Satistaskory does **not** depend on EMI, JEI, or REI.
|
||||||
|
|
||||||
Recipe lookup for [[🔌 Recipe Provider]] is Minecraft’s `RecipeManager` (vanilla + every mod that registers recipes through that API). Scan **by output** across **all** recipe types, not only `minecraft:crafting`. Next implementation after the stub: `VanillaRecipeProvider`.
|
Recipe lookup for [[🔌 Recipe Provider]] is Minecraft’s `RecipeManager` (vanilla + every mod that registers recipes through that API). Scan **by output** across **all** recipe types, not only `minecraft:crafting`. Implementation: `VanillaRecipeProvider`. `StubRecipeProvider` remains for unit tests.
|
||||||
|
|
||||||
Examples that must work without EMI: CC:Tweaked turtle, AE2 crafting and inscriber items.
|
Examples that must work without EMI: CC:Tweaked turtle, AE2 crafting and inscriber items.
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ com.sufficient.satistaskory
|
|||||||
|
|
||||||
infrastructure/
|
infrastructure/
|
||||||
recipe/
|
recipe/
|
||||||
StubRecipeProvider # furnace, crafting_table, chest; else gather
|
VanillaRecipeProvider # RecipeManager, all types, by output
|
||||||
|
StubRecipeProvider # unit tests only
|
||||||
inventory/
|
inventory/
|
||||||
PlayerInventoryAdapter # player inventory → InventoryState
|
PlayerInventoryAdapter # player inventory → InventoryState
|
||||||
client/
|
client/
|
||||||
@@ -49,7 +50,6 @@ Dependencies point inward: `infrastructure` and `application` may import `domain
|
|||||||
|---------|-----|
|
|---------|-----|
|
||||||
| `Project` | Organizational only; not in the slice |
|
| `Project` | Organizational only; not in the slice |
|
||||||
| Completion strategy | Ready ≠ complete; complete is not in the slice |
|
| Completion strategy | Ready ≠ complete; complete is not in the slice |
|
||||||
| `VanillaRecipeProvider` | Next recipe impl; `RecipeManager` |
|
|
||||||
| Persistence | In-memory goals. ADR-004 still holds; no save adapter yet |
|
| Persistence | In-memory goals. ADR-004 still holds; no save adapter yet |
|
||||||
| Full-screen planner | Not discovered |
|
| Full-screen planner | Not discovered |
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ Dependency chains as an auto-expanded tree remain an expanded view, not this por
|
|||||||
|
|
||||||
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).
|
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:
|
Acceptance:
|
||||||
|
|
||||||
- A **CC:Tweaked turtle** resolves to its registered ingredients (computer, chest, ingots — one level, not the computer’s own recipe).
|
- 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.
|
- 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.
|
||||||
@@ -48,11 +48,11 @@ Catalysts (AE2 press not consumed) are not modelled yet. The adapter may list th
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## First implementation: stub
|
## Shipped implementation
|
||||||
|
|
||||||
`StubRecipeProvider` in `infrastructure.recipe` — three shaped recipes plus gather. Shipped.
|
`VanillaRecipeProvider` over `RecipeManager` (all types, by output). Crafting-table recipes preferred when several match; else first highest score. Empty `getIngredients()` → gather.
|
||||||
|
|
||||||
Next: `VanillaRecipeProvider` over `RecipeManager` (vanilla and modded recipes registered with Minecraft). See ADR-016.
|
`StubRecipeProvider` remains for unit tests.
|
||||||
|
|
||||||
EMI / JEI / REI are not implementations and not Gradle dependencies.
|
EMI / JEI / REI are not implementations and not Gradle dependencies.
|
||||||
|
|
||||||
|
|||||||
@@ -6,22 +6,19 @@ What exists, and what is next. Implementation detail will live in an Implementat
|
|||||||
|
|
||||||
## ✅ Now (docs)
|
## ✅ Now (docs)
|
||||||
|
|
||||||
- Philosophy Rules #1–#10; ADRs **001–014**
|
- Philosophy Rules #1–#10; ADRs **001–016**
|
||||||
- Vision, ubiquitous language, bounded context (one: Goal Planning)
|
- Vision, ubiquitous language, bounded context (one: Goal Planning)
|
||||||
- Goal invariants: one per ItemId, quantity ≥ 1, create at 1 / +1, `[-]` at 1 removes
|
- Goal invariants: one per ItemId, quantity ≥ 1, create at 1 / +1, `[-]` at 1 removes
|
||||||
- Packages named; [[🔌 Recipe Provider]] sketched; [[▶️ Create Goal]] written
|
- Packages named; [[🔌 Recipe Provider]] sketched; [[▶️ Create Goal]] written
|
||||||
- Experience: capture in place; overlay on the right (goals + aggregated needed counts)
|
- Experience: capture in place; overlay on the right (goals + aggregated needed counts)
|
||||||
|
|
||||||
First slice **code exists** and has been played: domain, stub `RecipeProvider` (furnace / crafting table / chest; else gather), in-memory `Planner`, player inventory, play overlay on the right. Capture is hover + rebindable Add key (default `=`). `/satistaskory add` is a debug caller. Plan does not survive restart.
|
First slice **code exists** and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, all types, one level), in-memory `Planner`, player inventory, play overlay, hover + Add key. Plan does not survive restart.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🔲 Next
|
## 🔲 Next
|
||||||
|
|
||||||
The walk is real.
|
|
||||||
|
|
||||||
1. World-save persistence
|
1. World-save persistence
|
||||||
2. Vanilla `RecipeProvider` on `RecipeManager` (one crafting level). No EMI/JEI/REI.
|
|
||||||
|
|
||||||
EMI is not a dependency. See ADR-016.
|
EMI is not a dependency. See ADR-016.
|
||||||
|
|
||||||
|
|||||||
@@ -353,6 +353,20 @@ EMI may be where they *see* the computer. Capture still does not depend on EMI;
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 📜 2026-09-08 (VanillaRecipeProvider)
|
||||||
|
|
||||||
|
Greetings, Wayfinder.
|
||||||
|
|
||||||
|
`PlannerSession` now asks `VanillaRecipeProvider`. It scans every `RecipeType` in `RecipeManager` by output, one level, crafting-table preferred. Empty ingredients still gather.
|
||||||
|
|
||||||
|
`StubRecipeProvider` is tests only. Oak planks as a goal should now be logs (or the first tag member), not more planks.
|
||||||
|
|
||||||
|
Play on the gaming PC: furnace, crafting table, chest, oak planks, then a CC turtle and an AE2 processor if those mods are loaded.
|
||||||
|
|
||||||
|
Next is still world save. Not EMI. Not a Screen rewrite.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Related Documents
|
## Related Documents
|
||||||
|
|
||||||
[[🌟 Project Vision]]
|
[[🌟 Project Vision]]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ Not a build queue.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
- Vanilla `RecipeProvider` on `RecipeManager` (next after world save)
|
|
||||||
- Viewer-only recipe adapter (EMI/JEI/REI) **if** a recipe never appears in `RecipeManager`
|
- Viewer-only recipe adapter (EMI/JEI/REI) **if** a recipe never appears in `RecipeManager`
|
||||||
- Persistence (world save / server / cloud)
|
- Persistence (world save / server / cloud)
|
||||||
- Inventory-detection completion (alongside manual)
|
- Inventory-detection completion (alongside manual)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import com.sufficient.satistaskory.domain.MaterialAggregation;
|
|||||||
import com.sufficient.satistaskory.domain.ProgressCalculation;
|
import com.sufficient.satistaskory.domain.ProgressCalculation;
|
||||||
import com.sufficient.satistaskory.domain.RecipeResolution;
|
import com.sufficient.satistaskory.domain.RecipeResolution;
|
||||||
import com.sufficient.satistaskory.infrastructure.inventory.PlayerInventoryAdapter;
|
import com.sufficient.satistaskory.infrastructure.inventory.PlayerInventoryAdapter;
|
||||||
import com.sufficient.satistaskory.infrastructure.recipe.StubRecipeProvider;
|
import com.sufficient.satistaskory.infrastructure.recipe.VanillaRecipeProvider;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
@@ -24,7 +24,7 @@ public final class PlannerSession {
|
|||||||
if (planner != null) {
|
if (planner != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RecipeResolution resolution = new RecipeResolution(new StubRecipeProvider());
|
RecipeResolution resolution = new RecipeResolution(new VanillaRecipeProvider());
|
||||||
ProgressCalculation progress = new ProgressCalculation(resolution, new MaterialAggregation());
|
ProgressCalculation progress = new ProgressCalculation(resolution, new MaterialAggregation());
|
||||||
planner = new Planner(new InMemoryGoalStore(), progress, PlannerSession::currentInventory);
|
planner = new Planner(new InMemoryGoalStore(), progress, PlannerSession::currentInventory);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import com.sufficient.satistaskory.domain.MaterialRequirement;
|
|||||||
import com.sufficient.satistaskory.domain.RecipeProvider;
|
import com.sufficient.satistaskory.domain.RecipeProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* First implementation. A few shaped recipes plus identity fallback. Not EMI. Not vanilla-complete.
|
* Unit-test recipes. Furnace, crafting table, chest, plus identity fallback. Not the play adapter.
|
||||||
*/
|
*/
|
||||||
public final class StubRecipeProvider implements RecipeProvider {
|
public final class StubRecipeProvider implements RecipeProvider {
|
||||||
private static final ItemId FURNACE = ItemId.parse("minecraft:furnace");
|
private static final ItemId FURNACE = ItemId.parse("minecraft:furnace");
|
||||||
|
|||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
package com.sufficient.satistaskory.infrastructure.recipe;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.sufficient.satistaskory.domain.ItemId;
|
||||||
|
import com.sufficient.satistaskory.domain.MaterialRequirement;
|
||||||
|
import com.sufficient.satistaskory.domain.RecipeProvider;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.core.HolderLookup;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Items;
|
||||||
|
import net.minecraft.world.item.crafting.Ingredient;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeManager;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One crafting level from {@link RecipeManager}. All recipe types, by output.
|
||||||
|
* Crafting-table recipes win when several match. Tags become the first concrete item.
|
||||||
|
*/
|
||||||
|
public final class VanillaRecipeProvider implements RecipeProvider {
|
||||||
|
@Override
|
||||||
|
public List<MaterialRequirement> resolve(ItemId target, int quantity) {
|
||||||
|
if (quantity < 1) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
|
if (minecraft.level == null) {
|
||||||
|
return gather(target, quantity);
|
||||||
|
}
|
||||||
|
Item item = BuiltInRegistries.ITEM.get(ResourceLocation.parse(target.toString()));
|
||||||
|
if (item == Items.AIR && !target.toString().equals("minecraft:air")) {
|
||||||
|
return gather(target, quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
HolderLookup.Provider registries = minecraft.level.registryAccess();
|
||||||
|
RecipeHolder<?> chosen = pick(minecraft.level.getRecipeManager(), registries, item);
|
||||||
|
if (chosen == null) {
|
||||||
|
return gather(target, quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack result = chosen.value().getResultItem(registries);
|
||||||
|
int outputCount = Math.max(1, result.getCount());
|
||||||
|
int crafts = (quantity + outputCount - 1) / outputCount;
|
||||||
|
|
||||||
|
Map<ItemId, Integer> counts = new LinkedHashMap<>();
|
||||||
|
for (Ingredient ingredient : chosen.value().getIngredients()) {
|
||||||
|
if (ingredient.isEmpty() || ingredient.hasNoItems()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ItemStack[] options = ingredient.getItems();
|
||||||
|
if (options.length == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ItemStack option = options[0];
|
||||||
|
int perCraft = Math.max(1, option.getCount());
|
||||||
|
counts.merge(itemId(option), perCraft * crafts, Integer::sum);
|
||||||
|
}
|
||||||
|
if (counts.isEmpty()) {
|
||||||
|
return gather(target, quantity);
|
||||||
|
}
|
||||||
|
List<MaterialRequirement> requirements = new ArrayList<>();
|
||||||
|
counts.forEach((id, count) -> requirements.add(new MaterialRequirement(id, count)));
|
||||||
|
return List.copyOf(requirements);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RecipeHolder<?> pick(RecipeManager manager, HolderLookup.Provider registries, Item target) {
|
||||||
|
RecipeHolder<?> best = null;
|
||||||
|
int bestScore = Integer.MIN_VALUE;
|
||||||
|
for (RecipeHolder<?> holder : manager.getRecipes()) {
|
||||||
|
ItemStack result = holder.value().getResultItem(registries);
|
||||||
|
if (result.isEmpty() || result.getItem() != target) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int score = 0;
|
||||||
|
if (holder.value().getType() == RecipeType.CRAFTING) {
|
||||||
|
score += 2;
|
||||||
|
}
|
||||||
|
if (ItemStack.isSameItemSameComponents(result, new ItemStack(target))) {
|
||||||
|
score += 1;
|
||||||
|
}
|
||||||
|
if (score > bestScore) {
|
||||||
|
bestScore = score;
|
||||||
|
best = holder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemId itemId(ItemStack stack) {
|
||||||
|
return ItemId.parse(BuiltInRegistries.ITEM.getKey(stack.getItem()).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<MaterialRequirement> gather(ItemId target, int quantity) {
|
||||||
|
return List.of(new MaterialRequirement(target, quantity));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user