Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
15 changes: 10 additions & 5 deletions src/client/java/com/tcm/MineTale/MineTaleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.tcm.MineTale.block.workbenches.menu.AbstractWorkbenchContainerMenu;
import com.tcm.MineTale.block.workbenches.screen.ArmorersWorkbenchScreen;
import com.tcm.MineTale.block.workbenches.screen.CampfireWorkbenchScreen;
import com.tcm.MineTale.block.workbenches.screen.FarmersWorkbenchScreen;
import com.tcm.MineTale.registry.ModBlocks;
import com.tcm.MineTale.registry.ModMenuTypes;

Expand All @@ -23,19 +24,23 @@

public class MineTaleClient implements ClientModInitializer {
/**
* Register client-side screen factories for custom workbench menu types.
* Initializes client-side handlers for the MineTale mod.
*
* Binds ModMenuTypes.FURNACE_WORKBENCH_MENU to FurnaceWorkbenchScreen,
* ModMenuTypes.CAMPFIRE_WORKBENCH_MENU to CampfireWorkbenchScreen, and
* ModMenuTypes.WORKBENCH_WORKBENCH_MENU to WorkbenchWorkbenchScreen so the client
* can create the appropriate GUI when those menus open.
* Registers screen factories for custom workbench menu types, configures block render
* layers for furnace workbenches, and registers a global network receiver that applies
* nearby inventory item lists to an open workbench menu when available.
*
* The network receiver schedules a client task that retries up to 10 frames if the
* player's container menu is not yet an instance of the expected workbench menu and
* logs a failure message if synchronization could not be applied after retries.
*/
@Override
public void onInitializeClient() {
MenuScreens.register(ModMenuTypes.FURNACE_WORKBENCH_MENU, FurnaceWorkbenchScreen::new);
MenuScreens.register(ModMenuTypes.CAMPFIRE_WORKBENCH_MENU, CampfireWorkbenchScreen::new);
MenuScreens.register(ModMenuTypes.WORKBENCH_WORKBENCH_MENU, WorkbenchWorkbenchScreen::new);
MenuScreens.register(ModMenuTypes.ARMORERS_WORKBENCH_MENU, ArmorersWorkbenchScreen::new);
MenuScreens.register(ModMenuTypes.FARMERS_WORKBENCH_MENU, FarmersWorkbenchScreen::new);

BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T1, ChunkSectionLayer.CUTOUT);
BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T2, ChunkSectionLayer.CUTOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,45 +119,14 @@ protected void init() {
}

/**
* Sends a crafting request for the currently selected recipe in the integrated recipe book.
* Sends a craft request for the recipe remembered by this 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 available, sends a network
* CraftRequestPayload containing the first result and the requested amount. If no remembered
* selection or no results are available, no 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