Skip to content

Commit 1a6b7dc

Browse files
Merge pull request #48 from CodeMonkeysMods/coderabbitai/docstrings/3187d5d
📝 Add docstrings to `feat/add-items`
2 parents 3187d5d + 4249a40 commit 1a6b7dc

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

src/main/java/com/tcm/MineTale/registry/ModBlocks.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,11 @@ public class ModBlocks {
220220
// public static final Block THORIUM_ORE_SANDSTONE = registerOreBlock("thorium_ore_sandstone", Block::new, BlockBehaviour.Properties.of().strength(2).requiresCorrectToolForDrops(), Blocks.SANDSTONE, Items.COPPER_ORE, 1);
221221

222222
/**
223-
* Adds the mod's workbench and furnace blocks to the Functional Blocks creative tab.
223+
* Adds all mod-registered blocks to the MineTale creative tab and logs the action.
224224
*
225-
* Registers CAMPFIRE_WORKBENCH_BLOCK, WORKBENCH_WORKBENCH_BLOCK, FURNACE_WORKBENCH_BLOCK_T1,
226-
* and FURNACE_WORKBENCH_BLOCK_T2 to CreativeModeTabs.FUNCTIONAL_BLOCKS and prints a registration
227-
* message containing the mod ID.
225+
* Subscribes an entries-modification handler for ModCreativeTab.MINETALE_CREATIVE_TAB_KEY that
226+
* inserts every block collected in REGISTERED_BLOCKS into the creative tab, then prints a
227+
* registration message that includes the mod ID.
228228
*/
229229
public static void initialize() {
230230
ItemGroupEvents.modifyEntriesEvent(ModCreativeTab.MINETALE_CREATIVE_TAB_KEY).register(entries -> {
@@ -235,7 +235,17 @@ public static void initialize() {
235235
System.out.println("Registered Mod Blocks for " + MineTale.MOD_ID);
236236
}
237237

238-
private static Block register(String name, Function<BlockBehaviour.Properties, Block> blockFactory, BlockBehaviour.Properties settings, boolean shouldRegisterItem) {
238+
/**
239+
* Register a block under the mod's namespace, optionally create and register its corresponding BlockItem,
240+
* and add the block to the internal list of registered blocks.
241+
*
242+
* @param name the registry name (path) to use for the block and item
243+
* @param blockFactory factory that creates the Block from provided BlockBehaviour.Properties
244+
* @param settings the BlockBehaviour.Properties to apply to the block; this method will set the block's registry ID on it
245+
* @param shouldRegisterItem if `true`, a BlockItem for the block will be created and registered with the same name
246+
* @return the registered Block instance
247+
*/
248+
private static Block register(String name, Function<BlockBehaviour.Properties, Block> blockFactory, BlockBehaviour.Properties settings, boolean shouldRegisterItem) {
239249
// Create a registry key for the block
240250
ResourceKey<Block> blockKey = keyOfBlock(name);
241251
// Create the block instance
@@ -257,6 +267,21 @@ private static Block register(String name, Function<BlockBehaviour.Properties, B
257267
return Registry.register(BuiltInRegistries.BLOCK, blockKey, block);
258268
}
259269

270+
/**
271+
* Creates and registers an ore block and its corresponding BlockItem in the mod registries.
272+
*
273+
* The created block is configured to require the correct tool for drops and is added to the
274+
* internal REGISTERED_BLOCKS list. A BlockItem for the block is also created and registered
275+
* under the same name.
276+
*
277+
* @param name the registry name (path) for the block and its item
278+
* @param blockFactory a factory that produces the Block given BlockBehaviour.Properties
279+
* @param settings base block properties to apply to the created block
280+
* @param baseBlock an existing block used as the ore's base reference (semantic association)
281+
* @param itemToDrop the item that the ore is intended to drop when mined
282+
* @param count the number of items the ore is intended to drop
283+
* @return the registered Block instance
284+
*/
260285
private static Block registerOreBlock(String name, Function<BlockBehaviour.Properties, Block> blockFactory, BlockBehaviour.Properties settings, Block baseBlock, Item itemToDrop, int count) {
261286
ResourceKey<Block> blockKey = keyOfBlock(name);
262287

0 commit comments

Comments
 (0)