From 152d88df8f661c1f06151b06c4ef37605605e669 Mon Sep 17 00:00:00 2001
From: "coderabbitai[bot]"
<136622811+coderabbitai[bot]@users.noreply.github.com>
Date: Wed, 28 Jan 2026 16:36:09 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`feat/ad?=
=?UTF-8?q?d-furnace-block-basics`?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Docstrings generation was requested by @The-Code-Monkey.
* https://github.com/CodeMonkeysMods/MineTale/pull/14#issuecomment-3811512892
The following files were modified:
* `src/client/java/com/tcm/MineTale/MineTaleClient.java`
* `src/client/java/com/tcm/MineTale/block/workbenches/screen/FurnaceWorkbenchScreen.java`
* `src/main/java/com/tcm/MineTale/MineTale.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/AbstractWorkbench.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/CampfireWorkbench.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/FurnaceWorkbench.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/entity/AbstractWorkbenchEntity.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/entity/CampfireWorkbenchEntity.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/entity/FurnaceWorkbenchEntity.java`
* `src/main/java/com/tcm/MineTale/block/workbenches/menu/FurnaceWorkbenchMenu.java`
* `src/main/java/com/tcm/MineTale/registry/ModBlockEntities.java`
* `src/main/java/com/tcm/MineTale/registry/ModBlocks.java`
* `src/main/java/com/tcm/MineTale/registry/ModMenuTypes.java`
---
.../java/com/tcm/MineTale/MineTaleClient.java | 3 +
.../screen/FurnaceWorkbenchScreen.java | 28 +++-
src/main/java/com/tcm/MineTale/MineTale.java | 6 +
.../block/workbenches/AbstractWorkbench.java | 34 +++++
.../block/workbenches/CampfireWorkbench.java | 50 ++++++-
.../block/workbenches/FurnaceWorkbench.java | 42 +++++-
.../entity/AbstractWorkbenchEntity.java | 52 +++++++-
.../entity/CampfireWorkbenchEntity.java | 18 ++-
.../entity/FurnaceWorkbenchEntity.java | 125 +++++++++++++++++-
.../menu/FurnaceWorkbenchMenu.java | 74 ++++++++++-
.../MineTale/registry/ModBlockEntities.java | 7 +-
.../com/tcm/MineTale/registry/ModBlocks.java | 7 +-
.../tcm/MineTale/registry/ModMenuTypes.java | 16 ++-
13 files changed, 440 insertions(+), 22 deletions(-)
diff --git a/src/client/java/com/tcm/MineTale/MineTaleClient.java b/src/client/java/com/tcm/MineTale/MineTaleClient.java
index d347081..d74b8c8 100644
--- a/src/client/java/com/tcm/MineTale/MineTaleClient.java
+++ b/src/client/java/com/tcm/MineTale/MineTaleClient.java
@@ -7,6 +7,9 @@
import net.minecraft.client.gui.screens.MenuScreens;
public class MineTaleClient implements ClientModInitializer {
+ /**
+ * Registers the screen factory for the furnace workbench menu so the client can create FurnaceWorkbenchScreen instances for that menu type.
+ */
@Override
public void onInitializeClient() {
MenuScreens.register(ModMenuTypes.FURNACE_WORKBENCH_MENU, FurnaceWorkbenchScreen::new);
diff --git a/src/client/java/com/tcm/MineTale/block/workbenches/screen/FurnaceWorkbenchScreen.java b/src/client/java/com/tcm/MineTale/block/workbenches/screen/FurnaceWorkbenchScreen.java
index ef753f6..f321865 100644
--- a/src/client/java/com/tcm/MineTale/block/workbenches/screen/FurnaceWorkbenchScreen.java
+++ b/src/client/java/com/tcm/MineTale/block/workbenches/screen/FurnaceWorkbenchScreen.java
@@ -14,22 +14,48 @@ public class FurnaceWorkbenchScreen extends AbstractContainerScreen
On the client this acknowledges the interaction. On the server this method + * is a hook for workbench-specific handling; if the workbench processes the + * interaction it will consume it, otherwise the interaction is passed to other handlers.
+ * + * @param state the block state of the workbench + * @param level the world in which the interaction occurs + * @param pos the position of the interacted block + * @param player the player performing the interaction + * @param hit the hit result describing the interaction point + * @return {@code InteractionResult.SUCCESS} on client, {@code InteractionResult.CONSUME} if handled by the workbench, or {@code InteractionResult.PASS} otherwise + */ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hit) { if (level.isClientSide()) return InteractionResult.SUCCESS; @@ -89,6 +130,13 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockP return InteractionResult.PASS; } + /** + * Compute the master (base) block position for this block based on its state. + * + * @param state the block state of the current block + * @param pos the position of the current block + * @return the position of the master (base) block: if the block is the upper half, the block below is used; if the block's type is `RIGHT`, the position is offset one block counterclockwise from its facing direction; otherwise the original position + */ public BlockPos getMasterPos(BlockState state, BlockPos pos) { BlockPos master = pos; Direction facing = state.getValue(FACING); @@ -97,4 +145,4 @@ public BlockPos getMasterPos(BlockState state, BlockPos pos) { return master; } -} +} \ No newline at end of file diff --git a/src/main/java/com/tcm/MineTale/block/workbenches/FurnaceWorkbench.java b/src/main/java/com/tcm/MineTale/block/workbenches/FurnaceWorkbench.java index ebec50c..207d91b 100644 --- a/src/main/java/com/tcm/MineTale/block/workbenches/FurnaceWorkbench.java +++ b/src/main/java/com/tcm/MineTale/block/workbenches/FurnaceWorkbench.java @@ -24,25 +24,49 @@ public class FurnaceWorkbench extends AbstractWorkbenchThe base implementation is a no-op; subclasses should override to perform actual recycling. Implementations are expected to insert resulting items into nearby Container block entities when possible and otherwise spawn the items at this entity's world position.
+ * + * @param stack the ItemStack to recycle + */ public void attemptRecycle(ItemStack stack) { // Logic to break down stack.getItem() and return components // to nearby chests or drop them at worldPosition. } + /** + * Create the container menu presented to the player when they open this workbench. + * + * @param syncId the window synchronization id provided by the client + * @param playerInventory the player's inventory + * @param player the player opening the menu + * @return the created AbstractContainerMenu, or `null` if no menu should be opened + */ @Nullable @Override public abstract AbstractContainerMenu createMenu(int syncId, Inventory playerInventory, Player player); + /** + * Provides the display name for this workbench block. + * + * @return a translatable Component created from the block's description ID + */ @Override public Component getDisplayName() { return Component.translatable(this.getBlockState().getBlock().getDescriptionId()); } -} +} \ No newline at end of file diff --git a/src/main/java/com/tcm/MineTale/block/workbenches/entity/CampfireWorkbenchEntity.java b/src/main/java/com/tcm/MineTale/block/workbenches/entity/CampfireWorkbenchEntity.java index 40dc1ee..73db2a9 100644 --- a/src/main/java/com/tcm/MineTale/block/workbenches/entity/CampfireWorkbenchEntity.java +++ b/src/main/java/com/tcm/MineTale/block/workbenches/entity/CampfireWorkbenchEntity.java @@ -11,6 +11,14 @@ import net.minecraft.world.level.block.state.BlockState; public class CampfireWorkbenchEntity extends AbstractWorkbenchEntity { + /** + * Creates a CampfireWorkbenchEntity at the given position with the provided block state. + * + * Initializes the entity's scan radius to 6.0 and tier to 1. + * + * @param blockPos the world position of this block entity + * @param blockState the block state for this block entity + */ public CampfireWorkbenchEntity(BlockPos blockPos, BlockState blockState) { super(ModBlockEntities.CAMPFIRE_WORKBENCH_BE, blockPos, blockState); @@ -18,9 +26,17 @@ public CampfireWorkbenchEntity(BlockPos blockPos, BlockState blockState) { this.tier = 1; } + /** + * Creates the server-side container menu for this workbench for the given player and window ID. + * + * @param syncId the window synchronization ID provided by the client + * @param playerInventory the player's inventory + * @param player the player opening the menu + * @return the created {@link AbstractContainerMenu}, or `null` if no menu should be opened + */ @Override public @Nullable AbstractContainerMenu createMenu(int syncId, Inventory playerInventory, Player player) { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'createMenu'"); } -} +} \ No newline at end of file diff --git a/src/main/java/com/tcm/MineTale/block/workbenches/entity/FurnaceWorkbenchEntity.java b/src/main/java/com/tcm/MineTale/block/workbenches/entity/FurnaceWorkbenchEntity.java index 8389198..0f4c36c 100644 --- a/src/main/java/com/tcm/MineTale/block/workbenches/entity/FurnaceWorkbenchEntity.java +++ b/src/main/java/com/tcm/MineTale/block/workbenches/entity/FurnaceWorkbenchEntity.java @@ -39,6 +39,13 @@ public class FurnaceWorkbenchEntity extends AbstractWorkbenchEntity { private int fuelTime; protected final ContainerData data = new ContainerData() { + /** + * Retrieves an internal data value by index for UI synchronization. + * + * @param index the data index: 0 = remaining fuel time, 1 = fuel total (constant 100), + * 2 = current cook progress, 3 = total cook time + * @return the value associated with {@code index}, or 0 for any other index + */ @Override public int get(int index) { return switch (index) { @@ -50,6 +57,19 @@ public int get(int index) { }; } + /** + * Sets an internal workbench data field identified by index. + * + * Supported indices: + *Behavioral notes: + * - Runs only on the server side. + * - When input is empty, attempts to pull a single eligible input item from nearby inventories once every 20 game ticks. + * - Workbench tier reduces the required cook duration; cooking advances while fuel is available and is reset when smelting is not possible. + * - Consumes fuel items to refill internal fuel time, decrements fuel time each tick, increments cook progress, and invokes smeltItem(...) when a cycle finishes. + * - Marks the block entity changed if any inventory or internal state is modified.
+ * + * @param level the world in which the workbench exists + * @param pos the block position of the workbench + * @param state the current block state of the workbench + */ public void tick(Level level, BlockPos pos, BlockState state) { if (level.isClientSide()) return; @@ -111,12 +160,26 @@ public void tick(Level level, BlockPos pos, BlockState state) { if (changed) setChanged(); } + /** + * Determines whether the provided stack is a valid smelting input (ore or log). + * + * @param input the item stack to test + * @return `true` if the stack represents an ore or a log, `false` otherwise + */ private boolean canSmelt(ItemStack input) { if (input.isEmpty()) return false; // Logic: Check if it's an ore (Copper to Adamantite) or Logs for Charcoal return isOre(input) || isWood(input); } + /** + * Consume one unit of the provided fuel item and set the internal fuel timer when the item is an accepted fuel. + * + * Accepted fuels: sticks, string (fibres), or any item recognized as wood. + * + * @param fuel the ItemStack to attempt to consume; one item will be removed if accepted + * @return `true` if a fuel unit was consumed and the internal fuel time was set to 100, `false` otherwise + */ private boolean consumeFuel(ItemStack fuel) { // TRAIT: Use fibres (string), sticks, or logs if (fuel.is(Items.STICK) || fuel.is(Items.STRING) || isWood(fuel)) { @@ -127,6 +190,15 @@ private boolean consumeFuel(ItemStack fuel) { return false; } + /** + * Smelts a single input item into its output and deposits the result into an available output slot. + * + *If the input is wood, produces charcoal; otherwise produces a copper ingot (placeholder for ore-to-ingot mapping).
+ * The method finds a suitable output slot and either places the result there or increases the existing stack; if no
+ * output slot is available the method does nothing. The input stack is reduced by one on successful smelting.
+ *
+ * @param input the ItemStack to smelt; one item will be consumed from this stack when smelting occurs
+ */
private void smeltItem(ItemStack input) {
ItemStack result;
// TRAIT: Logs yield Charcoal
@@ -149,6 +221,13 @@ private void smeltItem(ItemStack input) {
input.shrink(1);
}
+ /**
+ * Attempts to move a single ore or wood item from nearby inventories into this entity's input slots.
+ *
+ * If INPUT_1 is empty that slot is filled first; otherwise INPUT_2 is used. If neither input slot is
+ * available or no matching item is found, the method does nothing. When an item is moved, the source
+ * container is marked changed.
+ */
private void pullFromNearbyChests() {
List Forces the class's static initializers to run and prints a registration confirmation
+ * message to standard output.
+ */
public static void initialize() {
// Just used to trigger the static registration
System.out.println("Registered Mod Menus for " + MineTale.MOD_ID);
}
+ /**
+ * Register a MenuType under this mod's namespace and return the registered type.
+ *
+ * @param name the path component used to build the registry Identifier (namespace is MineTale.MOD_ID)
+ * @param factory a supplier that constructs instances of the menu type
+ * @param