24
24
25
25
import dev .galacticraft .machinelib .api .machine .MachineType ;
26
26
import dev .galacticraft .machinelib .api .menu .RecipeMachineMenu ;
27
+ import dev .galacticraft .machinelib .api .storage .SlottedStorageAccess ;
28
+ import dev .galacticraft .machinelib .api .storage .slot .ItemResourceSlot ;
27
29
import net .minecraft .core .BlockPos ;
28
30
import net .minecraft .world .Container ;
31
+ import net .minecraft .world .item .Item ;
29
32
import net .minecraft .world .item .ItemStack ;
30
33
import net .minecraft .world .item .crafting .Recipe ;
31
34
import net .minecraft .world .item .crafting .RecipeHolder ;
@@ -46,10 +49,8 @@ public abstract class BasicRecipeMachineBlockEntity<C extends Container, R exten
46
49
*/
47
50
protected final @ NotNull C craftingInv ;
48
51
49
- protected final int inputSlots ;
50
- protected final int inputSlotsLen ;
51
- protected final int outputSlots ;
52
- protected final int outputSlotsLen ;
52
+ protected final SlottedStorageAccess <Item , ItemResourceSlot > inputSlots ;
53
+ protected final SlottedStorageAccess <Item , ItemResourceSlot > outputSlots ;
53
54
54
55
/**
55
56
* Constructs a new machine block entity that processes recipes.
@@ -98,10 +99,8 @@ protected BasicRecipeMachineBlockEntity(@NotNull MachineType<? extends BasicReci
98
99
@ NotNull BlockPos pos , BlockState state , @ NotNull RecipeType <R > recipeType , int inputSlots , int inputSlotsLen , int outputSlots , int outputSlotsLen ) {
99
100
super (type , pos , state , recipeType );
100
101
101
- this .inputSlots = inputSlots ;
102
- this .inputSlotsLen = inputSlotsLen ;
103
- this .outputSlots = outputSlots ;
104
- this .outputSlotsLen = outputSlotsLen ;
102
+ this .inputSlots = this .itemStorage ().subStorage (inputSlots , inputSlotsLen );
103
+ this .outputSlots = this .itemStorage ().subStorage (outputSlots , outputSlotsLen );
105
104
106
105
this .craftingInv = this .createCraftingInv ();
107
106
}
@@ -128,7 +127,7 @@ protected BasicRecipeMachineBlockEntity(@NotNull MachineType<? extends BasicReci
128
127
@ Override
129
128
protected void outputStacks (@ NotNull RecipeHolder <R > recipe ) {
130
129
ItemStack assembled = recipe .value ().assemble (this .craftingInv (), this .level .registryAccess ());
131
- this .itemStorage () .insertMatching (this . outputSlots , this . outputSlotsLen , assembled .getItem (), assembled .getComponentsPatch (), assembled .getCount ());
130
+ this .outputSlots .insertMatching (assembled .getItem (), assembled .getComponentsPatch (), assembled .getCount ());
132
131
}
133
132
134
133
/**
@@ -140,7 +139,7 @@ protected void outputStacks(@NotNull RecipeHolder<R> recipe) {
140
139
@ Override
141
140
protected boolean canOutputStacks (@ NotNull RecipeHolder <R > recipe ) {
142
141
ItemStack assembled = recipe .value ().assemble (this .craftingInv (), this .level .registryAccess ());
143
- return this .itemStorage () .canInsert (this . outputSlots , this . outputSlotsLen , assembled .getItem (), assembled .getComponentsPatch (), assembled .getCount ());
142
+ return this .inputSlots .canInsert (assembled .getItem (), assembled .getComponentsPatch (), assembled .getCount ());
144
143
}
145
144
146
145
/**
@@ -150,8 +149,8 @@ protected boolean canOutputStacks(@NotNull RecipeHolder<R> recipe) {
150
149
*/
151
150
@ Override
152
151
protected void extractCraftingMaterials (@ NotNull RecipeHolder <R > recipe ) {
153
- for (int i = 0 ; i < this .inputSlotsLen ; i ++ ) {
154
- this . itemStorage (). consumeOne (this . inputSlots + i );
152
+ for (ItemResourceSlot slot : this .inputSlots ) {
153
+ slot . consumeOne ();
155
154
}
156
155
}
157
156
}
0 commit comments