Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ private ArmorersWorkbenchScreen(ArmorersWorkbenchMenu menu, Inventory inventory,
}

/**
* Create a MineTaleRecipeBookComponent configured for the workbench screen.
* Creates a MineTaleRecipeBookComponent preconfigured for the armourer's workbench.
*
* @param menu the workbench menu used to initialize the recipe book component
* @return a MineTaleRecipeBookComponent containing the workbench tab and associated recipe category
* @param menu the workbench menu used to bind the recipe book to the current container
* @return the configured MineTaleRecipeBookComponent containing the workbench tab and associated recipe type
*/
private static MineTaleRecipeBookComponent createRecipeBookComponent(ArmorersWorkbenchMenu menu) {
ItemStack tabIcon = new ItemStack(ModBlocks.ARMORERS_WORKBENCH_BLOCK.asItem());
Expand All @@ -88,12 +88,12 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(ArmorersWor
}

/**
* Configure the screen's GUI dimensions and initialize widgets.
*
* Sets the layout size (imageWidth = 176, imageHeight = 166), delegates remaining
* layout initialization to the superclass, and creates the three craft buttons
* ("1", "10", "All") wired to their respective handlers.
*/
* Initialises the screen layout and registers three crafting buttons.
*
* Sets the GUI image dimensions, delegates further initialisation to the superclass,
* and creates three buttons that request crafting of 1, 10 or all results (the
* "all" action is represented by -1).
*/
@Override
protected void init() {
// Important: Set your GUI size before super.init()
Expand All @@ -119,45 +119,14 @@ protected void init() {
}

/**
* Sends a crafting request for the currently selected recipe in the integrated recipe book.
* Send a craft request for the recipe remembered by the screen's last known selection.
*
* Locates the last recipe collection and last selected recipe ID from the recipe book component,
* resolves the recipe's result item, and sends a CraftRequestPayload to the server containing that
* item and the requested amount.
* Resolves the remembered recipe to its resulting item(s) and, if a result exists, sends a
* network CraftRequestPayload containing the first result and the specified amount. If there
* is no remembered selection or no results, no network payload is sent.
*
* @param amount the quantity to craft; use -1 to request crafting of the full available stack ("All")
* @param amount the quantity to craft; use -1 to request crafting all available units
*/

// private void handleCraftRequest(int amount) {
// // 1. Cast the book component to the Accessor to get the selected data
// RecipeBookComponentAccessor accessor = (RecipeBookComponentAccessor) this.mineTaleRecipeBook;

// RecipeCollection collection = accessor.getLastRecipeCollection();
// RecipeDisplayId displayId = accessor.getLastRecipe();

// if (collection != null && displayId != null) {
// // 2. Find the visual entry
// for (RecipeDisplayEntry entry : collection.getSelectedRecipes(RecipeCollection.CraftableStatus.ANY)) {
// if (entry.id().equals(displayId)) {
// // 3. Resolve result for the packet
// List<ItemStack> results = entry.resultItems(SlotDisplayContext.fromLevel(this.minecraft.level));

// if (!results.isEmpty()) {
// ItemStack resultStack = results.get(0);

// // 4. LOG FOR DEBUGGING
// System.out.println("Sending craft request for: " + resultStack + " amount: " + amount);

// ClientPlayNetworking.send(new CraftRequestPayload(resultStack, amount));
// }
// break;
// }
// }
// } else {
// System.out.println("Request failed: Collection or DisplayID is null!");
// }
// }

private void handleCraftRequest(int amount) {
// Look at our "Memory" instead of the component
if (this.lastKnownSelectedId != null) {
Expand Down
Loading
Loading