Skip to content

Commit 5e302d5

Browse files
Merge pull request #54 from CodeMonkeysMods/feat/add-farmers-workbench
Add Most Farmers Workbench Recipies
2 parents 1d06564 + e9a6514 commit 5e302d5

26 files changed

+2203
-708
lines changed

src/client/java/com/tcm/MineTale/MineTaleClient.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
import com.tcm.MineTale.block.workbenches.menu.AbstractWorkbenchContainerMenu;
1010
import com.tcm.MineTale.block.workbenches.screen.ArmorersWorkbenchScreen;
11+
import com.tcm.MineTale.block.workbenches.screen.BuildersWorkbenchScreen;
1112
import com.tcm.MineTale.block.workbenches.screen.CampfireWorkbenchScreen;
13+
import com.tcm.MineTale.block.workbenches.screen.FarmersWorkbenchScreen;
1214
import com.tcm.MineTale.registry.ModBlocks;
1315
import com.tcm.MineTale.registry.ModMenuTypes;
1416

@@ -23,19 +25,24 @@
2325

2426
public class MineTaleClient implements ClientModInitializer {
2527
/**
26-
* Register client-side screen factories for custom workbench menu types.
28+
* Initialises client-side handlers for the MineTale mod.
2729
*
28-
* Binds ModMenuTypes.FURNACE_WORKBENCH_MENU to FurnaceWorkbenchScreen,
29-
* ModMenuTypes.CAMPFIRE_WORKBENCH_MENU to CampfireWorkbenchScreen, and
30-
* ModMenuTypes.WORKBENCH_WORKBENCH_MENU to WorkbenchWorkbenchScreen so the client
31-
* can create the appropriate GUI when those menus open.
30+
* Registers screen factories for custom workbench menu types, configures render
31+
* layers for furnace workbench blocks, and registers a global network receiver
32+
* that applies nearby inventory items to an open workbench menu.
33+
*
34+
* The network receiver schedules work on the client thread and retries application
35+
* for up to 10 client ticks if the expected workbench menu is not yet open; if
36+
* synchronization still fails it logs a failure message.
3237
*/
3338
@Override
3439
public void onInitializeClient() {
3540
MenuScreens.register(ModMenuTypes.FURNACE_WORKBENCH_MENU, FurnaceWorkbenchScreen::new);
3641
MenuScreens.register(ModMenuTypes.CAMPFIRE_WORKBENCH_MENU, CampfireWorkbenchScreen::new);
3742
MenuScreens.register(ModMenuTypes.WORKBENCH_WORKBENCH_MENU, WorkbenchWorkbenchScreen::new);
3843
MenuScreens.register(ModMenuTypes.ARMORERS_WORKBENCH_MENU, ArmorersWorkbenchScreen::new);
44+
MenuScreens.register(ModMenuTypes.FARMERS_WORKBENCH_MENU, FarmersWorkbenchScreen::new);
45+
MenuScreens.register(ModMenuTypes.BUILDERS_WORKBENCH_MENU, BuildersWorkbenchScreen::new);
3946

4047
BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T1, ChunkSectionLayer.CUTOUT);
4148
BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T2, ChunkSectionLayer.CUTOUT);

src/client/java/com/tcm/MineTale/block/workbenches/screen/ArmorersWorkbenchScreen.java

Lines changed: 11 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)