Skip to content

Commit c852d4a

Browse files
committed
v1.4.2 hotfix
1 parent 1762b22 commit c852d4a

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

Tiles/TransferAssemblerTile.cs

+33-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace MechTransfer.Tiles
1313
public class TransferAssemblerTile : ModTile
1414
{
1515
private ItemInventory inventory = new ItemInventory();
16+
private Item stockpile = new Item();
1617

1718
private Dictionary<int, int[]> tileRemap = new Dictionary<int, int[]>() {
1819
{ 302, new int[]{ 17 } },
@@ -67,6 +68,18 @@ public override void HitWire(int i, int j)
6768

6869
private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
6970
{
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+
7083
for (int i = 0; i < Recipe.maxRequirements && !recipe.requiredItem[i].IsAir; i++)
7184
{
7285
if (!inventory.TryTakeIngredient(recipe, recipe.requiredItem[i]))
@@ -93,10 +106,27 @@ private bool TryMakeRecipe(Recipe recipe, TransferAssemblerTileEntity entity)
93106
ItemLoader.OnCraft(clone, recipe);
94107
}
95108

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
97118
{
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+
}
100130
}
101131

102132
inventory.Commit(alchemy);

build.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
author = DRKV
2-
version = 1.4.1
2+
version = 1.4.2
33
displayName = MechTransfer
44
includePDB = false
55
buildIgnore = .gitignore, description.txt, *.csproj*, *.sln, .git/*, .vs/*, bin/*, obj/*, *.xcf

description.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ v1.4
4242
- Added reflection based adapter loading
4343

4444
v1.4.1
45-
- Fixed modded chest support
45+
- Fixed modded chest support
46+
47+
v1.4.2
48+
- Quick fix to stop assembler from eating items

0 commit comments

Comments
 (0)