Skip to content

Commit 9cf2d8a

Browse files
Merge branch 'Blacksmith-an-stuff' into Blacksmith-an-stuff3
2 parents 66737ba + 324e8dc commit 9cf2d8a

24 files changed

Lines changed: 280 additions & 151 deletions

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
public class MineTaleDataGen implements DataGeneratorEntrypoint {
99

1010
/**
11-
* Initialize a data pack and register the mod's data providers for data generation.
11+
* Initialises the data pack and registers the mod's data providers for data generation.
1212
*
13-
* Registers language, model, recipe, block tag, and loot table providers so they
14-
* will run as part of the Fabric data generation pack created from the given generator.
13+
* Registers language, model, recipe, block tag, item tag and loot table providers
14+
* so they run as part of the Fabric data generation pack created from the provided generator.
1515
*
1616
* @param fabricDataGenerator the Fabric data generator used to create the data pack
1717
*/

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,12 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(ArmorersWor
8888
}
8989

9090
/**
91-
* Initialises the screen size and adds the three crafting buttons.
91+
* Initialises the screen size and creates three crafting buttons.
9292
*
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").
93+
* Sets the GUI image dimensions, performs superclass initialisation, and adds
94+
* three buttons that request crafting of 1, 10 or all items. Each button calls
95+
* {@code handleCraftRequest} with arguments 1, 10 and -1 respectively; -1
96+
* signifies "craft all".
9697
*/
9798
@Override
9899
protected void init() {

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

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ public BlacksmithsWorkbenchScreen(BlacksmithsWorkbenchMenu menu, Inventory inven
5858
}
5959

6060
/**
61-
* Creates a WorkbenchWorkbenchScreen bound to the given menu, player inventory, title, and recipe book component.
61+
* Initialise a BlacksmithsWorkbenchScreen bound to the provided menu, player inventory, title and recipe book.
6262
*
63-
* @param menu the menu backing this screen
64-
* @param inventory the player's inventory shown in the screen
65-
* @param title the screen title component
66-
* @param recipeBook the MineTaleRecipeBookComponent used to display and manage recipes in this screen
63+
* @param menu the workbench menu backing this screen
64+
* @param inventory the player's inventory to display
65+
* @param title the screen title component
66+
* @param recipeBook the MineTaleRecipeBookComponent used to display and manage recipes for this screen
6767
*/
6868
private BlacksmithsWorkbenchScreen(BlacksmithsWorkbenchMenu menu, Inventory inventory, Component title, MineTaleRecipeBookComponent recipeBook) {
6969
super(menu, recipeBook, inventory, title);
@@ -87,13 +87,12 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(Blacksmiths
8787
}
8888

8989
/**
90-
* Initialises the workbench screen's GUI size and interactive widgets.
90+
* Initialises the screen's GUI size and adds the craft control buttons.
9191
*
92-
* Sets the screen image dimensions, delegates remaining setup to the superclass,
93-
* computes default button positions and creates three craft buttons:
94-
* - "Craft" (requests 1),
95-
* - "x10" (requests 10),
96-
* - "All" (requests -1 to indicate all).
92+
* Sets the screen image dimensions before delegating to the superclass, computes
93+
* default positions relative to the current GUI origin and adds three buttons:
94+
* "Craft" requests a single item, "x10" requests ten items and "All" requests
95+
* the full possible amount (represented by -1).
9796
*/
9897
@Override
9998
protected void init() {
@@ -160,11 +159,17 @@ protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) {
160159
}
161160

162161
/**
163-
* Render the screen, remember the current recipe selection and update craft-button availability.
162+
* Render the screen, preserve the recipe book selection and update craft-button enabled state
163+
* according to whether the player has sufficient ingredients for different craft counts.
164164
*
165-
* Remembers the recipe selected in the recipe book, resolves that selection against the client's known recipes when possible,
166-
* sets the craft buttons active or inactive according to whether the player has sufficient ingredients for counts of 1, 2 and 10,
167-
* renders the background, the superclass UI and any tooltips.
165+
* The method draws the screen background and base UI, remembers the currently selected recipe
166+
* from the recipe book for later resolution, enables or disables the craft buttons for
167+
* counts of 1, 2 and 10 based on ingredient availability, and renders any tooltips.
168+
*
169+
* @param graphics the graphics context to render with
170+
* @param mouseX the current mouse X coordinate relative to the window
171+
* @param mouseY the current mouse Y coordinate relative to the window
172+
* @param delta the frame delta time (partial tick) for the current render frame
168173
*/
169174
@Override
170175
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
@@ -206,13 +211,13 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
206211
}
207212

208213
/**
209-
* Determines whether the player has enough ingredients to craft the given recipe the specified number of times.
210-
*
211-
* @param player the player whose inventory (and networked nearby items) will be checked; may be null
212-
* @param entry the recipe display entry providing crafting requirements; may be null
213-
* @param craftCount the multiplier for required ingredient quantities (e.g., 1, 10, or -1 is not specially handled here)
214-
* @return `true` if the player has at least the required quantity of each ingredient multiplied by `craftCount`, `false` otherwise (also returns `false` if `player` or `entry` is null or the recipe has no requirements)
215-
*/
214+
* Determine whether the player has sufficient ingredients to craft the given recipe the specified number of times.
215+
*
216+
* Returns `false` if `player` or `entry` is null or if the recipe has no crafting requirements.
217+
*
218+
* @param craftCount the number of times to craft the recipe; ingredient requirements are multiplied by this value
219+
* @return `true` if the player has at least the required quantity of each ingredient multiplied by `craftCount`, `false` otherwise
220+
*/
216221
private boolean canCraft(Player player, RecipeDisplayEntry entry, int craftCount) {
217222
if (player == null || entry == null) return false;
218223

@@ -253,6 +258,16 @@ private boolean canCraft(Player player, RecipeDisplayEntry entry, int craftCount
253258
return true;
254259
}
255260

261+
/**
262+
* Checks whether the player inventory combined with the workbench's networked nearby items
263+
* contains at least the specified total quantity of the given ingredient.
264+
*
265+
* @param inventory the inventory to search (player inventory)
266+
* @param ingredient the ingredient matcher used to test ItemStacks
267+
* @param totalRequired the total number of matching items required
268+
* @return `true` if the combined count from inventory and nearby networked items
269+
* is greater than or equal to `totalRequired`, `false` otherwise
270+
*/
256271
private boolean hasIngredientAmount(Inventory inventory, Ingredient ingredient, int totalRequired) {
257272
System.out.println("DEBUG: Searching inventory + nearby for " + totalRequired + "...");
258273
if (totalRequired <= 0) return true;

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(BuildersWor
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 the screen layout and widgets for the Builders Workbench.
92+
*
93+
* Sets the GUI dimensions, delegates remaining initialisation to the superclass,
94+
* and creates three craft buttons that request crafting of 1, 10 or all available items.
95+
*/
9796
@Override
9897
protected void init() {
9998
// Important: Set your GUI size before super.init()

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(FarmersWork
8888
}
8989

9090
/**
91-
* Initialises the screen layout and registers the crafting controls.
91+
* Initialises the screen size and adds three craft buttons to the GUI.
9292
*
93-
* Sets the GUI dimensions to 176×166 and adds three buttons wired to craft requests:
94-
* - "Craft" requests 1,
95-
* - "x10" requests 10,
96-
* - "All" requests all (represented by -1).
93+
* Configures the GUI dimensions to 176×166 and creates three buttons wired to craft requests:
94+
* - the first button requests 1 item;
95+
* - the second button requests 10 items;
96+
* - the third button requests all items (represented by -1).
9797
*/
9898
@Override
9999
protected void init() {

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

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,20 @@ public class FurnitureWorkbenchScreen extends AbstractRecipeBookScreen<Furniture
4848
private Button craftAllBtn;
4949

5050
/**
51-
* Initialize a workbench GUI screen using the provided container menu, player inventory, and title.
51+
* Initialises the furniture workbench GUI screen with the given container menu, player inventory and title.
5252
*
53-
* @param menu the menu supplying slots and synchronized state for this screen
53+
* @param menu the menu providing slots and synchronized state for this screen
5454
* @param inventory the player's inventory to display and interact with
55-
* @param title the title component shown at the top of the screen
55+
* @param title the title component displayed at the top of the screen
5656
*/
5757
public FurnitureWorkbenchScreen(FurnitureWorkbenchMenu menu, Inventory inventory, Component title) {
5858
this(menu, inventory, title, createRecipeBookComponent(menu));
5959
}
6060

6161
/**
62-
* Creates a WorkbenchWorkbenchScreen bound to the given menu, player inventory, title, and recipe book component.
62+
* Initialise a FurnitureWorkbenchScreen bound to the given menu, player inventory, title and recipe book.
6363
*
64-
* @param menu the menu backing this screen
65-
* @param inventory the player's inventory shown in the screen
66-
* @param title the screen title component
67-
* @param recipeBook the MineTaleRecipeBookComponent used to display and manage recipes in this screen
64+
* @param recipeBook the MineTaleRecipeBookComponent used to display and manage recipes in this screen
6865
*/
6966
private FurnitureWorkbenchScreen(FurnitureWorkbenchMenu menu, Inventory inventory, Component title, MineTaleRecipeBookComponent recipeBook) {
7067
super(menu, recipeBook, inventory, title);
@@ -88,13 +85,11 @@ private static MineTaleRecipeBookComponent createRecipeBookComponent(FurnitureWo
8885
}
8986

9087
/**
91-
* Initialises the workbench screen's GUI size and interactive widgets.
88+
* Initialises the screen's GUI dimensions and adds the three craft buttons.
9289
*
93-
* Sets the screen image dimensions, delegates remaining setup to the superclass,
94-
* computes default button positions and creates three craft buttons:
95-
* - "Craft" (requests 1),
96-
* - "x10" (requests 10),
97-
* - "All" (requests -1 to indicate all).
90+
* Sets the screen image width and height, invokes superclass initialisation,
91+
* computes default button positions and creates the "Craft" (requests 1),
92+
* "x10" (requests 10) and "All" (requests all) buttons.
9893
*/
9994
@Override
10095
protected void init() {
@@ -161,11 +156,11 @@ protected void renderBg(GuiGraphics guiGraphics, float f, int i, int j) {
161156
}
162157

163158
/**
164-
* Render the screen, remember the current recipe selection and update craft-button availability.
159+
* Render the screen and update craft-button availability based on the current recipe selection.
165160
*
166-
* Remembers the recipe selected in the recipe book, resolves that selection against the client's known recipes when possible,
167-
* sets the craft buttons active or inactive according to whether the player has sufficient ingredients for counts of 1, 2 and 10,
168-
* renders the background, the superclass UI and any tooltips.
161+
* Remembers the recipe selected in the recipe book and resolves it against the client's known recipes;
162+
* enables or disables the craft buttons for counts of 1, 2 and 10 according to whether the player has
163+
* sufficient ingredients; renders the background, superclass UI and any tooltips.
169164
*/
170165
@Override
171166
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
@@ -207,13 +202,13 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
207202
}
208203

209204
/**
210-
* Determines whether the player has enough ingredients to craft the given recipe the specified number of times.
211-
*
212-
* @param player the player whose inventory (and networked nearby items) will be checked; may be null
213-
* @param entry the recipe display entry providing crafting requirements; may be null
214-
* @param craftCount the multiplier for required ingredient quantities (e.g., 1, 10, or -1 is not specially handled here)
215-
* @return `true` if the player has at least the required quantity of each ingredient multiplied by `craftCount`, `false` otherwise (also returns `false` if `player` or `entry` is null or the recipe has no requirements)
216-
*/
205+
* Determine whether the player has sufficient ingredients to craft the given recipe the specified number of times.
206+
*
207+
* @param player the player whose inventory and any networked nearby items will be checked; may be null
208+
* @param entry the recipe display entry that provides crafting requirements; may be null
209+
* @param craftCount the multiplier applied to each ingredient's required quantity
210+
* @return `true` if `player` and `entry` are non-null and the player has at least each ingredient's required quantity multiplied by `craftCount`; `false` otherwise (also `false` if the recipe has no requirements)
211+
*/
217212
private boolean canCraft(Player player, RecipeDisplayEntry entry, int craftCount) {
218213
if (player == null || entry == null) return false;
219214

@@ -254,6 +249,14 @@ private boolean canCraft(Player player, RecipeDisplayEntry entry, int craftCount
254249
return true;
255250
}
256251

252+
/**
253+
* Checks whether the player's inventory and nearby networked items contain at least the specified quantity of an ingredient.
254+
*
255+
* @param inventory the player's inventory to search
256+
* @param ingredient the ingredient to match against item stacks
257+
* @param totalRequired the total quantity required
258+
* @return `true` if the combined quantity found in the inventory and any networked nearby items is greater than or equal to `totalRequired`, `false` otherwise
259+
*/
257260
private boolean hasIngredientAmount(Inventory inventory, Ingredient ingredient, int totalRequired) {
258261
System.out.println("DEBUG: Searching inventory + nearby for " + totalRequired + "...");
259262
if (totalRequired <= 0) return true;

src/client/java/com/tcm/MineTale/datagen/ModItemTagProvider.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,26 @@
1212
import java.util.concurrent.CompletableFuture;
1313

1414
public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
15+
/**
16+
* Create a ModItemTagProvider used to generate item tag mappings for the mod during data generation.
17+
*
18+
* @param output the Fabric data output used to write generated data
19+
* @param registriesFuture a future supplying a {@link HolderLookup.Provider} for resolving registries needed while building tags
20+
*/
1521
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
1622
super(output, registriesFuture);
1723
}
1824

25+
/**
26+
* Populate item tag mappings used during data generation.
27+
*
28+
* Adds entries for the mod's item tags, including:
29+
* - `ModTags.Items.WOOD_REPAIR` (adds `Items.STICK`)
30+
* - `ModTags.Items.MOSS` (adds the moss block item and various moss variant items resolved from `ModBlocks`)
31+
* - `ModTags.Items.MILK_BUCKETS` (adds `Items.MILK_BUCKET`)
32+
*
33+
* @param provider the registry provider used to resolve item lookups when building tags
34+
*/
1935
@Override
2036
protected void addTags(HolderLookup.Provider provider) {
2137
valueLookupBuilder(ModTags.Items.WOOD_REPAIR)

src/client/java/com/tcm/MineTale/datagen/ModLangProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ public ModLangProvider(FabricDataOutput dataOutput, CompletableFuture<HolderLook
1212
super(dataOutput, registryLookup);
1313
}
1414

15+
/**
16+
* Provides English translations for MineTale mod content.
17+
*
18+
* Populates the given TranslationBuilder with translation keys and their English text for blocks,
19+
* items and GUI elements used by the mod (e.g. workbenches, ores, natural materials, crops, armour and buttons).
20+
*
21+
* @param wrapperLookup registry lookup provider for obtaining registries if needed
22+
* @param translationBuilder builder used to register translation key → text pairs
23+
*/
1524
@Override
1625
public void generateTranslations(HolderLookup.Provider wrapperLookup, TranslationBuilder translationBuilder) {
1726
translationBuilder.add("minetale.creative_tab.title", "MineTale Stuffs");

src/client/java/com/tcm/MineTale/datagen/ModModelProvider.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,13 @@ private void registerFurnaceWorkbench(BlockModelGenerators generator, Block bloc
106106
}
107107

108108
/**
109-
* Registers item models for the mod; currently left empty (no item models are generated).
110-
*
111-
* @param itemModelGenerators generator used to register item models
112-
*/
109+
* Register item models for mod items that require custom or non-default models.
110+
*
111+
* <p>Registers models for shields, trimmable armour pieces, a handheld mace template,
112+
* and various flat handheld item templates used for food and small items.</p>
113+
*
114+
* @param itemModelGenerators the generator used to create and register item models
115+
*/
113116
@Override
114117
public void generateItemModels(ItemModelGenerators itemModelGenerators) {
115118
itemModelGenerators.generateShield(ModItems.COPPER_SHIELD);

src/client/java/com/tcm/MineTale/datagen/recipes/AlchemistRecipes.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
import net.minecraft.data.recipes.RecipeProvider;
1111

1212
public class AlchemistRecipes {
13+
/**
14+
* Registers alchemist workbench recipes and writes them to the provided exporter.
15+
*
16+
* Uses the provider to determine unlock conditions and the lookup to resolve holders required
17+
* during recipe generation.
18+
*
19+
* @param provider the RecipeProvider used to query registered items/blocks for unlock conditions
20+
* @param exporter the RecipeOutput target to which generated recipes will be saved
21+
* @param lookup the HolderLookup.Provider used to resolve registry holders during generation
22+
*/
1323
public static void buildRecipes(RecipeProvider provider, RecipeOutput exporter, HolderLookup.Provider lookup) {
1424
new WorkbenchRecipeBuilder(ModRecipes.ALCHEMISTS_TYPE, ModRecipes.ALCHEMISTS_SERIALIZER)
1525
.input(ModItems.EMPTY_POTION_BOTTLE)

0 commit comments

Comments
 (0)