Skip to content

Commit 4ffe5ee

Browse files
📝 Add docstrings to feat/add-builders-workbench
Docstrings generation was requested by @The-Code-Monkey. * #55 (comment) The following files were modified: * `src/client/java/com/tcm/MineTale/MineTaleClient.java` * `src/client/java/com/tcm/MineTale/block/workbenches/screen/ArmorersWorkbenchScreen.java` * `src/client/java/com/tcm/MineTale/block/workbenches/screen/BuildersWorkbenchScreen.java` * `src/client/java/com/tcm/MineTale/block/workbenches/screen/FarmersWorkbenchScreen.java` * `src/client/java/com/tcm/MineTale/block/workbenches/screen/WorkbenchWorkbenchScreen.java` * `src/client/java/com/tcm/MineTale/datagen/recipes/BuilderRecipes.java` * `src/client/java/com/tcm/MineTale/datagen/recipes/FarmerRecipes.java` * `src/client/java/com/tcm/MineTale/datagen/recipes/WorkbenchRecipes.java` * `src/main/java/com/tcm/MineTale/block/workbenches/BuildersWorkbench.java` * `src/main/java/com/tcm/MineTale/block/workbenches/FarmersWorkbench.java` * `src/main/java/com/tcm/MineTale/block/workbenches/entity/BuildersWorkbenchEntity.java` * `src/main/java/com/tcm/MineTale/block/workbenches/entity/FarmersWorkbenchEntity.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/AbstractWorkbenchContainerMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/ArmorersWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/BuildersWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/CampfireWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/FarmersWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/FurnaceWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/block/workbenches/menu/WorkbenchWorkbenchMenu.java` * `src/main/java/com/tcm/MineTale/registry/ModRecipes.java`
1 parent 1d06564 commit 4ffe5ee

20 files changed

Lines changed: 2092 additions & 623 deletions

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

Lines changed: 9 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,21 @@
2325

2426
public class MineTaleClient implements ClientModInitializer {
2527
/**
26-
* Register client-side screen factories for custom workbench menu types.
28+
* Initialises client-side GUI screens, render layers and network handling for workbench features.
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 each custom workbench menu type so the client can create the appropriate GUI;
31+
* sets the render layer for furnace workbench block variants to CUTOUT; and registers a global network receiver
32+
* for nearby-inventory sync packets that schedules applying the received item stacks to the currently open
33+
* workbench menu, retrying for up to 10 frames if the menu is not yet ready and logging on persistent failure.
3234
*/
3335
@Override
3436
public void onInitializeClient() {
3537
MenuScreens.register(ModMenuTypes.FURNACE_WORKBENCH_MENU, FurnaceWorkbenchScreen::new);
3638
MenuScreens.register(ModMenuTypes.CAMPFIRE_WORKBENCH_MENU, CampfireWorkbenchScreen::new);
3739
MenuScreens.register(ModMenuTypes.WORKBENCH_WORKBENCH_MENU, WorkbenchWorkbenchScreen::new);
3840
MenuScreens.register(ModMenuTypes.ARMORERS_WORKBENCH_MENU, ArmorersWorkbenchScreen::new);
41+
MenuScreens.register(ModMenuTypes.FARMERS_WORKBENCH_MENU, FarmersWorkbenchScreen::new);
42+
MenuScreens.register(ModMenuTypes.BUILDERS_WORKBENCH_MENU, BuildersWorkbenchScreen::new);
3943

4044
BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T1, ChunkSectionLayer.CUTOUT);
4145
BlockRenderLayerMap.putBlock(ModBlocks.FURNACE_WORKBENCH_BLOCK_T2, ChunkSectionLayer.CUTOUT);

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

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,10 @@ 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+
* Initialise GUI dimensions and widgets for the armourer's workbench screen.
92+
*
93+
* Adds three craft buttons labelled "Craft", "x10" and "All" bound to handleCraftRequest with amounts 1, 10 and -1 respectively.
94+
*/
9795
@Override
9896
protected void init() {
9997
// Important: Set your GUI size before super.init()
@@ -119,45 +117,14 @@ protected void init() {
119117
}
120118

121119
/**
122-
* Sends a crafting request for the currently selected recipe in the integrated recipe book.
120+
* Sends a craft request for the recipe remembered by this screen's last selection.
123121
*
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.
122+
* Looks up the remembered recipe id, resolves its display result for the current level
123+
* and sends a network craft request for the first result stack. If no remembered recipe
124+
* or result is available, no request is sent.
127125
*
128-
* @param amount the quantity to craft; use -1 to request crafting of the full available stack ("All")
126+
* @param amount the requested craft quantity; use -1 to request crafting of all possible outputs
129127
*/
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-
161128
private void handleCraftRequest(int amount) {
162129
// Look at our "Memory" instead of the component
163130
if (this.lastKnownSelectedId != null) {

0 commit comments

Comments
 (0)