@@ -38,6 +38,13 @@ public class ChickenCoopBlock extends HorizontalDirectionalBlock implements Enti
3838
3939 public static final MapCodec <ChickenCoopBlock > CODEC = simpleCodec (ChickenCoopBlock ::new );
4040
41+ /**
42+ * Create a ChickenCoopBlock configured with the provided block properties and a default state.
43+ *
44+ * The default state sets FACING to NORTH and PART to CoopPart.BOTTOM_FRONT_LEFT.
45+ *
46+ * @param properties block properties used to configure this block's behaviour and characteristics
47+ */
4148 public ChickenCoopBlock (Properties properties ) {
4249 super (properties );
4350 // Default to the origin part (Bottom Front Left) facing North
@@ -46,6 +53,18 @@ public ChickenCoopBlock(Properties properties) {
4653 .setValue (PART , CoopPart .BOTTOM_FRONT_LEFT ));
4754 }
4855
56+ /**
57+ * Provides a BlockEntityTicker for the coop's centre-front part on the server.
58+ *
59+ * Returns a ticker that delegates to ChickenCoopEntity.tick when the call is on the logical server,
60+ * the block state's PART is BOTTOM_FRONT_CENTER and the requested BlockEntityType equals ModBlockEntities.CHICKEN_COOP_BE.
61+ *
62+ * @param <T> the block entity type
63+ * @param level the level containing the block
64+ * @param state the block state for which a ticker is requested
65+ * @param type the requested block entity type
66+ * @return a ticker delegating to ChickenCoopEntity.tick when applicable, `null` otherwise
67+ */
4968 @ Nullable
5069 @ Override
5170 public <T extends BlockEntity > BlockEntityTicker <T > getTicker (Level level , BlockState state , BlockEntityType <T > type ) {
@@ -61,6 +80,13 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, Block
6180 : null ;
6281 }
6382
83+ /**
84+ * Creates the block entity for the coop when this block represents the centre-front (brain) part.
85+ *
86+ * @param pos the block position
87+ * @param state the current block state
88+ * @return {@code ChickenCoopEntity} for the centre-front part, {@code null} otherwise
89+ */
6490 @ Nullable
6591 @ Override
6692 public BlockEntity newBlockEntity (BlockPos pos , BlockState state ) {
@@ -71,6 +97,13 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
7197 return null ;
7298 }
7399
100+ /**
101+ * Registers this block's state properties.
102+ *
103+ * Adds the horizontal facing and coop part properties so block states can represent orientation and segment.
104+ *
105+ * @param builder the state definition builder to register properties with
106+ */
74107 @ Override
75108 protected void createBlockStateDefinition (StateDefinition .Builder <Block , BlockState > builder ) {
76109 builder .add (FACING , PART );
@@ -221,7 +254,14 @@ public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state,
221254 }
222255
223256 /**
224- * Rotates the 3x3x2 grid logic based on which way the player is facing.
257+ * Compute the world block position for a local coordinate inside the coop's 3×2×3 grid, taking block facing into account.
258+ *
259+ * @param origin the reference origin position (the block considered as the grid origin)
260+ * @param facing the horizontal direction the coop is facing; used to convert local depth into world direction
261+ * @param x local x index in the 3-wide grid (0 = left, 1 = centre, 2 = right)
262+ * @param z local depth index along the facing direction (0..2); larger values are further away from the player
263+ * @param y local vertical index (0..2) measured as blocks above the origin
264+ * @return the computed BlockPos in world coordinates for the given local grid coordinate
225265 */
226266 private BlockPos calculateOffset (BlockPos origin , Direction facing , int x , int z , int y ) {
227267 // x-1 centers the 3-wide structure (0=left, 1=center, 2=right)
@@ -234,12 +274,31 @@ private BlockPos calculateOffset(BlockPos origin, Direction facing, int x, int z
234274 .above (y );
235275 }
236276
277+ /**
278+ * Provide the block's MapCodec used by the game's codec system for (de)serialisation.
279+ *
280+ * @return the MapCodec instance for this block's state
281+ */
237282 @ Override
238283 protected MapCodec <? extends HorizontalDirectionalBlock > codec () {
239284 return CODEC ;
240285 }
241286
242- @ Override
287+ /**
288+ * Handle interaction with the coop when used without an item, dispensing any collected eggs to the player.
289+ *
290+ * On the client this returns `InteractionResult.SUCCESS`. On the server this locates the coop's brain
291+ * block entity (the bottom-front-center part); if that entity has eggs they are transferred to the player
292+ * (or dropped at the player's feet if their inventory is full) and a chicken-egg sound is played.
293+ *
294+ * @param state the current block state
295+ * @param level the level where the block is located
296+ * @param pos the position of the interacted block
297+ * @param player the player performing the interaction
298+ * @param hitResult hit information for the interaction
299+ * @return `InteractionResult.SUCCESS` if eggs were given or on the client, `InteractionResult.PASS` otherwise.
300+ */
301+ @ Override
243302 protected InteractionResult useWithoutItem (BlockState state , Level level , BlockPos pos , Player player , BlockHitResult hitResult ) {
244303 if (level .isClientSide ()) return InteractionResult .SUCCESS ;
245304
0 commit comments