|
34 | 34 | import net.minecraft.world.item.crafting.RecipeType;
|
35 | 35 | import net.minecraft.world.level.block.entity.BlockEntityType;
|
36 | 36 | import net.minecraft.world.level.block.state.BlockState;
|
37 |
| -import org.jetbrains.annotations.Contract; |
38 | 37 | import org.jetbrains.annotations.NotNull;
|
39 | 38 |
|
40 | 39 | /**
|
|
44 | 43 | * @param <R> The type of recipe the machine uses.
|
45 | 44 | */
|
46 | 45 | public abstract class BasicRecipeMachineBlockEntity<I extends RecipeInput, R extends Recipe<I>> extends RecipeMachineBlockEntity<I, R> {
|
47 |
| - /** |
48 |
| - * An inventory for use in finding vanilla recipes for this machine. |
49 |
| - */ |
50 |
| - protected final @NotNull I craftingInv; |
51 |
| - |
52 | 46 | protected final SlottedStorageAccess<Item, ItemResourceSlot> inputSlots;
|
53 | 47 | protected final SlottedStorageAccess<Item, ItemResourceSlot> outputSlots;
|
54 | 48 |
|
@@ -101,52 +95,20 @@ protected BasicRecipeMachineBlockEntity(BlockEntityType<? extends BasicRecipeMac
|
101 | 95 |
|
102 | 96 | this.inputSlots = this.itemStorage().subStorage(inputSlots, inputSlotsLen);
|
103 | 97 | this.outputSlots = this.itemStorage().subStorage(outputSlots, outputSlotsLen);
|
104 |
| - |
105 |
| - this.craftingInv = this.createCraftingInv(); |
106 |
| - } |
107 |
| - |
108 |
| - protected abstract I createCraftingInv(); |
109 |
| - |
110 |
| - /** |
111 |
| - * Creates an inventory for use in finding vanilla recipes for this machine. |
112 |
| - * NOTE: This inventory can assume that it is never modified - do not modify it! |
113 |
| - * |
114 |
| - * @return The crafting inventory of the machine. |
115 |
| - */ |
116 |
| - @Override |
117 |
| - @Contract(pure = true) |
118 |
| - protected @NotNull I craftingInv() { |
119 |
| - return this.craftingInv; |
120 | 98 | }
|
121 | 99 |
|
122 |
| - /** |
123 |
| - * Inserts the active recipe's output into the machine's inventory. |
124 |
| - * |
125 |
| - * @param recipe The recipe to output. |
126 |
| - */ |
127 | 100 | @Override
|
128 | 101 | protected void outputStacks(@NotNull RecipeHolder<R> recipe) {
|
129 | 102 | ItemStack assembled = recipe.value().assemble(this.craftingInv(), this.level.registryAccess());
|
130 | 103 | this.outputSlots.insertMatching(assembled.getItem(), assembled.getComponentsPatch(), assembled.getCount());
|
131 | 104 | }
|
132 | 105 |
|
133 |
| - /** |
134 |
| - * Checks if the machine can output stacks for the given recipe. |
135 |
| - * |
136 |
| - * @param recipe The recipe to check. |
137 |
| - * @return {@code true} if the machine can output stacks for the recipe, {@code false} otherwise. |
138 |
| - */ |
139 | 106 | @Override
|
140 | 107 | protected boolean canOutputStacks(@NotNull RecipeHolder<R> recipe) {
|
141 | 108 | ItemStack assembled = recipe.value().assemble(this.craftingInv(), this.level.registryAccess());
|
142 |
| - return this.inputSlots.canInsert(assembled.getItem(), assembled.getComponentsPatch(), assembled.getCount()); |
| 109 | + return this.outputSlots.canInsert(assembled.getItem(), assembled.getComponentsPatch(), assembled.getCount()); |
143 | 110 | }
|
144 | 111 |
|
145 |
| - /** |
146 |
| - * Extracts the recipe's input from the machine's inventory. |
147 |
| - * |
148 |
| - * @param recipe The recipe to extract. |
149 |
| - */ |
150 | 112 | @Override
|
151 | 113 | protected void extractCraftingMaterials(@NotNull RecipeHolder<R> recipe) {
|
152 | 114 | for (ItemResourceSlot slot : this.inputSlots) {
|
|
0 commit comments