Skip to content

Commit f474304

Browse files
XxFran10xXclaude
andauthored
fix: stop the branding status listing hit counts (#35)
The branding tool's right-click status listed how often each configured hit had been used, which helps players track the hit split they are meant to work out themselves. It now shows only the recipe, the material groups still to fill and how to finish or cancel. Co-authored-by: XxFran10xX <318299142+XxFran10xX@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 4a5c7ad commit f474304

3 files changed

Lines changed: 9 additions & 21 deletions

File tree

‎src/main/java/net/tfminecraft/advancedcrafting/objects/crafting/CraftingStation.java‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,17 @@ public StationFeedback addMaterial(Player p, ItemStack i) {
247247
return StationFeedback.SUCCESS;
248248
}
249249

250-
/** Lines the branding tool shows on right-click: recipe, materials, and the current count of every configured hit. */
250+
/**
251+
* Lines the branding tool shows on right-click: the recipe and the material groups still to fill.
252+
* Players have to find the hits themselves, so per-hit counts stay out of it.
253+
*/
251254
public List<String> getStatusLines() {
252255
List<String> lines = new ArrayList<>();
253256
lines.add("§7Recipe: " + recipe.getCleanedName());
254257
for (Map.Entry<IngredientType, IntCounter> e : types.entrySet()) {
255258
if (e.getKey() == null) continue;
256259
lines.add(e.getKey().getName() + "§7: §e" + e.getValue().getCurrent() + "/" + e.getValue().getNeeded());
257260
}
258-
// Counted by id: a reload replaces the hit objects this station was keyed with.
259-
Map<String, Integer> done = new HashMap<>();
260-
for (Map.Entry<CraftingHit, IntCounter> e : hits.entrySet()) {
261-
if (e.getKey() == null) continue;
262-
done.merge(e.getKey().getId(), e.getValue().getCurrent(), Integer::sum);
263-
}
264-
for (CraftingHit hit : HitLoader.get().values()) {
265-
lines.add(hit.getName() + "§7: §e" + done.getOrDefault(hit.getId(), 0));
266-
}
267261
lines.add("§7Left-click branding to finish");
268262
lines.add("§cSHIFT + LEFT CLICK with the branding tool to cancel the project!");
269263
return lines;

‎src/test/java/net/tfminecraft/advancedcrafting/CraftingManagerCoverageTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,14 @@ void rightClickWithBrandingShowsStatusInsteadOfAddingIt() throws Exception {
142142
var m = new CraftingManager();
143143
var s = station(m, b);
144144
when(s.hasRecipe()).thenReturn(true);
145-
when(s.getStatusLines()).thenReturn(List.of("§7Recipe: Sword", "Strike§7: §e3"));
145+
when(s.getStatusLines()).thenReturn(List.of("§7Recipe: Sword", "Metal§7: §e1/2"));
146146
p.getInventory().setItemInMainHand(new ItemStack(Material.STICK));
147147
Cache.brandingTool = "v.stick";
148148
when(items.getChecker().checkItemWithPath(any(), eq(Cache.brandingTool))).thenReturn(true);
149149
m.openStation(event(p, b, Action.RIGHT_CLICK_BLOCK));
150150
verify(s, never()).addMaterial(any(), any());
151151
verify(p).sendMessage("§7Recipe: Sword");
152-
verify(p).sendMessage("Strike§7: §e3");
152+
verify(p).sendMessage("Metal§7: §e1/2");
153153
when(items.getChecker().checkItemWithPath(any(), eq(Cache.brandingTool))).thenReturn(false);
154154
when(s.addMaterial(eq(p), any())).thenReturn(StationFeedback.NOT_INGREDIENT);
155155
map(m, "cooldown").clear();

‎src/test/java/net/tfminecraft/advancedcrafting/StationCoverageTest.java‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,21 @@ void materialAdmissionChecksItemTypePermissionsRecipeAndCapacity() throws Except
9595
}
9696

9797
@Test
98-
void statusLinesListEveryConfiguredHitWithItsCount() throws Exception {
98+
void statusLinesShowMaterialsButNoHitCounts() throws Exception {
9999
var p = server.addPlayer();
100-
HitLoader.map.put("tap", new CraftingHit("tap", yaml("name: Tap\ntype: hammer\ntool: v.stick")));
101100
var station = new CraftingStation(loc());
102101
station.setRecipe(recipe("recipe: ['metal.2']"));
103102
var item = ingredient("iron", "hits: ['strike.2']").build();
104103
p.getInventory().setItemInMainHand(item);
105104
assertEquals(StationFeedback.SUCCESS, station.addMaterial(p, item));
106105
station.getHits().get(HitLoader.map.get("strike")).setCurrent(3);
107-
// A reload swaps in new hit objects; counts must still match by id.
108-
HitLoader.map.put(
109-
"strike", new CraftingHit("strike", yaml("name: Strike\ntype: hammer\ntool: v.iron_axe")));
110-
// Unknown types or hits from a stale config are skipped, not printed as "null".
106+
// Unknown types from a stale config are skipped, not printed as "null".
111107
station.getTypes().put(null, new IntCounter());
112-
station.getHits().put(null, new IntCounter());
108+
// Players have to find the hits themselves, so no hit counts are listed.
113109
assertEquals(
114110
List.of(
115111
"§7Recipe: Sword",
116112
"Metal§7: §e1/2",
117-
"Strike§7: §e3",
118-
"Tap§7: §e0",
119113
"§7Left-click branding to finish",
120114
"§cSHIFT + LEFT CLICK with the branding tool to cancel the project!"),
121115
station.getStatusLines());

0 commit comments

Comments
 (0)