@@ -13,6 +13,7 @@ namespace MechTransfer.Tiles
13
13
public class TransferAssemblerTile : ModTile
14
14
{
15
15
private ItemInventory inventory = new ItemInventory ( ) ;
16
+ private Item stockpile = new Item ( ) ;
16
17
17
18
private Dictionary < int , int [ ] > tileRemap = new Dictionary < int , int [ ] > ( ) {
18
19
{ 302 , new int [ ] { 17 } } ,
@@ -67,6 +68,18 @@ public override void HitWire(int i, int j)
67
68
68
69
private bool TryMakeRecipe ( Recipe recipe , TransferAssemblerTileEntity entity )
69
70
{
71
+
72
+ while ( stockpile . stack > 0 )
73
+ {
74
+ Item safeCLone = stockpile . Clone ( ) ;
75
+ safeCLone . stack = 1 ;
76
+ if ( ! TransferUtils . InjectItem ( entity . Position . X , entity . Position . Y , safeCLone ) )
77
+ {
78
+ return true ;
79
+ }
80
+ stockpile . stack -- ;
81
+ }
82
+
70
83
for ( int i = 0 ; i < Recipe . maxRequirements && ! recipe . requiredItem [ i ] . IsAir ; i ++ )
71
84
{
72
85
if ( ! inventory . TryTakeIngredient ( recipe , recipe . requiredItem [ i ] ) )
@@ -93,10 +106,27 @@ private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
93
106
ItemLoader . OnCraft ( clone , recipe ) ;
94
107
}
95
108
96
- if ( ! TransferUtils . InjectItem ( entity . Position . X , entity . Position . Y , clone ) )
109
+ if ( clone . stack == 1 )
110
+ {
111
+ if ( ! TransferUtils . InjectItem ( entity . Position . X , entity . Position . Y , clone ) )
112
+ {
113
+ entity . Status = TransferAssemblerTileEntity . StatusKind . MissingSpace ;
114
+ return true ; //returning with success, so we don't try alternate recipes
115
+ }
116
+ }
117
+ else
97
118
{
98
- entity . Status = TransferAssemblerTileEntity . StatusKind . MissingSpace ;
99
- return true ; //returning with success, so we don't try alternate recipes
119
+ stockpile = clone ;
120
+ while ( stockpile . stack > 0 )
121
+ {
122
+ Item safeCLone = stockpile . Clone ( ) ;
123
+ safeCLone . stack = 1 ;
124
+ if ( ! TransferUtils . InjectItem ( entity . Position . X , entity . Position . Y , safeCLone ) )
125
+ {
126
+ break ;
127
+ }
128
+ stockpile . stack -- ;
129
+ }
100
130
}
101
131
102
132
inventory . Commit ( alchemy ) ;
0 commit comments