From 5de2200706ac08c154067f69c2a29ff1ad0556ac Mon Sep 17 00:00:00 2001 From: Andy Wilson Date: Thu, 22 Jan 2026 19:03:58 +0000 Subject: [PATCH 1/6] feat: added optional secondary result item --- .../entity/custom/CrusherBlockEntity.java | 44 ++++++++++++++----- .../pizza/houseki/recipe/CrusherRecipe.java | 34 +++++++++----- .../screen/custom/CrusherScreenHandler.java | 6 +++ 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java index 5f153e30..47b4e9d6 100644 --- a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java +++ b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java @@ -34,11 +34,12 @@ import java.util.Optional; public class CrusherBlockEntity extends BlockEntity implements ExtendedScreenHandlerFactory, ImplementedInventory { - private final DefaultedList inventory = DefaultedList.ofSize(3, ItemStack.EMPTY); + private final DefaultedList inventory = DefaultedList.ofSize(4, ItemStack.EMPTY); private static final int INPUT_SLOT = 0; private static final int FUEL_SLOT = 1; private static final int OUTPUT_SLOT = 2; + private static final int AUXILARY_OUTPUT_SLOT = 3; protected final PropertyDelegate propertyDelegate; private int progress = 0; @@ -183,23 +184,44 @@ private boolean canCraft() { Optional> recipe = getCurrentRecipe(); if (recipe.isEmpty()) return false; - ItemStack output = recipe.get().value().getResult(null); - ItemStack outputSlot = inventory.get(OUTPUT_SLOT); - return (outputSlot.isEmpty() || outputSlot.isOf(output.getItem())) - && outputSlot.getCount() + output.getCount() <= outputSlot.getMaxCount(); + CrusherRecipe crusherRecipe = recipe.get().value(); + ItemStack output = crusherRecipe.getResult(null); + ItemStack auxiliary = crusherRecipe.getAuxiliaryOutput().orElse(ItemStack.EMPTY); + + return canInsertIntoSlot(OUTPUT_SLOT, output) && canInsertIntoSlot(AUXILARY_OUTPUT_SLOT, auxiliary); + } + + private boolean canInsertIntoSlot(int slot, ItemStack stack) { + if (stack.isEmpty()) return true; + ItemStack slotStack = inventory.get(slot); + return (slotStack.isEmpty() || ItemStack.areItemsAndComponentsEqual(slotStack, stack)) + && slotStack.getCount() + stack.getCount() <= slotStack.getMaxCount(); } private void craftItem() { Optional> recipe = getCurrentRecipe(); if (recipe.isEmpty()) return; + CrusherRecipe crusherRecipe = recipe.get().value(); + + // Handle Main Output + insertOrIncrement(OUTPUT_SLOT, crusherRecipe.output().copy()); + + // Handle Auxiliary Output + crusherRecipe.getAuxiliaryOutput().ifPresent(stack -> { + insertOrIncrement(AUXILARY_OUTPUT_SLOT, stack.copy()); + }); + inventory.get(INPUT_SLOT).decrement(1); - ItemStack outputSlot = inventory.get(OUTPUT_SLOT); - ItemStack result = recipe.get().value().output().copy(); - if (outputSlot.isEmpty()) { - inventory.set(OUTPUT_SLOT, result); + } + + private void insertOrIncrement(int slot, ItemStack result) { + if (result.isEmpty()) return; + ItemStack slotStack = inventory.get(slot); + if (slotStack.isEmpty()) { + inventory.set(slot, result); } else { - outputSlot.increment(result.getCount()); + slotStack.increment(result.getCount()); } } @@ -223,7 +245,7 @@ public boolean canInsert(int slot, ItemStack stack, @Nullable Direction side) { @Override public boolean canExtract(int slot, ItemStack stack, Direction side) { - return slot == OUTPUT_SLOT; + return slot == OUTPUT_SLOT || slot == AUXILARY_OUTPUT_SLOT; } @Nullable diff --git a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java index 3da43deb..09367e23 100644 --- a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java +++ b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java @@ -1,5 +1,7 @@ package anya.pizza.houseki.recipe; +import java.util.Optional; + import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import com.mojang.serialization.codecs.RecordCodecBuilder; @@ -15,7 +17,7 @@ import net.minecraft.util.collection.DefaultedList; import net.minecraft.world.World; -public record CrusherRecipe(Ingredient inputItem, ItemStack output, int crushingTime) implements Recipe { +public record CrusherRecipe(Ingredient inputItem, ItemStack output, int crushingTime, Optional auxiliaryOutput) implements Recipe { public static final int DEFAULT_CRUSHING_TIME = 200; @Override @@ -49,6 +51,11 @@ public ItemStack getResult(RegistryWrapper.WrapperLookup registriesLookup) { return output; } + // 2. Getter for the secondary slot + public Optional getAuxiliaryOutput() { + return auxiliaryOutput; + } + @Override public RecipeSerializer getSerializer() { return ModRecipes.CRUSHER_SERIALIZER; @@ -62,16 +69,23 @@ public RecipeType getType() { public static class Serializer implements RecipeSerializer { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> inst.group( - Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("ingredient").forGetter(CrusherRecipe::inputItem), - ItemStack.CODEC.fieldOf("result").forGetter(CrusherRecipe::output), - Codec.INT.optionalFieldOf("crushingTime",DEFAULT_CRUSHING_TIME).forGetter(CrusherRecipe::crushingTime) - ).apply(inst, CrusherRecipe::new)); + Ingredient.DISALLOW_EMPTY_CODEC.fieldOf("ingredient").forGetter(CrusherRecipe::inputItem), + ItemStack.CODEC.fieldOf("result").forGetter(CrusherRecipe::output), + Codec.INT.optionalFieldOf("crushingTime", DEFAULT_CRUSHING_TIME).forGetter(CrusherRecipe::crushingTime), + // Optional auxiliary output is now the 4th parameter + ItemStack.CODEC.optionalFieldOf("auxiliary_result", ItemStack.EMPTY) + .xmap(Optional::of, opt -> opt.orElse(ItemStack.EMPTY)) + .forGetter(CrusherRecipe::auxiliaryOutput) + ).apply(inst, CrusherRecipe::new)); + public static final PacketCodec STREAM_CODEC = - PacketCodec.tuple( - Ingredient.PACKET_CODEC, CrusherRecipe::inputItem, - ItemStack.PACKET_CODEC, CrusherRecipe::output, - PacketCodecs.INTEGER, CrusherRecipe::crushingTime, - CrusherRecipe::new); + PacketCodec.tuple( + Ingredient.PACKET_CODEC, CrusherRecipe::inputItem, + ItemStack.PACKET_CODEC, CrusherRecipe::output, + PacketCodecs.INTEGER, CrusherRecipe::crushingTime, + // Optional auxiliary output is now the 4th parameter + PacketCodecs.optional(ItemStack.PACKET_CODEC), CrusherRecipe::auxiliaryOutput, + CrusherRecipe::new); @Override public MapCodec codec() { diff --git a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java index 4951fe34..651eec16 100644 --- a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java +++ b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java @@ -38,6 +38,12 @@ public boolean canInsert(ItemStack stack) { return false; //Makes output slot read-only } }); + this.addSlot(new Slot(inventory, 3, 130, 30) { + @Override + public boolean canInsert(ItemStack stack) { + return false; //Makes output slot read-only + } + }); addPlayerInventory(playerInventory); addPlayerHotbar(playerInventory); From be3a58df3bb1aead2ddc94097321b374b5a9ea8d Mon Sep 17 00:00:00 2001 From: Andy Wilson Date: Thu, 22 Jan 2026 19:23:02 +0000 Subject: [PATCH 2/6] fix: correct the recipie --- .../pizza/houseki/recipe/CrusherRecipe.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java index 09367e23..bab55811 100644 --- a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java +++ b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java @@ -20,6 +20,19 @@ public record CrusherRecipe(Ingredient inputItem, ItemStack output, int crushingTime, Optional auxiliaryOutput) implements Recipe { public static final int DEFAULT_CRUSHING_TIME = 200; + public CrusherRecipe { + if (auxiliaryOutput == null) { + auxiliaryOutput = Optional.empty(); + } + } + + // 2. Secondary Constructor (For DataGen/Old Recipes) + // This allows you to call: new CrusherRecipe(input, output, time) + // It will automatically fill the Optional with empty. + public CrusherRecipe(Ingredient inputItem, ItemStack output, int crushingTime) { + this(inputItem, output, crushingTime, Optional.empty()); + } + @Override public DefaultedList getIngredients() { DefaultedList list = DefaultedList.of(); @@ -83,8 +96,8 @@ public static class Serializer implements RecipeSerializer { Ingredient.PACKET_CODEC, CrusherRecipe::inputItem, ItemStack.PACKET_CODEC, CrusherRecipe::output, PacketCodecs.INTEGER, CrusherRecipe::crushingTime, - // Optional auxiliary output is now the 4th parameter - PacketCodecs.optional(ItemStack.PACKET_CODEC), CrusherRecipe::auxiliaryOutput, + // Change this line to use OPTIONAL_PACKET_CODEC + PacketCodecs.optional(ItemStack.OPTIONAL_PACKET_CODEC), CrusherRecipe::auxiliaryOutput, CrusherRecipe::new); @Override From c3979801b11cab4985436b7057bad2a0d38d6b0a Mon Sep 17 00:00:00 2001 From: Andy Wilson Date: Thu, 22 Jan 2026 19:52:20 +0000 Subject: [PATCH 3/6] fix: incorrect comparison --- .../pizza/houseki/block/entity/custom/CrusherBlockEntity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java index 47b4e9d6..b61419fa 100644 --- a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java +++ b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java @@ -194,8 +194,9 @@ private boolean canCraft() { private boolean canInsertIntoSlot(int slot, ItemStack stack) { if (stack.isEmpty()) return true; ItemStack slotStack = inventory.get(slot); + int maxCount = slotStack.isEmpty() ? stack.getMaxCount() : slotStack.getMaxCount(); return (slotStack.isEmpty() || ItemStack.areItemsAndComponentsEqual(slotStack, stack)) - && slotStack.getCount() + stack.getCount() <= slotStack.getMaxCount(); + && slotStack.getCount() + stack.getCount() <= maxCount; } private void craftItem() { From 3106e0b6f0ca753339b3eee090773fdc43c3f9d6 Mon Sep 17 00:00:00 2001 From: Andy Wilson Date: Thu, 22 Jan 2026 20:12:12 +0000 Subject: [PATCH 4/6] fix: update some things to make it consistent --- .../block/entity/custom/CrusherBlockEntity.java | 16 ++++++++-------- .../anya/pizza/houseki/recipe/CrusherRecipe.java | 5 ----- .../screen/custom/CrusherScreenHandler.java | 2 +- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java index b61419fa..2434386b 100644 --- a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java +++ b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java @@ -39,7 +39,7 @@ public class CrusherBlockEntity extends BlockEntity implements ExtendedScreenHan private static final int INPUT_SLOT = 0; private static final int FUEL_SLOT = 1; private static final int OUTPUT_SLOT = 2; - private static final int AUXILARY_OUTPUT_SLOT = 3; + private static final int AUXILIARY_OUTPUT_SLOT = 3; protected final PropertyDelegate propertyDelegate; private int progress = 0; @@ -186,9 +186,9 @@ private boolean canCraft() { CrusherRecipe crusherRecipe = recipe.get().value(); ItemStack output = crusherRecipe.getResult(null); - ItemStack auxiliary = crusherRecipe.getAuxiliaryOutput().orElse(ItemStack.EMPTY); + ItemStack auxiliary = crusherRecipe.auxiliaryOutput().orElse(ItemStack.EMPTY); - return canInsertIntoSlot(OUTPUT_SLOT, output) && canInsertIntoSlot(AUXILARY_OUTPUT_SLOT, auxiliary); + return canInsertIntoSlot(OUTPUT_SLOT, output) && canInsertIntoSlot(AUXILIARY_OUTPUT_SLOT, auxiliary); } private boolean canInsertIntoSlot(int slot, ItemStack stack) { @@ -206,11 +206,11 @@ private void craftItem() { CrusherRecipe crusherRecipe = recipe.get().value(); // Handle Main Output - insertOrIncrement(OUTPUT_SLOT, crusherRecipe.output().copy()); + insertOrIncrement(OUTPUT_SLOT, crusherRecipe.getResult(null).copy()); // Handle Auxiliary Output - crusherRecipe.getAuxiliaryOutput().ifPresent(stack -> { - insertOrIncrement(AUXILARY_OUTPUT_SLOT, stack.copy()); + crusherRecipe.auxiliaryOutput().ifPresent(stack -> { + insertOrIncrement(AUXILIARY_OUTPUT_SLOT, stack.copy()); }); inventory.get(INPUT_SLOT).decrement(1); @@ -233,7 +233,7 @@ private Optional> getCurrentRecipe() { @Override public int[] getAvailableSlots(Direction side) { - return side == Direction.DOWN ? new int[]{OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT}; + return side == Direction.DOWN ? new int[]{OUTPUT_SLOT, AUXILIARY_OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT}; } @Override @@ -246,7 +246,7 @@ public boolean canInsert(int slot, ItemStack stack, @Nullable Direction side) { @Override public boolean canExtract(int slot, ItemStack stack, Direction side) { - return slot == OUTPUT_SLOT || slot == AUXILARY_OUTPUT_SLOT; + return slot == OUTPUT_SLOT || slot == AUXILIARY_OUTPUT_SLOT; } @Nullable diff --git a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java index bab55811..aed66c62 100644 --- a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java +++ b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java @@ -64,11 +64,6 @@ public ItemStack getResult(RegistryWrapper.WrapperLookup registriesLookup) { return output; } - // 2. Getter for the secondary slot - public Optional getAuxiliaryOutput() { - return auxiliaryOutput; - } - @Override public RecipeSerializer getSerializer() { return ModRecipes.CRUSHER_SERIALIZER; diff --git a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java index 651eec16..3e06e1af 100644 --- a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java +++ b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java @@ -26,7 +26,7 @@ public CrusherScreenHandler(int syncId, PlayerInventory inventory, BlockPos pos) public CrusherScreenHandler(int syncId, PlayerInventory playerInventory, BlockEntity blockEntity, PropertyDelegate arrayPropertyDelegate) { super(ModScreenHandlers.CRUSHER_SCREEN_HANDLER, syncId); - checkSize((Inventory) blockEntity, 3); + checkSize((Inventory) blockEntity, 4); this.inventory = (Inventory) blockEntity; this.propertyDelegate = arrayPropertyDelegate; this.blockEntity = (CrusherBlockEntity) blockEntity; From ac1e6c9c199c3d27dee7b6110c0e68f1c5e802d1 Mon Sep 17 00:00:00 2001 From: Andy Wilson Date: Thu, 22 Jan 2026 20:16:42 +0000 Subject: [PATCH 5/6] feat: add aux item of iron nugget to crushing of bauxite --- .../houseki/recipe/crushed_bauxite_from_crushing_bauxite.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/data/houseki/recipe/crushed_bauxite_from_crushing_bauxite.json b/src/main/resources/data/houseki/recipe/crushed_bauxite_from_crushing_bauxite.json index c94e2681..7cd3b688 100644 --- a/src/main/resources/data/houseki/recipe/crushed_bauxite_from_crushing_bauxite.json +++ b/src/main/resources/data/houseki/recipe/crushed_bauxite_from_crushing_bauxite.json @@ -6,5 +6,9 @@ "result": { "id": "houseki:crushed_bauxite" }, + "auxiliary_result": { + "id": "minecraft:iron_nugget", + "count": 1 + }, "crushingTime": 250 } \ No newline at end of file From db5262f8bb8cbe6837f574ffbbf1204b4115dc11 Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 20:22:48 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`fea?= =?UTF-8?q?t/add-optional-second-item`?= 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/Houseki/pull/1#issuecomment-3786524307 The following files were modified: * `src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java` * `src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java` * `src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java` --- .../entity/custom/CrusherBlockEntity.java | 59 ++++++++++++++++++- .../pizza/houseki/recipe/CrusherRecipe.java | 20 ++++++- .../screen/custom/CrusherScreenHandler.java | 10 +++- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java index 2434386b..3a5f1390 100644 --- a/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java +++ b/src/main/java/anya/pizza/houseki/block/entity/custom/CrusherBlockEntity.java @@ -180,6 +180,13 @@ private void updateMaxProgress(World world) { .orElse(CrusherRecipe.DEFAULT_CRUSHING_TIME); } + /** + * Determines whether the crusher can perform a craft with the current input. + * + * Checks for a matching CrusherRecipe and verifies that the recipe's primary output and optional auxiliary output can be inserted into the output and auxiliary output slots respectively. + * + * @return `true` if a matching recipe exists and both outputs can be inserted into their target slots, `false` otherwise. + */ private boolean canCraft() { Optional> recipe = getCurrentRecipe(); if (recipe.isEmpty()) return false; @@ -191,6 +198,14 @@ private boolean canCraft() { return canInsertIntoSlot(OUTPUT_SLOT, output) && canInsertIntoSlot(AUXILIARY_OUTPUT_SLOT, auxiliary); } + /** + * Determine whether the given ItemStack can be placed into the specified inventory slot + * without violating item compatibility or stack size limits. + * + * @param slot index of the target slot in the block entity's inventory + * @param stack the ItemStack intended for insertion; an empty stack is considered insertable + * @return `true` if the slot can accept the stack (slot empty or same item/component and total count does not exceed the slot's max), `false` otherwise + */ private boolean canInsertIntoSlot(int slot, ItemStack stack) { if (stack.isEmpty()) return true; ItemStack slotStack = inventory.get(slot); @@ -199,6 +214,12 @@ private boolean canInsertIntoSlot(int slot, ItemStack stack) { && slotStack.getCount() + stack.getCount() <= maxCount; } + /** + * Executes the currently matched crusher recipe: adds the recipe's main output to the output slot, + * adds the optional auxiliary output to the auxiliary output slot if present, and consumes one input. + * + * If no matching recipe is available, no changes are made. + */ private void craftItem() { Optional> recipe = getCurrentRecipe(); if (recipe.isEmpty()) return; @@ -216,6 +237,15 @@ private void craftItem() { inventory.get(INPUT_SLOT).decrement(1); } + /** + * Inserts the provided ItemStack into the specified inventory slot, merging with the existing stack if present. + * + * If `result` is empty this method has no effect. If the target slot is empty the `result` is placed there; + * otherwise the existing stack's count is increased by `result.getCount()`. + * + * @param slot the index of the target inventory slot + * @param result the ItemStack to insert or merge into the slot + */ private void insertOrIncrement(int slot, ItemStack result) { if (result.isEmpty()) return; ItemStack slotStack = inventory.get(slot); @@ -231,11 +261,25 @@ private Optional> getCurrentRecipe() { } + /** + * Provide the indices of inventory slots that are accessible from the specified side. + * + * @param side the block face from which access is attempted + * @return an array of slot indices; for {@link Direction#DOWN} returns {OUTPUT_SLOT, AUXILIARY_OUTPUT_SLOT}, otherwise returns {INPUT_SLOT, FUEL_SLOT} + */ @Override public int[] getAvailableSlots(Direction side) { return side == Direction.DOWN ? new int[]{OUTPUT_SLOT, AUXILIARY_OUTPUT_SLOT} : new int[]{INPUT_SLOT, FUEL_SLOT}; } + /** + * Determines whether the given ItemStack may be inserted into the specified inventory slot from the provided side. + * + * @param slot the target inventory slot index + * @param stack the ItemStack to insert + * @param side the side from which insertion is attempted; may be null for non-sided access + * @return `true` if insertion is allowed: fuel slot accepts items that provide fuel time, input slot accepts items that match a Crusher recipe; `false` otherwise. + */ @Override public boolean canInsert(int slot, ItemStack stack, @Nullable Direction side) { if (slot == FUEL_SLOT) return getFuelTime(stack) > 0; @@ -244,11 +288,24 @@ public boolean canInsert(int slot, ItemStack stack, @Nullable Direction side) { return false; } + /** + * Determines whether items may be extracted from the given slot from the specified side. + * + * @param slot the slot index being accessed + * @param stack the stack being extracted + * @param side the side of the block from which extraction is attempted + * @return `true` if the slot is the primary output slot or the auxiliary output slot, `false` otherwise + */ @Override public boolean canExtract(int slot, ItemStack stack, Direction side) { return slot == OUTPUT_SLOT || slot == AUXILIARY_OUTPUT_SLOT; } + /** + * Create a network packet containing this block entity's update data for the client. + * + * @return the update packet for synchronizing this block entity to clients, or {@code null} if no update is required + */ @Nullable @Override public Packet toUpdatePacket() { @@ -265,4 +322,4 @@ public void clear() { inventory.clear(); markDirty(); } -} +} \ No newline at end of file diff --git a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java index aed66c62..8469d789 100644 --- a/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java +++ b/src/main/java/anya/pizza/houseki/recipe/CrusherRecipe.java @@ -28,11 +28,22 @@ public record CrusherRecipe(Ingredient inputItem, ItemStack output, int crushing // 2. Secondary Constructor (For DataGen/Old Recipes) // This allows you to call: new CrusherRecipe(input, output, time) - // It will automatically fill the Optional with empty. + /** + * Constructs a CrusherRecipe with the specified input, output, and crushing time, and with no auxiliary output. + * + * @param inputItem the ingredient consumed by the recipe + * @param output the primary result produced by the recipe + * @param crushingTime the time required to perform the crushing (in ticks) + */ public CrusherRecipe(Ingredient inputItem, ItemStack output, int crushingTime) { this(inputItem, output, crushingTime, Optional.empty()); } + /** + * Gets the recipe's ingredient list. + * + * @return a DefaultedList containing the single input ingredient for this recipe + */ @Override public DefaultedList getIngredients() { DefaultedList list = DefaultedList.of(); @@ -95,6 +106,11 @@ public static class Serializer implements RecipeSerializer { PacketCodecs.optional(ItemStack.OPTIONAL_PACKET_CODEC), CrusherRecipe::auxiliaryOutput, CrusherRecipe::new); + /** + * Returns the map-based codec for serializing and deserializing CrusherRecipe instances. + * + * @return the MapCodec that encodes and decodes CrusherRecipe objects + */ @Override public MapCodec codec() { return CODEC; @@ -106,4 +122,4 @@ public PacketCodec packetCodec() { } } -} +} \ No newline at end of file diff --git a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java index 3e06e1af..8a2f2dc1 100644 --- a/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java +++ b/src/main/java/anya/pizza/houseki/screen/custom/CrusherScreenHandler.java @@ -24,6 +24,14 @@ public CrusherScreenHandler(int syncId, PlayerInventory inventory, BlockPos pos) this(syncId, inventory, inventory.player.getWorld().getBlockEntity(pos), new ArrayPropertyDelegate(5)); } + /** + * Creates a Crusher screen handler, initializes the crusher and player inventories, and attaches the provided property delegate for GUI state syncing. + * + * @param syncId window sync id assigned by the client/server + * @param playerInventory the player's inventory to populate player slots and hotbar + * @param blockEntity the block entity whose inventory backs this handler; must be an Inventory of size 4 and is used as a CrusherBlockEntity + * @param arrayPropertyDelegate the PropertyDelegate used to synchronize progress, fuel, and related GUI properties + */ public CrusherScreenHandler(int syncId, PlayerInventory playerInventory, BlockEntity blockEntity, PropertyDelegate arrayPropertyDelegate) { super(ModScreenHandlers.CRUSHER_SCREEN_HANDLER, syncId); checkSize((Inventory) blockEntity, 4); @@ -129,4 +137,4 @@ private void addPlayerHotbar(PlayerInventory playerInventory) { public PropertyDelegate getPropertyDelegate() { return propertyDelegate; } -} +} \ No newline at end of file