diff --git a/AGENTS.md b/AGENTS.md index 4a6804e..d807b75 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -40,7 +40,7 @@ Read [[🧠 Philosophy]] before changing the vault. The Bookshelf Principle, Pre ## Code -The first slice is in code and has been played (ADRs 012–020): [[▶️ Create Goal]], [[🔌 Recipe Provider]] via `RecipeManager`, overlay HUD, capture = tooltip + rebindable Add key, client-owned plan files. Tag ingredients are any-of (ADR-019). Completion is manual, plus opt-in `/satistaskory auto-remove` (ADR-020). +The first slice is in code and has been played (ADRs 012–021): [[▶️ Create Goal]], [[🔌 Recipe Provider]] via `RecipeManager`, overlay HUD, capture = tooltip + rebindable Add key, client-owned plan files. Tag ingredients are any-of (ADR-019). Completion is manual, plus opt-in `/satistaskory auto-remove` (ADR-020). Do not start EMI/JEI/REI. Recipe source is `RecipeManager` (ADR-016). The host does not need this mod (ADR-018). Project waits until settled. Do not rewrite the overlay as a `Screen` unless the HUD path fails. diff --git a/docs/02-Domain/🎯 Goal.md b/docs/02-Domain/🎯 Goal.md index bdd509a..5c5dc0d 100644 --- a/docs/02-Domain/🎯 Goal.md +++ b/docs/02-Domain/🎯 Goal.md @@ -33,10 +33,9 @@ Target Quantity is required and is never 0. | Action | Result | |--------|--------| -| [[▶️ Create Goal]] | Quantity **1** if new; **+1** if that ItemId already exists | -| `[+]` on the overlay | Quantity + 1 | -| `[-]` when quantity > 1 | Quantity − 1 | -| `[-]` when quantity is 1 | Goal is **removed** | +| [[▶️ Create Goal]] | One recipe’s output if new; **+ that output** if the ItemId already exists. No recipe → 1 | +| `[+]` on the overlay | + one recipe’s output (planks +4). No recipe → +1 | +| `[-]` | − one recipe’s output. At or below that step, the goal is **removed** | | `X Clear Items` | All goals removed | There is no quantity picker on capture. See [[🖥️ Experience]]. diff --git a/docs/02-Domain/🗣️ Ubiquitous Language.md b/docs/02-Domain/🗣️ Ubiquitous Language.md index 1773734..17ac808 100644 --- a/docs/02-Domain/🗣️ Ubiquitous Language.md +++ b/docs/02-Domain/🗣️ Ubiquitous Language.md @@ -25,7 +25,7 @@ A thing the player wishes to obtain. Contains: Target Item (**ItemId**, `namespace:path`), Target Quantity (≥ 1). -One Goal per ItemId in the plan. Create at 1, or +1 if that item is already a goal. `[-]` at 1 removes it. +One Goal per ItemId in the plan. Create / `[+]` / `[-]` step by one recipe’s output (no recipe → 1). `[-]` at or below one yield removes it. Examples: 4 Ender Chests. 1 AE2 Controller. 64 Export Buses. diff --git a/docs/03-Architecture/▶️ Create Goal.md b/docs/03-Architecture/▶️ Create Goal.md index ce644f6..2d6aae7 100644 --- a/docs/03-Architecture/▶️ Create Goal.md +++ b/docs/03-Architecture/▶️ Create Goal.md @@ -17,7 +17,7 @@ Capture (hover item → Add key) is one caller. The use case does not know about ## Quantity -Always **1** on this path. New goal: quantity 1. Existing goal: quantity + 1. +One recipe’s output on this path (and on overlay `[+]`). New goal: that many. Existing goal: + that many. No recipe → 1. --- diff --git a/docs/03-Architecture/📝 Decisions.md b/docs/03-Architecture/📝 Decisions.md index 6dad1c6..cc6ed5f 100644 --- a/docs/03-Architecture/📝 Decisions.md +++ b/docs/03-Architecture/📝 Decisions.md @@ -368,6 +368,24 @@ The walk: finished items stayed on the overlay until a click. For a prosthetic t --- +### ADR-021 — Quantity steps by recipe output + +**Date:** 2026-09-08 + +**Decision:** Capture, `[+]`, and `[-]` move Target Quantity by **one recipe’s output count**, not always 1. Oak planks +4. A furnace +1. No recipe → 1. `[-]` at or below one yield removes the goal. + +The same recipe `VanillaRecipeProvider` already picked for ingredients. Ingredient math stays aligned with crafts. + +**Reason:** + +The walk: items that craft in stacks of 4 still ticked by 1, so the overlay was counting pieces instead of crafts. + +**Status:** ✅ Accepted + +**Supersedes:** ADR-012’s “Create = 1 / +1” freeze for quantity steps. + +--- + ## Related Documents [[🏛️ Architecture]] diff --git a/docs/03-Architecture/🔌 Recipe Provider.md b/docs/03-Architecture/🔌 Recipe Provider.md index 10e579f..c48f5e7 100644 --- a/docs/03-Architecture/🔌 Recipe Provider.md +++ b/docs/03-Architecture/🔌 Recipe Provider.md @@ -13,6 +13,8 @@ Infrastructure answers. The domain never imports a recipe **viewer** (EMI/JEI/RE RecipeProvider resolve(ItemId target, int quantity) → list of MaterialRequirement + outputCount(ItemId target) + → how many one recipe produces (gather → 1) ``` `ItemId` is `namespace:path` (e.g. `minecraft:furnace`). Not `net.minecraft.world.item.Item`. diff --git a/docs/04-Planning/🗺️ Roadmap.md b/docs/04-Planning/🗺️ Roadmap.md index 7ab049c..55fe959 100644 --- a/docs/04-Planning/🗺️ Roadmap.md +++ b/docs/04-Planning/🗺️ Roadmap.md @@ -6,7 +6,7 @@ What exists, and what is next. Implementation detail will live in an Implementat ## ✅ Now (docs) -- Philosophy Rules #1–#10; ADRs **001–020** +- Philosophy Rules #1–#10; ADRs **001–021** - Vision, ubiquitous language, bounded context (one: Goal Planning) - Goal invariants: one per ItemId, quantity ≥ 1, create at 1 / +1, `[-]` at 1 removes - Packages named; [[🔌 Recipe Provider]] sketched; [[▶️ Create Goal]] written diff --git a/docs/04-Planning/🧭 Notes for the Wayfinder.md b/docs/04-Planning/🧭 Notes for the Wayfinder.md index d50bb09..50bbdd6 100644 --- a/docs/04-Planning/🧭 Notes for the Wayfinder.md +++ b/docs/04-Planning/🧭 Notes for the Wayfinder.md @@ -453,6 +453,16 @@ Cut `0.1.0-alpha.1` for friend testers. Client jar. Host does not need the mod. --- +## 📜 2026-09-08 (step by recipe yield) + +Greetings, Wayfinder. + +The walk: `[+]` on planks added 1, not 4. + +ADR-021: capture / `+` / `−` step by `RecipeProvider.outputCount`. Same picked recipe as ingredients. Gather stays 1. + +--- + ## 📜 2026-09-08 (the black screen was HDR) Greetings, Wayfinder. diff --git a/docs/05-Experience/📖 User Stories.md b/docs/05-Experience/📖 User Stories.md index c5127c5..8195bc0 100644 --- a/docs/05-Experience/📖 User Stories.md +++ b/docs/05-Experience/📖 User Stories.md @@ -48,7 +48,7 @@ As a player I want `[+]` / `[-]` on a goal so I can set Target Quantity while I play. -Screen 2. Capture starts at 1 (or +1). `[-]` at 1 removes the goal. +Screen 2. Capture and `[+]` add one recipe’s yield. `[-]` subtracts that yield. ### US-6 — Clear the plan diff --git a/docs/05-Experience/🖥️ Experience.md b/docs/05-Experience/🖥️ Experience.md index a0dd1b4..4b8e298 100644 --- a/docs/05-Experience/🖥️ Experience.md +++ b/docs/05-Experience/🖥️ Experience.md @@ -35,7 +35,7 @@ Interaction: 1. Hover the item 2. Tooltip includes `[+] Add to Crafting Goals` (bound key) -3. Press that key — [[▶️ Create Goal]] — quantity **1**, or **+1** if that item is already a goal +3. Press that key — [[▶️ Create Goal]] — one recipe’s yield (or 1 if none), or + that yield if already a goal 4. Player closes the view and is back in the world 5. The item is a row on the overlay’s goal list @@ -80,9 +80,9 @@ A full-screen planner is not this surface. It is not discovered. ## Quantity -Capture always applies **1** (new goal) or **+1** (existing). No picker on Screen 1. +Capture and `[+]` apply **one recipe’s yield** (oak planks → 4). No recipe → 1. No picker on Screen 1. -`[+]` / `[-]` on the overlay change quantity. `[-]` at 1 removes the goal. There is no 0. +`[-]` subtracts that same yield. At or below one yield, the goal is removed. There is no 0. --- diff --git a/docs/05-Experience/🖼️ Wireframes.md b/docs/05-Experience/🖼️ Wireframes.md index 975d78d..9bb5d3b 100644 --- a/docs/05-Experience/🖼️ Wireframes.md +++ b/docs/05-Experience/🖼️ Wireframes.md @@ -25,7 +25,7 @@ Satistaskory draws only a tooltip line. The mouse stays on the item. [+] Add to Crafting Goals ``` -**Primary action:** hover the item, press the Add key (default `=`, rebindable in Controls) → [[▶️ Create Goal]] (quantity 1, or +1 if present) → close the host view → the item is a row on Screen 2. +**Primary action:** hover the item, press the Add key (default `=`, rebindable in Controls) → [[▶️ Create Goal]] (one recipe’s yield, or + that yield if present) → close the host view → the item is a row on Screen 2. Same control in inventory, crafting pane, and craft book. We do not restyle those views. We do not draw a click target you have to leave the item to hit. diff --git a/docs/05-Experience/🚶 Day in the Life.md b/docs/05-Experience/🚶 Day in the Life.md index 099252b..fa1e536 100644 --- a/docs/05-Experience/🚶 Day in the Life.md +++ b/docs/05-Experience/🚶 Day in the Life.md @@ -107,7 +107,7 @@ Player copy **Crafting Goals**. Domain: [[🎯 Goal]]. See [[🖥️ Experience] ### Quantity -A goal has a Target Quantity. Hover-add starts at **1**, or **+1** if that item is already a goal. The overlay changes it with `[+]` / `[-]`. `[-]` at 1 removes the goal. +A goal has a Target Quantity. Hover-add and `[+]` add **one recipe’s yield** (planks 4, furnace 1). `[-]` subtracts that yield and removes the goal at or below it. --- diff --git a/src/main/java/com/sufficient/satistaskory/application/Planner.java b/src/main/java/com/sufficient/satistaskory/application/Planner.java index 0b257dd..fda7440 100644 --- a/src/main/java/com/sufficient/satistaskory/application/Planner.java +++ b/src/main/java/com/sufficient/satistaskory/application/Planner.java @@ -9,6 +9,7 @@ import com.sufficient.satistaskory.domain.InventoryState; import com.sufficient.satistaskory.domain.ItemId; import com.sufficient.satistaskory.domain.ProgressCalculation; import com.sufficient.satistaskory.domain.ProgressSnapshot; +import com.sufficient.satistaskory.domain.RecipeResolution; /** * Application facade for the first slice. Persistence is the store's job. @@ -17,11 +18,17 @@ public final class Planner { private final GoalStore store; private final ProgressCalculation progress; private final Supplier inventory; + private final RecipeResolution resolution; - public Planner(GoalStore store, ProgressCalculation progress, Supplier inventory) { + public Planner( + GoalStore store, + ProgressCalculation progress, + Supplier inventory, + RecipeResolution resolution) { this.store = Objects.requireNonNull(store, "store"); this.progress = Objects.requireNonNull(progress, "progress"); this.inventory = Objects.requireNonNull(inventory, "inventory"); + this.resolution = Objects.requireNonNull(resolution, "resolution"); } public List goals() { @@ -34,25 +41,28 @@ public final class Planner { public ProgressSnapshot create(ItemId item) { Objects.requireNonNull(item, "item"); + int step = step(item); store.find(item).ifPresentOrElse( - existing -> store.put(existing.increment()), - () -> store.put(new Goal(item, 1))); + existing -> store.put(existing.plus(step)), + () -> store.put(new Goal(item, step))); return refresh(); } public ProgressSnapshot increment(ItemId item) { Objects.requireNonNull(item, "item"); - store.find(item).ifPresent(existing -> store.put(existing.increment())); + int step = step(item); + store.find(item).ifPresent(existing -> store.put(existing.plus(step))); return refresh(); } public ProgressSnapshot decrement(ItemId item) { Objects.requireNonNull(item, "item"); + int step = step(item); store.find(item).ifPresent(existing -> { - if (existing.quantity() == 1) { + if (existing.quantity() <= step) { store.remove(item); } else { - store.put(existing.decrement()); + store.put(new Goal(item, existing.quantity() - step)); } }); return refresh(); @@ -87,6 +97,10 @@ public final class Planner { }); } + private int step(ItemId item) { + return resolution.outputCount(item); + } + private ProgressSnapshot refresh() { return progress.calculate(store.all(), inventory.get()); } diff --git a/src/main/java/com/sufficient/satistaskory/domain/Goal.java b/src/main/java/com/sufficient/satistaskory/domain/Goal.java index 6f8d926..a012471 100644 --- a/src/main/java/com/sufficient/satistaskory/domain/Goal.java +++ b/src/main/java/com/sufficient/satistaskory/domain/Goal.java @@ -26,7 +26,14 @@ public final class Goal { } public Goal increment() { - return new Goal(targetItem, quantity + 1); + return plus(1); + } + + public Goal plus(int amount) { + if (amount < 1) { + throw new IllegalArgumentException("amount must be >= 1"); + } + return new Goal(targetItem, quantity + amount); } public Goal decrement() { diff --git a/src/main/java/com/sufficient/satistaskory/domain/RecipeProvider.java b/src/main/java/com/sufficient/satistaskory/domain/RecipeProvider.java index 621c62c..7bc88fc 100644 --- a/src/main/java/com/sufficient/satistaskory/domain/RecipeProvider.java +++ b/src/main/java/com/sufficient/satistaskory/domain/RecipeProvider.java @@ -11,4 +11,11 @@ public interface RecipeProvider { * One crafting level. No recipe → {@code (target, quantity)}. {@code quantity < 1} → empty. */ List resolve(ItemId target, int quantity); + + /** + * How many of {@code target} one recipe produces. Gather / unknown → 1. + */ + default int outputCount(ItemId target) { + return 1; + } } diff --git a/src/main/java/com/sufficient/satistaskory/domain/RecipeResolution.java b/src/main/java/com/sufficient/satistaskory/domain/RecipeResolution.java index eacd4e1..40b6c08 100644 --- a/src/main/java/com/sufficient/satistaskory/domain/RecipeResolution.java +++ b/src/main/java/com/sufficient/satistaskory/domain/RecipeResolution.java @@ -16,4 +16,8 @@ public final class RecipeResolution { } return provider.resolve(target, quantity); } + + public int outputCount(ItemId target) { + return Math.max(1, provider.outputCount(target)); + } } diff --git a/src/main/java/com/sufficient/satistaskory/infrastructure/client/PlannerSession.java b/src/main/java/com/sufficient/satistaskory/infrastructure/client/PlannerSession.java index e3768b1..c9eba47 100644 --- a/src/main/java/com/sufficient/satistaskory/infrastructure/client/PlannerSession.java +++ b/src/main/java/com/sufficient/satistaskory/infrastructure/client/PlannerSession.java @@ -32,7 +32,7 @@ public final class PlannerSession { RecipeResolution resolution = new RecipeResolution(new VanillaRecipeProvider()); ProgressCalculation progress = new ProgressCalculation(resolution, new MaterialAggregation()); store = new PersistingGoalStore(); - planner = new Planner(store, progress, PlannerSession::currentInventory); + planner = new Planner(store, progress, PlannerSession::currentInventory, resolution); ClientSettings.load(); obtained.reset(); } diff --git a/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/StubRecipeProvider.java b/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/StubRecipeProvider.java index 5d5dc4e..0a1c4fe 100644 --- a/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/StubRecipeProvider.java +++ b/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/StubRecipeProvider.java @@ -18,6 +18,7 @@ public final class StubRecipeProvider implements RecipeProvider { private static final ItemId CHEST = ItemId.parse("minecraft:chest"); private static final ItemId COBBLESTONE = ItemId.parse("minecraft:cobblestone"); private static final ItemId OAK_PLANKS = ItemId.parse("minecraft:oak_planks"); + private static final ItemId OAK_LOG = ItemId.parse("minecraft:oak_log"); private final Map recipes = new HashMap<>(); @@ -25,6 +26,13 @@ public final class StubRecipeProvider implements RecipeProvider { recipes.put(FURNACE, new Recipe(1, List.of(new MaterialRequirement(COBBLESTONE, 8)))); recipes.put(CRAFTING_TABLE, new Recipe(1, List.of(new MaterialRequirement(OAK_PLANKS, 4)))); recipes.put(CHEST, new Recipe(1, List.of(new MaterialRequirement(OAK_PLANKS, 8)))); + recipes.put(OAK_PLANKS, new Recipe(4, List.of(new MaterialRequirement(OAK_LOG, 1)))); + } + + @Override + public int outputCount(ItemId target) { + Recipe recipe = recipes.get(target); + return recipe == null ? 1 : recipe.outputCount(); } @Override diff --git a/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/VanillaRecipeProvider.java b/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/VanillaRecipeProvider.java index b8938f7..aa530b5 100644 --- a/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/VanillaRecipeProvider.java +++ b/src/main/java/com/sufficient/satistaskory/infrastructure/recipe/VanillaRecipeProvider.java @@ -34,20 +34,11 @@ public final class VanillaRecipeProvider implements RecipeProvider { 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); + RecipeHolder chosen = chosen(target); if (chosen == null) { return gather(target, quantity); } + HolderLookup.Provider registries = Minecraft.getInstance().level.registryAccess(); ItemStack result = chosen.value().getResultItem(registries); int outputCount = Math.max(1, result.getCount()); @@ -77,6 +68,28 @@ public final class VanillaRecipeProvider implements RecipeProvider { return List.copyOf(requirements); } + @Override + public int outputCount(ItemId target) { + RecipeHolder chosen = chosen(target); + if (chosen == null) { + return 1; + } + ItemStack result = chosen.value().getResultItem(Minecraft.getInstance().level.registryAccess()); + return Math.max(1, result.getCount()); + } + + private static RecipeHolder chosen(ItemId target) { + Minecraft minecraft = Minecraft.getInstance(); + if (minecraft.level == null) { + return null; + } + Item item = BuiltInRegistries.ITEM.get(ResourceLocation.parse(target.toString())); + if (item == Items.AIR && !target.toString().equals("minecraft:air")) { + return null; + } + return pick(minecraft.level.getRecipeManager(), minecraft.level.registryAccess(), item); + } + private static RecipeHolder pick(RecipeManager manager, HolderLookup.Provider registries, Item target) { RecipeHolder best = null; int bestScore = Integer.MIN_VALUE; diff --git a/src/test/java/com/sufficient/satistaskory/application/ObtainedCompletionTest.java b/src/test/java/com/sufficient/satistaskory/application/ObtainedCompletionTest.java index 22f48f0..09bd748 100644 --- a/src/test/java/com/sufficient/satistaskory/application/ObtainedCompletionTest.java +++ b/src/test/java/com/sufficient/satistaskory/application/ObtainedCompletionTest.java @@ -25,7 +25,7 @@ class ObtainedCompletionTest { void setUp() { RecipeResolution resolution = new RecipeResolution(new StubRecipeProvider()); ProgressCalculation progress = new ProgressCalculation(resolution, new MaterialAggregation()); - planner = new Planner(new InMemoryGoalStore(), progress, InventoryState::empty); + planner = new Planner(new InMemoryGoalStore(), progress, InventoryState::empty, resolution); completion = new ObtainedCompletion(); } diff --git a/src/test/java/com/sufficient/satistaskory/application/PlannerTest.java b/src/test/java/com/sufficient/satistaskory/application/PlannerTest.java index 4f5e57d..5f2b820 100644 --- a/src/test/java/com/sufficient/satistaskory/application/PlannerTest.java +++ b/src/test/java/com/sufficient/satistaskory/application/PlannerTest.java @@ -32,7 +32,7 @@ class PlannerTest { inventory = InventoryState.empty(); RecipeResolution resolution = new RecipeResolution(new StubRecipeProvider()); ProgressCalculation progress = new ProgressCalculation(resolution, new MaterialAggregation()); - planner = new Planner(new InMemoryGoalStore(), progress, () -> inventory); + planner = new Planner(new InMemoryGoalStore(), progress, () -> inventory, resolution); } @Test @@ -43,6 +43,17 @@ class PlannerTest { assertEquals(2, second.goals().getFirst().quantity()); } + @Test + void plusStepsByRecipeOutput() { + planner.create(OAK_PLANKS); + assertEquals(4, planner.goals().getFirst().quantity()); + planner.increment(OAK_PLANKS); + assertEquals(8, planner.goals().getFirst().quantity()); + planner.decrement(OAK_PLANKS); + assertEquals(4, planner.goals().getFirst().quantity()); + assertTrue(planner.decrement(OAK_PLANKS).goals().isEmpty()); + } + @Test void decrementAtOneRemoves() { planner.create(FURNACE);