@@ -88,12 +88,12 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(ArmorersWor
8888 }
8989
9090 /**
91- * Configure the screen's GUI dimensions and initialize widgets .
92- *
93- * Sets the layout size (imageWidth = 176, imageHeight = 166), delegates remaining
94- * layout initialization to the superclass, and creates the three craft buttons
95- * ("1", "10", "All") wired to their respective handlers .
96- */
91+ * Initialises the screen size and adds the three crafting buttons .
92+ *
93+ * Sets the GUI image dimensions, delegates further initialisation to the superclass,
94+ * and creates/registers three buttons wired to craft one, ten or all items
95+ * (they invoke handleCraftRequest with 1, 10 and -1 respectively; -1 signifies "All") .
96+ */
9797 @ Override
9898 protected void init () {
9999 // Important: Set your GUI size before super.init()
@@ -119,45 +119,14 @@ protected void init() {
119119 }
120120
121121 /**
122- * Sends a crafting request for the currently selected recipe in the integrated recipe book .
122+ * Sends a craft request for the recipe remembered by this screen's last known selection .
123123 *
124- * Locates the last recipe collection and last selected recipe ID from the recipe book component,
125- * resolves the recipe's result item, and sends a CraftRequestPayload to the server containing that
126- * item and the requested amount .
124+ * Resolves the remembered recipe to its resulting item(s) and, if available, sends a network
125+ * CraftRequestPayload containing the first result and the requested amount. If no remembered
126+ * selection or no results are available, no payload is sent .
127127 *
128- * @param amount the quantity to craft; use -1 to request crafting of the full available stack ("All")
128+ * @param amount the quantity to craft; use -1 to request crafting all available units
129129 */
130-
131- // private void handleCraftRequest(int amount) {
132- // // 1. Cast the book component to the Accessor to get the selected data
133- // RecipeBookComponentAccessor accessor = (RecipeBookComponentAccessor) this.mineTaleRecipeBook;
134-
135- // RecipeCollection collection = accessor.getLastRecipeCollection();
136- // RecipeDisplayId displayId = accessor.getLastRecipe();
137-
138- // if (collection != null && displayId != null) {
139- // // 2. Find the visual entry
140- // for (RecipeDisplayEntry entry : collection.getSelectedRecipes(RecipeCollection.CraftableStatus.ANY)) {
141- // if (entry.id().equals(displayId)) {
142- // // 3. Resolve result for the packet
143- // List<ItemStack> results = entry.resultItems(SlotDisplayContext.fromLevel(this.minecraft.level));
144-
145- // if (!results.isEmpty()) {
146- // ItemStack resultStack = results.get(0);
147-
148- // // 4. LOG FOR DEBUGGING
149- // System.out.println("Sending craft request for: " + resultStack + " amount: " + amount);
150-
151- // ClientPlayNetworking.send(new CraftRequestPayload(resultStack, amount));
152- // }
153- // break;
154- // }
155- // }
156- // } else {
157- // System.out.println("Request failed: Collection or DisplayID is null!");
158- // }
159- // }
160-
161130 private void handleCraftRequest (int amount ) {
162131 // Look at our "Memory" instead of the component
163132 if (this .lastKnownSelectedId != null ) {
0 commit comments